diff --git a/.factorypath b/.factorypath new file mode 100644 index 0000000000000000000000000000000000000000..64aa78395684cdf667988ff5f0a9d23a40f8ff19 --- /dev/null +++ b/.factorypath @@ -0,0 +1,4 @@ + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f91fa9371fecdbfdea0875063f0030a632267f54 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/target/ +/.apt_generated/ +/.apt_generated_tests/ +/.project +/.classpath +/.settings +/org.etsi.osl.tmf.api.iml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..bb7d754baa751630b25598e182a30f062e9b6ebd --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,40 @@ +include: + - project: osl/code/org.etsi.osl.main + ref: main + file: + - ci-templates/default.yml + - ci-templates/build.yml + rules: + - if: '$CI_COMMIT_REF_NAME == "main"' + + - project: osl/code/org.etsi.osl.main + ref: develop + file: + - ci-templates/default.yml + - ci-templates/build.yml + rules: + - if: '$CI_COMMIT_REF_NAME == "develop"' + + - project: osl/code/org.etsi.osl.main + ref: $CI_COMMIT_REF_NAME + file: + - ci-templates/default.yml + - ci-templates/build.yml + rules: + - if: '$CI_COMMIT_REF_PROTECTED && $CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop"' + + - project: osl/code/org.etsi.osl.main + ref: develop + file: + - 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' + +maven_build: + extends: .maven_build + +docker_build: + extends: .docker_build + needs: + - maven_build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e7a7b05cf8fe304860bd076a7163a384075171d4 --- /dev/null +++ b/Dockerfile @@ -0,0 +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"] +EXPOSE 13082 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/README.md b/README.md index 8f78f76393956fe7b0812491ce1d71aab3e62cdd..0e1a978178b1e4d625912a53fac5106b048e3f53 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,3 @@ # org.etsi.osl.tmf.api - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://labs.etsi.org/rep/osl/code/org.etsi.osl.tmf.api.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://labs.etsi.org/rep/osl/code/org.etsi.osl.tmf.api/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +TMF OpenAPIs implementation. diff --git a/ci_settings.xml b/ci_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..69ad06ed6c63795d191555afde6ea2d1da4e133d --- /dev/null +++ b/ci_settings.xml @@ -0,0 +1,16 @@ + + + + gitlab-maven + + + + Job-Token + ${CI_JOB_TOKEN} + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..885c3062d39c252078cdaf8636c69305ec312f2a --- /dev/null +++ b/pom.xml @@ -0,0 +1,485 @@ + + 4.0.0 + + org.etsi.osl + org.etsi.osl.main + 1.0.0 + ../org.etsi.osl.main + + + + org.etsi.osl.tmf.api + org.etsi.osl.tmf.api + + + + UTF-8 + UTF-8 + ${spring-boot-version} + 1.5.3.Final + ${springdoc-version} + ${springdoc-security-version} + ${springdoc-openapiui-version} + jdt_apt + ${mysql.connector.version} + 1.18.28 + + + + + gitlab-maven + https://labs.etsi.org/rep/api/v4/groups/260/-/packages/maven + + + + + gitlab-maven + ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven + + + gitlab-maven + ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven + + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot-version} + pom + import + + + + org.apache.camel.springboot + camel-spring-boot-dependencies + ${camel.version} + pom + import + + + + com.google.guava + guava + 32.0.0-jre + + + org.keycloak.bom + keycloak-adapter-bom + ${keycloak.version} + pom + import + + + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + + org.springframework.boot + spring-boot-starter-oauth2-resource-server + + + + com.jayway.jsonpath + json-path + + + + + + org.projectlombok + lombok + provided + ${lombok-version} + + + + org.keycloak + keycloak-spring-boot-starter + + + org.keycloak + keycloak-spring-security-adapter + + + + org.keycloak + keycloak-admin-client + ${keycloak.version} + + + + mysql + mysql-connector-java + runtime + ${mysql-connector.version} + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-hibernate5-jakarta + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + + + org.springframework.boot + spring-boot-starter-activemq + + + org.apache.activemq + activemq-amqp + test + + + org.apache.qpid + proton-j + + + + + org.messaginghub + pooled-jms + + + + + org.apache.camel.springboot + camel-spring-boot-starter + + + org.apache.activemq + activemq-pool + + + org.apache.camel + camel-activemq + + + org.apache.activemq + activemq-broker + + + + + org.apache.camel.springboot + camel-service-starter + + + + org.apache.camel.springboot + camel-http-starter + + + org.apache.camel + camel-jackson + + + org.apache.camel + camel-stream + + + + + org.etsi.osl + org.etsi.osl.model.nfv + ${org.etsi.osl.model.nfv.version} + + + org.etsi.osl + org.etsi.osl.model.tmf + ${org.etsi.osl.model.tmf.version} + + + org.etsi.osl + org.etsi.osl.model.k8s + ${org.etsi.osl.model.k8s.version} + + + org.etsi.osl + org.etsi.osl.centrallog.client + ${org.etsi.osl.centrallog.client.version} + + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc.version} + + + org.springdoc + springdoc-openapi-ui + ${springdoc.openapiui.version} + + + org.springdoc + springdoc-openapi-security + ${springdoc.security.version} + + + + org.mapstruct + mapstruct + ${mapstruct.version} + + + org.mapstruct + mapstruct-processor + ${mapstruct.version} + + + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + com.vaadin.external.google + android-json + + + + + + org.springframework.security + spring-security-test + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.junit.platform + junit-platform-commons + test + + + org.junit.platform + junit-platform-runner + test + + + com.h2database + h2 + test + + + org.apache.activemq + activemq-broker + test + + + javax.jms + javax.jms-api + 2.0.1 + test + + + org.json + json + 20210307 + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + + -parameters + + + + org.mapstruct + mapstruct-processor + ${mapstruct.version} + + + org.projectlombok + lombok + ${lombok-version} + + + + + + org.codehaus.mojo + build-helper-maven-plugin + ${build-helper-maven-plugin.version} + + + add-generated-source + generate-sources + + add-source + + + + ${generated-sources-path}/wsdl + + + + + + + + org.codehaus.mojo + license-maven-plugin + ${maven-license-plugin.version} + + false + ========================LICENSE_START================================= + =========================LICENSE_END================================== + *.json + + + + generate-license-headers + + update-file-header + + process-sources + + ${license.licenseName} + + + + + download-licenses + + download-licenses + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot-version} + + + + repackage + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot-version} + + exec + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + + prepare-agent + + + + report + prepare-package + + report + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + + prepare-agent + + + + report + prepare-package + + report + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/etsi/osl/tmf/BootstrapRepository.java b/src/main/java/org/etsi/osl/tmf/BootstrapRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..31cc63fd735f194dbf570f77dc2ad9eb402ab9b1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/BootstrapRepository.java @@ -0,0 +1,183 @@ +/*- + * ========================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; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateUpdate; +import org.etsi.osl.tmf.scm633.model.ServiceCatalog; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryRef; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.reposervices.CandidateRepoService; +import org.etsi.osl.tmf.scm633.reposervices.CatalogRepoService; +import org.etsi.osl.tmf.scm633.reposervices.CategoryRepoService; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.annotation.PostConstruct; + +/** + * @author ctranoris + * + */ +@Service +public class BootstrapRepository { + + private static final transient Log logger = LogFactory.getLog(BootstrapRepository.class.getName()); + + private static final boolean ADDGST = true; + + private static final boolean ADDVINNISBT = false; + + private static final String GST_EXAMPLE_NAME = "A GST(NEST) Service Example"; + + private static final String VINNI_EXAMPLE_NAME = "A VINNI Service Example"; + + @Autowired + CatalogRepoService catalogRepoService; + + @Autowired + CategoryRepoService categRepoService; + + @Autowired + CandidateRepoService candidateRepoService; + + @Autowired + ServiceSpecificationRepoService specRepoService; + + @Autowired + ResourceSpecificationRepoService resourceSpecRepoService; + + + @Autowired + ObjectMapper objectMapper; + + @PostConstruct + @Transactional + public void initRepo() { + if (this.catalogRepoService.findAll().size() == 0) { + ServiceCatalogCreate sc = new ServiceCatalogCreate(); + sc.setName("Catalog"); + sc.setDescription("Primary Catalog"); + sc.setVersion("1.0"); + ServiceCatalog scatalog = this.catalogRepoService.addCatalog(sc); + + ServiceCategoryCreate scatCreate = new ServiceCategoryCreate(); + scatCreate.setName("Generic Services"); + scatCreate.setDescription("Generic Services of this catalog"); + scatCreate.setVersion("1.0"); + scatCreate.setIsRoot(true); + ServiceCategory scategory = this.categRepoService.addCategory(scatCreate); + + scatalog.getCategoryObj().add(scategory); + scatalog = this.catalogRepoService.updateCatalog(scatalog); + /** + * Add GST + */ + if (ADDGST) { + this.createFirstTimeGSTRepo( scategory ); + } + /** + * Add VINNI-SB + */ + if (ADDVINNISBT) { + this.createFirstTimeVINNISBTRepo( scategory ); + } + + + } else { //check if we have the latest version of GST + if (ADDGST) { + ServiceCategory scategory = this.categRepoService.findByName("Generic Services"); + ServiceSpecification serviceSpecificationObj = this.specRepoService.findByNameAndVersion( GST_EXAMPLE_NAME , "5.0.0"); + + if ( ( scategory != null ) && ( serviceSpecificationObj == null )) + { + this.createFirstTimeGSTRepo( scategory ); + } + } + if (ADDVINNISBT) { + ServiceCategory scategory = this.categRepoService.findByName("Generic Services"); + ServiceSpecification serviceSpecificationObj = this.specRepoService.findByNameAndVersion(VINNI_EXAMPLE_NAME, "0.1.0"); + if ( ( scategory != null ) && ( serviceSpecificationObj == null ) ) + { + this.createFirstTimeVINNISBTRepo( scategory ); + } + } + + + } + } + + + @Transactional + private void createFirstTimeGSTRepo(ServiceCategory scategory) { + + ServiceSpecification serviceSpecificationObj = this.specRepoService.cloneGSTServiceSpecification( GST_EXAMPLE_NAME); + //serviceSpecificationObj = this.specRepoService.updateServiceSpecification( serviceSpecificationObj ); + serviceSpecificationObj = this.specRepoService.findByUuid( serviceSpecificationObj.getId() ); + + ServiceCandidateUpdate scand = new ServiceCandidateUpdate(); + ServiceSpecificationRef serviceSpecificationRef = new ServiceSpecificationRef(); + serviceSpecificationRef.setId(serviceSpecificationObj.getId()); + ServiceCategoryRef categoryItem = new ServiceCategoryRef(); + categoryItem.setId(scategory.getId()); + scand.addCategoryItem(categoryItem); + scand.setServiceSpecification(serviceSpecificationRef); + + this.candidateRepoService.updateCandidate( + serviceSpecificationObj.getServiceCandidateObjId() , + scand); + + } + + + @Transactional + public void createFirstTimeVINNISBTRepo( ServiceCategory scategory ) { + + ServiceSpecification serviceSpecVinniSB = this.specRepoService.cloneVINNIServiceSpecification( VINNI_EXAMPLE_NAME, true, true, true, true, true, true, true, true, true, true); + + + /** + * add VINNI-SB Service Spec to Catalog + */ + + + ServiceCandidateUpdate scand = new ServiceCandidateUpdate(); + ServiceSpecificationRef serviceSpecificationRef = new ServiceSpecificationRef(); + serviceSpecificationRef.setId(serviceSpecVinniSB.getId()); + ServiceCategoryRef categoryItem = new ServiceCategoryRef(); + categoryItem.setId(scategory.getId()); + scand.addCategoryItem(categoryItem); + scand.setServiceSpecification(serviceSpecificationRef); + + this.candidateRepoService.updateCandidate( + serviceSpecVinniSB.getServiceCandidateObjId(), + scand); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/BootstrapResources.java b/src/main/java/org/etsi/osl/tmf/BootstrapResources.java new file mode 100644 index 0000000000000000000000000000000000000000..dacfb02b6c0f9c82d758949409ef662b163cadaf --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/BootstrapResources.java @@ -0,0 +1,288 @@ +/*- + * ========================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; + +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.KubernetesContextDefinition; +import org.etsi.osl.domain.model.kubernetes.KubernetesSecret; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalog; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCategory; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryRef; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.rcm634.repo.ResourceCatalogRepository; +import org.etsi.osl.tmf.rcm634.repo.ResourceSpecificationRepository; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCandidateRepoService; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCatalogRepoService; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCategoryRepoService; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.annotation.PostConstruct; + +@Service +public class BootstrapResources { + + @Autowired + ResourceCatalogRepoService resourceCatalogRepoService; + + @Autowired + ResourceCategoryRepoService resourceCategRepoService; + + @Autowired + ResourceCandidateRepoService resourceCandidateRepoService; + + @Autowired + ResourceSpecificationRepoService resourceSpecRepoService; + + @Autowired + ResourceRepoService resourceRepoService; + + @Autowired + ResourceCatalogRepository resourceCatalogRepository; + + @Autowired + ResourceSpecificationRepository resourceSpecificationRepo; + + @Autowired + ObjectMapper objectMapper; + + + private static final String OSM_TENANT = "osm-tenant.openslice.io"; + + private static final String VIM_ACCOUNT = "vim-account.openslice.io.json"; + + private static final String GNB_TENANT = "gnodeb.openslice.io"; + + + private static final String INFRA_RESOURCES = "Infrastructure Resources"; + + private static final String NETWORK_RESOURCES = "Network Resources"; + + + + @PostConstruct + @Transactional + public void initRepo() { + + ResourceCatalog scatalog = this.resourceCatalogRepoService.findByName( "Catalog" ); + if ( scatalog == null) { + + //Create a new ResourceCatalogCreate named Catalog + ResourceCatalogCreate sc = new ResourceCatalogCreate(); + sc.setName("Catalog"); + sc.setDescription("Primary Resource Catalog"); + sc.setVersion("1.0"); + //Turns ResourceCatalogCreate to a ResourceCatalog with the same attributes set at the ResourceCatalogCreate + scatalog = this.resourceCatalogRepoService.addCatalog(sc); + + // Create a new ResourceCategoryCreate named Generic Resources + ResourceCategoryCreate scatCreate = new ResourceCategoryCreate(); + scatCreate.setName("Generic Resources"); + scatCreate.setDescription("Generic Resources of this catalog"); + scatCreate.setVersion("1.0"); + scatCreate.setIsRoot(true); + + ResourceCategory scategory = this.resourceCategRepoService.addCategory(scatCreate); + //Adds the ResourceCategory to the Primary Resource Catalog and then saves it to the resourceCatalogRepository + //scatalog.getCategoryObj().add(scategory); +// ResourceCategoryRef catref = new ResourceCategoryRef(); +// catref.setId( scategory.getId() ); +// catref.setName( scategory.getName()); + scatalog.addCategory(scategory); + } + + ResourceCategory scategoryNetw = this.resourceCategRepoService.findByName(NETWORK_RESOURCES ); + if ( scategoryNetw == null ){ + ResourceCategoryCreate scategoryNetwCreate = new ResourceCategoryCreate(); + scategoryNetwCreate.setName(NETWORK_RESOURCES); + scategoryNetwCreate.setDescription("Network Resources on this catalog"); + scategoryNetwCreate.setVersion("1.0"); + scategoryNetwCreate.setIsRoot(true); + // Turns ResourceCategoryCreate to a ResourceCategory with the same attributes set at the ResourceCategoryCreate + scategoryNetw = this.resourceCategRepoService.addCategory( scategoryNetwCreate ); + //Adds the ResourceCategory to the Primary Resource Catalog and then saves it to the resourceCatalogRepository +// ResourceCategoryRef catref = new ResourceCategoryRef(); +// catref.setId( scategoryNetw.getId() ); +// catref.setName( scategoryNetw.getName()); + scatalog.addCategory( scategoryNetw ); + } + + ResourceCategory scategoryInfra = this.resourceCategRepoService.findByName(INFRA_RESOURCES ); + if ( scategoryInfra == null ){ + ResourceCategoryCreate scategoryInfraCreate = new ResourceCategoryCreate(); + scategoryInfraCreate.setName( INFRA_RESOURCES ); + scategoryInfraCreate.setDescription("Infrastructure Resources on this catalog"); + scategoryInfraCreate.setVersion("1.0"); + scategoryInfraCreate.setIsRoot(true); + scategoryInfra = this.resourceCategRepoService.addCategory( scategoryInfraCreate ); +// ResourceCategoryRef catref = new ResourceCategoryRef(); +// catref.setId( scategoryInfra.getId() ); +// catref.setName( scategoryInfra.getName()); + scatalog.addCategory( scategoryInfra ); + } + + scatalog = this.resourceCatalogRepoService.updateCatalog( scatalog ); + + + ResourceSpecification resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( VIM_ACCOUNT , "0.2.0"); + if ( ( resourceSpecificationObj == null )) + { + this.createBootResourceSpec( scategoryNetw, VIM_ACCOUNT , "vim-account.openslice.io.json" ); + } + + resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( OSM_TENANT , "0.2.0"); + if ( ( resourceSpecificationObj == null )) + { + this.createBootResourceSpec( scategoryNetw, OSM_TENANT , "osm-tenant.openslice.io.json" ); + } + resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( GNB_TENANT , "0.2.0"); + if ( ( resourceSpecificationObj == null )) + { + this.createBootPhysicalResourceSpec( scategoryNetw,GNB_TENANT, "gnodeb.openslice.io.json"); + } + + + + + resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( + KubernetesContextDefinition.OSL_KUBD_RSPEC_NAME , + KubernetesContextDefinition.OSL_KUBD_RSPEC_VERSION); + + if ( ( scategoryInfra != null ) && ( resourceSpecificationObj == null )) + { + ResourceSpecification resourceSpecificationKubernetes = + this.resourceSpecRepoService.addResourceSpecification( KubernetesContextDefinition.builder().build().toRSpecCreate_InitRepo() ); + //KubernetesContextDefinition.builder().build().fromRSpec(resourceSpecificationKubernetes);//to update any details + this.addToCategory( scategoryInfra, resourceSpecificationKubernetes ); + } + + resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( + KubernetesCRDV1.OSL_KUBCRD_RSPEC_NAME , + KubernetesCRDV1.OSL_KUBCRD_RSPEC_VERSION); + + if ( ( scategoryInfra != null ) && ( resourceSpecificationObj == null )) + { + ResourceSpecification resourceSpecificationKubernetesCRD = + this.resourceSpecRepoService.addResourceSpecification( KubernetesCRDV1.builder().build().toRSpecCreate_InitRepo() ); + KubernetesCRDV1.builder().build().fromRSpec(resourceSpecificationKubernetesCRD);//to update any details + this.addToCategory( scategoryInfra, resourceSpecificationKubernetesCRD ); + } + + + resourceSpecificationObj = this.resourceSpecRepoService.findByNameAndVersion( + KubernetesCRV1.OSL_KUBCRV1_RSPEC_NAME , + KubernetesCRV1.OSL_KUBCRV1_RSPEC_VERSION); + + if ( ( scategoryInfra != null ) && ( resourceSpecificationObj == null )) + { + ResourceSpecification rspecKubCRV1 = + this.resourceSpecRepoService.addResourceSpecification( KubernetesCRV1.builder().build().toRSpecCreate_InitRepo() ); + KubernetesCRV1.builder().build().fromRSpec(rspecKubCRV1);//to update any details + this.addToCategory( scategoryInfra, rspecKubCRV1 ); + } + + 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 ); + } + + + + } + + + private void createBootResourceSpec( ResourceCategory scategory, String aname, String afile) { + + ResourceSpecificationCreate rsc = this.resourceSpecRepoService.readFromLocalLogicalResourceSpec( afile ); + rsc.setName( aname ); + ResourceSpecification resourceSpecificationObj = this.resourceSpecRepoService.addResourceSpecification( rsc ); + + addToCategory(scategory, resourceSpecificationObj); + + } + + private void addToCategory(ResourceCategory scategory, ResourceSpecification resourceSpecificationObj) { + + //Turn the ResourceSpecification to a ResourceCanditate to save it to the ResourceCatalogRepo + ResourceCandidateUpdate scand = new ResourceCandidateUpdate(); + scand.setName( resourceSpecificationObj.getName()); + ResourceSpecificationRef resSpecificationRef = new ResourceSpecificationRef(); + resSpecificationRef.setId(resourceSpecificationObj.getId()); + resSpecificationRef.setName(resourceSpecificationObj.getName()); + scand.resourceSpecification(resSpecificationRef); + ResourceCategoryRef categoryItem = new ResourceCategoryRef(); + categoryItem.setId(scategory.getId()); + scand.addCategoryItem(categoryItem); + + this.resourceCandidateRepoService.updateCandidate(resourceSpecificationObj.getResourceCandidateObjId() , scand); + } + + private void createBootPhysicalResourceSpec( ResourceCategory scategory, String aname, String afile) { + //Find the MANO Provider Spec, get its href and use it to create a dependency with the VIM + + ResourceSpecification resourceSpecificationObj = this.resourceSpecRepoService.clonePhysicalResourceSpec( aname , afile); + resourceSpecificationObj = resourceSpecificationRepo.save(resourceSpecificationObj); + + //Turn the ResourceSpecification to a ResourceCanditate to save it to the ResourceCatalogRepo + ResourceCandidateUpdate scand = new ResourceCandidateUpdate(); + scand.setName( resourceSpecificationObj.getName()); + ResourceSpecificationRef resSpecificationRef = new ResourceSpecificationRef(); + resSpecificationRef.setId(resourceSpecificationObj.getId()); + resSpecificationRef.setName(resourceSpecificationObj.getName()); + scand.resourceSpecification(resSpecificationRef); + ResourceCategoryRef categoryItem = new ResourceCategoryRef(); + categoryItem.setId(scategory.getId()); + scand.addCategoryItem(categoryItem); + + this.resourceCandidateRepoService.updateCandidate(resourceSpecificationObj.getResourceCandidateObjId() , scand); + } + + + + public ResourceSpecification demoResourceSpecification() { + + ResourceSpecificationCreate spec = new ResourceSpecificationCreate(); + spec.setName("Example Logical Resource"); + spec.setVersion("1.0.0"); + + return this.resourceSpecRepoService.addLogicalResourceSpecification(spec); + } + + + +} + + diff --git a/src/main/java/org/etsi/osl/tmf/JsonUtils.java b/src/main/java/org/etsi/osl/tmf/JsonUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..b28edd691ad5bafaa90b8c41454b85aaf8a5a122 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/JsonUtils.java @@ -0,0 +1,55 @@ +package org.etsi.osl.tmf; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +/** + * @author ctranoris + * + */ +public class JsonUtils { + + public static byte[] toJson(Object object) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.registerModule(new JavaTimeModule()); + return mapper.writeValueAsBytes(object); + } + + public static String toJsonString(Object object) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.registerModule(new JavaTimeModule()); + return mapper.writeValueAsString(object); + } + + public static T toJsonObj(String content, Class valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.registerModule(new JavaTimeModule()); + return mapper.readValue(content, valueType); + } + + public static T toJsonObj(InputStream content, Class valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.registerModule(new JavaTimeModule()); + return mapper.readValue(content, valueType); + } + + public static List toListOfJsonObj(String content, Class valueType) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + List listOfJsonObj = mapper.readValue( + content, + mapper.getTypeFactory().constructCollectionType( + List.class, valueType)); + return listOfJsonObj; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/LocalMysqlDialect.java b/src/main/java/org/etsi/osl/tmf/LocalMysqlDialect.java new file mode 100644 index 0000000000000000000000000000000000000000..9220b97d37b9d9ba89da308bd334939c6e40e254 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/LocalMysqlDialect.java @@ -0,0 +1,29 @@ +/*- + * ========================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; + +import org.hibernate.dialect.MySQLDialect; ; + +public class LocalMysqlDialect extends MySQLDialect { + @Override + public String getTableTypeString() { + return " DEFAULT CHARSET=utf8"; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/MvcConfig.java b/src/main/java/org/etsi/osl/tmf/MvcConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..bb104c659dd4f754aa8fc7792aad7ec999b71051 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/MvcConfig.java @@ -0,0 +1,129 @@ +/*- + * ========================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; + +import java.io.File; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; +import org.springframework.http.converter.ByteArrayHttpMessageConverter; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.resource.EncodedResourceResolver; +import org.springframework.web.servlet.resource.PathResourceResolver; + +@Configuration +//@EnableWebMvc - removed 30/7/2021 +public class MvcConfig implements WebMvcConfigurer { + @Autowired + Environment env; + + public MvcConfig() { + super(); + } + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + registry.addViewController("/index.html"); + + } + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + // registry.addResourceHandler("/testweb/**").addResourceLocations("file:///C:/Users/ctranoris/git/org.etsi.osl.portal.web/src/").setCachePeriod(0); + String a = (new File("../org.etsi.osl.tmf.web/dist/io-openslice-portal-web/")).getAbsoluteFile().toURI().toString(); + System.out.println("======================> " + a); + registry.addResourceHandler("/services/**").addResourceLocations(a) // "file:///./../org.etsi.osl.portal.web/src/") + .setCachePeriod(0).resourceChain(true).addResolver(new EncodedResourceResolver()) + .addResolver(new PathResourceResolver()); + +// registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); +// +// registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); + + } + + @Override + public void extendMessageConverters(List> converters) { + // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd + // HH:mm:ss"); + DateTimeFormatter formatter = DateTimeFormatter.ISO_ZONED_DATE_TIME; + LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(formatter); + LocalDateTimeDeserializer localDateTimeDeserializer = new LocalDateTimeDeserializer(formatter); + + JavaTimeModule module = new JavaTimeModule(); + module.addSerializer(LocalDateTime.class, localDateTimeSerializer); + module.addDeserializer(LocalDateTime.class, localDateTimeDeserializer); + + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(module); + + SimpleModule simpleModule = new SimpleModule(); + simpleModule.addSerializer(OffsetDateTime.class, new JsonSerializer() { + @Override + public void serialize(OffsetDateTime offsetDateTime, JsonGenerator jsonGenerator, + SerializerProvider serializerProvider) throws IOException, JsonProcessingException { + jsonGenerator.writeString(DateTimeFormatter.ISO_ZONED_DATE_TIME.format(offsetDateTime)); + + } + }); + + + + + mapper.registerModule(simpleModule); + + // add converter at the very front + // if there are same type mappers in converters, setting in first mapper + // is used. + converters.add(new MappingJackson2HttpMessageConverter(mapper)); + + + + } + + @Override + public void configureMessageConverters(List> converters) { + converters.add(new StringHttpMessageConverter()); + converters.add(new ByteArrayHttpMessageConverter()); + } + + +} diff --git a/src/main/java/org/etsi/osl/tmf/OpenAPISpringBoot.java b/src/main/java/org/etsi/osl/tmf/OpenAPISpringBoot.java new file mode 100644 index 0000000000000000000000000000000000000000..f42df109cbb8db78fdbdbebd9131589bb6cd10d7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/OpenAPISpringBoot.java @@ -0,0 +1,87 @@ +/*- + * ========================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; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.ComponentScan; + + +/** + * For implementing the callback and events, it might be useful to check the DDD pattern: https://www.baeldung.com/spring-data-ddd + * + * + * @author ctranoris + * + */ +@SpringBootApplication +@ComponentScan( basePackages = { + "org.etsi.osl", + "org.etsi.osl.centrallog" + } ) +@EntityScan( basePackages = { + "org.etsi.osl", + "org.etsi.osl.sd", + "org.etsi.osl.sd.model", + "org.etsi.osl.tmf", + "org.etsi.osl.tmf.configuration", + "org.etsi.osl.tmf.scm633", + "org.etsi.osl.tmf.scm633.api", + "org.etsi.osl.tmf.scm633.repo", + "org.etsi.osl.tmf.scm633.reposervices", + "org.etsi.osl.tmf.scm634", + "org.etsi.osl.tmf.scm634.api", + "org.etsi.osl.centrallog.client"} ) + +public class OpenAPISpringBoot implements CommandLineRunner { + + private static ApplicationContext applicationContext; + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + + applicationContext = new SpringApplication(OpenAPISpringBoot.class).run(args); + +// for (String beanName : applicationContext.getBeanDefinitionNames()) { +// System.out.println(beanName); +// } + } + + class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/AckAlarmsApi.java b/src/main/java/org/etsi/osl/tmf/am642/api/AckAlarmsApi.java new file mode 100644 index 0000000000000000000000000000000000000000..75edd445b5523bf87d5e7d4ba1f3d5c574de5a4c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/AckAlarmsApi.java @@ -0,0 +1,165 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am642.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.AckAlarms; +import org.etsi.osl.tmf.am642.model.AckAlarmsCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Tag(name = "ackAlarms", description = "the ackAlarms API") +public interface AckAlarmsApi { + + Logger log = LoggerFactory.getLogger(AckAlarmsApi.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 AckAlarms", operationId = "createAckAlarms", description = "This operation creates a AckAlarms entity.", tags={ "ackAlarms", }) + @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 = "/ackAlarms", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createAckAlarms(@Parameter(description = "The AckAlarms to be created" ,required=true ) @Valid @RequestBody AckAlarmsCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"ackedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"ackTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"ackUserId\" : \"ackUserId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", AckAlarms.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 AckAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find AckAlarms objects", operationId = "listAckAlarms", description = "This operation list or find AckAlarms entities" , tags={ "ackAlarms", }) + @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 = "/ackAlarms", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listAckAlarms(@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, +Map allParams +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"ackedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"ackTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"ackUserId\" : \"ackUserId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}, {\r\n \"ackedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"ackTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"ackUserId\" : \"ackUserId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AckAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a AckAlarms by ID", operationId = "retrieveAckAlarms", description = "This operation retrieves a AckAlarms entity. Attribute selection is enabled for all first level attributes.", tags={ "ackAlarms", }) + @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 = "/ackAlarms/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveAckAlarms(@Parameter(description = "Identifier of the AckAlarms",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("{\r\n \"ackedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"ackTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"ackUserId\" : \"ackUserId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", AckAlarms.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 AckAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/AckAlarmsApiController.java b/src/main/java/org/etsi/osl/tmf/am642/api/AckAlarmsApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..a84959eb3dcb73c89d32fb997112ec07308eba84 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/AckAlarmsApiController.java @@ -0,0 +1,130 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.AckAlarms; +import org.etsi.osl.tmf.am642.model.AckAlarmsCreate; +import org.etsi.osl.tmf.am642.reposervices.AckAlarmsRepoService; +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.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Controller +@RequestMapping("/alarmManagement/v4/") +public class AckAlarmsApiController implements AckAlarmsApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + private static final Logger log = LoggerFactory.getLogger(AckAlarmsApiController.class); + + @org.springframework.beans.factory.annotation.Autowired + public AckAlarmsApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + + @Autowired + AckAlarmsRepoService ackAlarmRepoService; + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createAckAlarms(@Valid AckAlarmsCreate body) { + try { + + AckAlarms c = ackAlarmRepoService.addAckAlarm( body ); + + return new ResponseEntity(c, 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_ADMIN')" ) + public ResponseEntity> listAckAlarms(@Valid String fields, @Valid Integer offset, + @Valid Integer limit, Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>( + ackAlarmRepoService.findAll( myfields, allParams), HttpStatus.OK); + + + } else { + + + return new ResponseEntity>( + ackAlarmRepoService.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); + } + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity retrieveAckAlarms(String id, @Valid String fields) { + try { + + return new ResponseEntity( ackAlarmRepoService.findById( 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/am642/api/AlarmApi.java b/src/main/java/org/etsi/osl/tmf/am642/api/AlarmApi.java new file mode 100644 index 0000000000000000000000000000000000000000..0c518aef511bf67ffd5909c044343d5870fba094 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/AlarmApi.java @@ -0,0 +1,222 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am642.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.Alarm; +import org.etsi.osl.tmf.am642.model.AlarmCreate; +import org.etsi.osl.tmf.am642.model.AlarmUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Tag(name = "alarm", description = "the alarm API") +public interface AlarmApi { + + Logger log = LoggerFactory.getLogger(AlarmApi.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 Alarm", operationId = "createAlarm", description = "This operation creates a Alarm entity.", tags={ "alarm", }) + @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 = "/alarm", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createAlarm(@Parameter(description = "The Alarm to be created" ,required=true ) @Valid @RequestBody AlarmCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n}", Alarm.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 AlarmApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a Alarm", operationId = "deleteAlarm", description = "This operation deletes a Alarm entity.", tags={ "alarm", }) + @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 = "/alarm/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteAlarm(@Parameter(description = "Identifier of the Alarm",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AlarmApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find Alarm objects", operationId = "listAlarm", description = "This operation list or find Alarm entities" , tags={ "alarm", }) + @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 = "/alarm", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listAlarm(@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("[ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n}, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AlarmApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a Alarm", operationId = "patchAlarm", description = "This operation updates partially a Alarm entity.", tags={ "alarm", }) + @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 = "/alarm/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchAlarm(@Parameter(description = "The Alarm to be updated" ,required=true ) @Valid @RequestBody AlarmUpdate body +,@Parameter(description = "Identifier of the Alarm",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n}", Alarm.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 AlarmApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a Alarm by ID", operationId = "retrieveAlarm", description = "This operation retrieves a Alarm entity. Attribute selection is enabled for all first level attributes.", tags={ "alarm", }) + @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 = "/alarm/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveAlarm(@Parameter(description = "Identifier of the Alarm",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("{\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n}", Alarm.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 AlarmApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/AlarmApiController.java b/src/main/java/org/etsi/osl/tmf/am642/api/AlarmApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..f82067c35d138ff316894bd47add776e5e78bc86 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/AlarmApiController.java @@ -0,0 +1,152 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.Alarm; +import org.etsi.osl.tmf.am642.model.AlarmCreate; +import org.etsi.osl.tmf.am642.model.AlarmUpdate; +import org.etsi.osl.tmf.am642.reposervices.AlarmRepoService; +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.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Controller +@RequestMapping("/alarmManagement/v4/") + +public class AlarmApiController implements AlarmApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + + private static final Logger log = LoggerFactory.getLogger(AlarmApiController.class); + + @Autowired + AlarmRepoService alarmRepoService; + + @org.springframework.beans.factory.annotation.Autowired + public AlarmApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createAlarm(@Valid AlarmCreate body) { + try { + + Alarm c = alarmRepoService.addAlarm( body ); + + return new ResponseEntity(c, 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_ADMIN')" ) + public ResponseEntity deleteAlarm(String id) { + try { + + return new ResponseEntity( alarmRepoService.deleteById( 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_ADMIN')" ) + public ResponseEntity> listAlarm(@Valid String fields, @Valid Integer offset, @Valid Integer limit, + Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = null; + return new ResponseEntity>( + alarmRepoService.findAll( myfields, allParams), HttpStatus.OK); + + + } else { + + + return new ResponseEntity>( + alarmRepoService.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); + } + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity patchAlarm(@Valid AlarmUpdate body, String id) { + Alarm c = alarmRepoService.updateAlarm( id, body ); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity retrieveAlarm(String id, @Valid String fields) { + try { + + return new ResponseEntity( alarmRepoService.findById( 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/am642/api/AlarmApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/am642/api/AlarmApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..c9f7dd6e210115aacb2bbdb373f6a656c873615a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/AlarmApiRouteBuilder.java @@ -0,0 +1,111 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.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.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.am642.model.AlarmCreate; +import org.etsi.osl.tmf.am642.model.AlarmUpdate; +import org.etsi.osl.tmf.am642.reposervices.AlarmRepoService; +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 AlarmApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(AlarmApiRouteBuilder.class.getName()); + + + @Value("${ALARMS_ADD_ALARM}") + private String ALARMS_ADD_ALARM =""; + + @Value("${ALARMS_UPDATE_ALARM}") + private String ALARMS_UPDATE_ALARM =""; + + @Value("${ALARMS_GET_ALARM}") + private String ALARMS_GET_ALARM =""; + + + + @Value("${spring.application.name}") + private String compname; + + @Autowired + AlarmRepoService alarmRepoService; + + + @Autowired + private ProducerTemplate template; + + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + + from( ALARMS_ADD_ALARM ) + .log(LoggingLevel.INFO, log, ALARMS_ADD_ALARM + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal() + .json(JsonLibrary.Jackson, AlarmCreate.class, true) + .bean( alarmRepoService, "addAlarm(${body})") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + from( ALARMS_UPDATE_ALARM ) + .log(LoggingLevel.INFO, log, ALARMS_UPDATE_ALARM + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal() + .json(JsonLibrary.Jackson, AlarmUpdate.class, true) + .bean( alarmRepoService, "updateAlarm(${header.alarmid}, ${body})") + .bean( alarmRepoService, "findByUuidEager(${header.alarmid})") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + from( ALARMS_GET_ALARM ) + .log(LoggingLevel.INFO, log, ALARMS_GET_ALARM + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( alarmRepoService, "findByUuidEager(${header.alarmid})") + .marshal().json( JsonLibrary.Jackson, String.class) + .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/am642/api/AlarmApiRouteBuilderEvents.java b/src/main/java/org/etsi/osl/tmf/am642/api/AlarmApiRouteBuilderEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..b53aea657ea9c88a8c4e1e7d11a3d85703e24fe4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/AlarmApiRouteBuilderEvents.java @@ -0,0 +1,105 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.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.am642.model.AlarmCreateEvent; +import org.etsi.osl.tmf.common.model.OpensliceEvent; +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 AlarmApiRouteBuilderEvents extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(AlarmApiRouteBuilderEvents.class.getName()); + + + + @Value("${EVENT_ALARM_CREATE}") + private String EVENT_ALARM_CREATE =""; + + + @Value("${spring.application.name}") + private String compname; + + + @Autowired + private ProducerTemplate template; + + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + + + + } + + /** + * @param n + */ + public void publishEvent(final OpensliceEvent n, final String objId) { + n.setEventType( n.getClass().getName()); + logger.info("will send Event for type " + n.getEventType()); + try { + String msgtopic=""; + + if ( n instanceof AlarmCreateEvent) { + msgtopic = EVENT_ALARM_CREATE; + } + 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/am642/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/am642/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..c4c5c2d9f67b97aa8045d65c160d12703b59cbd7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/ApiException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02: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/am642/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/am642/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..5ac39b2ce0be32b66549b28ea625d6813b37df69 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/ApiOriginFilter.java @@ -0,0 +1,50 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.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 = "2021-02-15T11:15:47.327930400+02: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/am642/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/am642/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..abe236789ca31058576cc94ddc7dfa9c9a0b5270 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/ApiResponseMessage.java @@ -0,0 +1,88 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02: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/am642/api/ClearAlarmsApi.java b/src/main/java/org/etsi/osl/tmf/am642/api/ClearAlarmsApi.java new file mode 100644 index 0000000000000000000000000000000000000000..5d3a6148520cc719b02b0b98f4e79d4cab9bfb41 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/ClearAlarmsApi.java @@ -0,0 +1,169 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am642.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.ClearAlarms; +import org.etsi.osl.tmf.am642.model.ClearAlarmsCreate; +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.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 io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Tag(name = "clearAlarms", description = "the clearAlarms API") +public interface ClearAlarmsApi { + + Logger log = LoggerFactory.getLogger(ClearAlarmsApi.class); + + default Optional getObjectMapper(){ + return Optional.empty(); + } + + default Optional getRequest(){ + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + +// schema = @Schema(implementation = ClearAlarms.class) + + @Operation(summary = "Creates a ClearAlarms", operationId = "createClearAlarms", description = "This operation creates a ClearAlarms entity.", responses = { @ApiResponse( content= @Content( schema =@Schema(implementation = ClearAlarms.class) ) ) }, tags={ "clearAlarms", }) + @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 = "/clearAlarms", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createClearAlarms(@Parameter(description = "The ClearAlarms to be created" ,required=true ) @Valid @RequestBody ClearAlarmsCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"clearedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"clearSystemId\" : \"clearSystemId\"\r\n}", ClearAlarms.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 ClearAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ClearAlarms objects", operationId = "listClearAlarms", description = "This operation list or find ClearAlarms entities" , tags={ "clearAlarms", }) + @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 = "/clearAlarms", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listClearAlarms(@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 +, Map allParams +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"clearedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"clearSystemId\" : \"clearSystemId\"\r\n}, {\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"clearedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"clearSystemId\" : \"clearSystemId\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ClearAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ClearAlarms by ID", operationId = "retrieveClearAlarms", description = "This operation retrieves a ClearAlarms entity. Attribute selection is enabled for all first level attributes.", tags={ "clearAlarms", }) + @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 = "/clearAlarms/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveClearAlarms(@Parameter(description = "Identifier of the ClearAlarms",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("{\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"clearedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"clearSystemId\" : \"clearSystemId\"\r\n}", ClearAlarms.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 ClearAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/ClearAlarmsApiController.java b/src/main/java/org/etsi/osl/tmf/am642/api/ClearAlarmsApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..3bcd49465c858bd5c2cd476d78f3682bf5f3399e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/ClearAlarmsApiController.java @@ -0,0 +1,132 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.ClearAlarms; +import org.etsi.osl.tmf.am642.model.ClearAlarmsCreate; +import org.etsi.osl.tmf.am642.reposervices.ClearAlarmsRepoService; +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.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Controller +@RequestMapping("/alarmManagement/v4/") +public class ClearAlarmsApiController implements ClearAlarmsApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + private static final Logger log = LoggerFactory.getLogger(ClearAlarmsApiController.class); + + @Autowired + ClearAlarmsRepoService clearAlarmRepoService; + + + @org.springframework.beans.factory.annotation.Autowired + public ClearAlarmsApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createClearAlarms(@Valid ClearAlarmsCreate body) { + try { + + ClearAlarms c = clearAlarmRepoService.addClearAlarm( body ); + + return new ResponseEntity(c, 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_ADMIN')" ) + public ResponseEntity> listClearAlarms(@Valid String fields, @Valid Integer offset, + @Valid Integer limit, Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>( + clearAlarmRepoService.findAll( myfields, allParams), HttpStatus.OK); + + + } else { + + + return new ResponseEntity>( + clearAlarmRepoService.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); + } + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity retrieveClearAlarms(String id, @Valid String fields) { + try { + + return new ResponseEntity( clearAlarmRepoService.findById( 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/am642/api/CommentAlarmsApi.java b/src/main/java/org/etsi/osl/tmf/am642/api/CommentAlarmsApi.java new file mode 100644 index 0000000000000000000000000000000000000000..529bf3d2088ae6618805dba2a699e694efd18918 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/CommentAlarmsApi.java @@ -0,0 +1,164 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am642.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.CommentAlarms; +import org.etsi.osl.tmf.am642.model.CommentAlarmsCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Tag(name = "commentAlarms", description = "the commentAlarms API") +public interface CommentAlarmsApi { + + Logger log = LoggerFactory.getLogger(CommentAlarmsApi.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 CommentAlarms", operationId = "createCommentAlarms", description = "This operation creates a CommentAlarms entity.", tags={ "commentAlarms", }) + @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 = "/commentAlarms", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createCommentAlarms(@Parameter(description = "The CommentAlarms to be created" ,required=true ) @Valid @RequestBody CommentAlarmsCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"commentedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"comment\" : {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", CommentAlarms.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 CommentAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find CommentAlarms objects", operationId = "listCommentAlarms", description = "This operation list or find CommentAlarms entities" , tags={ "commentAlarms", }) + @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 = "/commentAlarms", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listCommentAlarms(@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 +, Map allParams) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"commentedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"comment\" : {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}, {\r\n \"commentedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"comment\" : {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default CommentAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a CommentAlarms by ID", operationId = "retrieveCommentAlarms", description = "This operation retrieves a CommentAlarms entity. Attribute selection is enabled for all first level attributes.", tags={ "commentAlarms", }) + @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 = "/commentAlarms/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveCommentAlarms(@Parameter(description = "Identifier of the CommentAlarms",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("{\r\n \"commentedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"comment\" : {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", CommentAlarms.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 CommentAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/CommentAlarmsApiController.java b/src/main/java/org/etsi/osl/tmf/am642/api/CommentAlarmsApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..b5fe3279acfc99b8fbfad845b735399673377941 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/CommentAlarmsApiController.java @@ -0,0 +1,129 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.CommentAlarms; +import org.etsi.osl.tmf.am642.model.CommentAlarmsCreate; +import org.etsi.osl.tmf.am642.reposervices.CommentAlarmsRepoService; +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.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Controller +@RequestMapping("/alarmManagement/v4/") +public class CommentAlarmsApiController implements CommentAlarmsApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Autowired + CommentAlarmsRepoService commentAlarmRepoService; + + private static final Logger log = LoggerFactory.getLogger(CommentAlarmsApiController.class); + + @org.springframework.beans.factory.annotation.Autowired + public CommentAlarmsApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createCommentAlarms(@Valid CommentAlarmsCreate body) { + try { + + CommentAlarms c = commentAlarmRepoService.addCommentAlarms(body); + + return new ResponseEntity(c, 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_ADMIN')" ) + public ResponseEntity retrieveCommentAlarms(String id, @Valid String fields) { + try { + + return new ResponseEntity(commentAlarmRepoService.findById(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_ADMIN')" ) + public ResponseEntity> listCommentAlarms(@Valid String fields, @Valid Integer offset, + @Valid Integer limit, Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>(commentAlarmRepoService.findAll(myfields, allParams), + HttpStatus.OK); + + } else { + + return new ResponseEntity>(commentAlarmRepoService.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); + } + } +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/GroupAlarmsApi.java b/src/main/java/org/etsi/osl/tmf/am642/api/GroupAlarmsApi.java new file mode 100644 index 0000000000000000000000000000000000000000..d595a826db0f212973a6353e669ab5477c69ec28 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/GroupAlarmsApi.java @@ -0,0 +1,169 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am642.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.GroupAlarms; +import org.etsi.osl.tmf.am642.model.GroupAlarmsCreate; +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; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Tag(name = "groupAlarms", description = "the groupAlarms API") +public interface GroupAlarmsApi { + + Logger log = LoggerFactory.getLogger(GroupAlarmsApi.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 GroupAlarms", operationId = "createGroupAlarms", description = "This operation creates a GroupAlarms entity." , tags = { + "groupAlarms", }) + @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 = "/groupAlarms", produces = { "application/json;charset=utf-8" }, consumes = { + "application/json;charset=utf-8" }, method = RequestMethod.POST) + default ResponseEntity createGroupAlarms( + @Parameter(description = "The GroupAlarms to be created", required = true) @Valid @RequestBody GroupAlarmsCreate body) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "{\r\n \"@baseType\" : \"@baseType\",\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"@type\" : \"@type\",\r\n \"groupedAlarm\" : [ null, null ],\r\n \"correlatedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", + GroupAlarms.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 GroupAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "List or find GroupAlarms objects", operationId = "listGroupAlarms", description = "This operation list or find GroupAlarms entities" , tags = { + "groupAlarms", }) + @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 = "/groupAlarms", produces = { "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity> listGroupAlarms( + @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, + Map allParams) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "[ {\r\n \"@baseType\" : \"@baseType\",\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"@type\" : \"@type\",\r\n \"groupedAlarm\" : [ null, null ],\r\n \"correlatedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}, {\r\n \"@baseType\" : \"@baseType\",\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"@type\" : \"@type\",\r\n \"groupedAlarm\" : [ null, null ],\r\n \"correlatedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\"\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); + } + } + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default GroupAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Retrieves a GroupAlarms by ID", operationId = "retrieveGroupAlarms", description = "This operation retrieves a GroupAlarms entity. Attribute selection is enabled for all first level attributes." , tags = { + "groupAlarms", }) + @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 = "/groupAlarms/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity retrieveGroupAlarms( + @Parameter(description = "Identifier of the GroupAlarms", 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( + "{\r\n \"@baseType\" : \"@baseType\",\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"@type\" : \"@type\",\r\n \"groupedAlarm\" : [ null, null ],\r\n \"correlatedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", + GroupAlarms.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 GroupAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/GroupAlarmsApiController.java b/src/main/java/org/etsi/osl/tmf/am642/api/GroupAlarmsApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..39c68d79f0cdf51a48e01b86e3d2bc36c4400e69 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/GroupAlarmsApiController.java @@ -0,0 +1,124 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.GroupAlarms; +import org.etsi.osl.tmf.am642.model.GroupAlarmsCreate; +import org.etsi.osl.tmf.am642.reposervices.GroupAlarmsRepoService; +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.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Controller +@RequestMapping("/alarmManagement/v4/") +public class GroupAlarmsApiController implements GroupAlarmsApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Autowired + GroupAlarmsRepoService groupAlarmRepoService; + + @org.springframework.beans.factory.annotation.Autowired + public GroupAlarmsApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createGroupAlarms(@Valid GroupAlarmsCreate body) { + try { + + GroupAlarms c = groupAlarmRepoService.addGroupAlarms(body); + + return new ResponseEntity(c, 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_ADMIN')" ) + public ResponseEntity retrieveGroupAlarms(String id, @Valid String fields) { + try { + + return new ResponseEntity(groupAlarmRepoService.findById(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_ADMIN')" ) + public ResponseEntity> listGroupAlarms(@Valid String fields, @Valid Integer offset, + @Valid Integer limit, Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>(groupAlarmRepoService.findAll(myfields, allParams), + HttpStatus.OK); + + } else { + + return new ResponseEntity>(groupAlarmRepoService.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); + } + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/am642/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..7463e6bcf9b467570d78367f6a022fd22a56a3f0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am642.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.EventSubscription; +import org.etsi.osl.tmf.am642.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener642", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener642", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/am642/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..b3c83b84f36e48e4dbe8d0652564177de6f3b2af --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") + +@Controller("HubApiController642") +@RequestMapping("/alarmManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/am642/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..e00e2533dc8a2f95d38ba8343e9f4bb7e227a49e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/ListenerApi.java @@ -0,0 +1,591 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am642.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.AckAlarmsCreateEvent; +import org.etsi.osl.tmf.am642.model.AckAlarmsStateChangeEvent; +import org.etsi.osl.tmf.am642.model.AlarmAttributeValueChangeEvent; +import org.etsi.osl.tmf.am642.model.AlarmCreateEvent; +import org.etsi.osl.tmf.am642.model.AlarmDeleteEvent; +import org.etsi.osl.tmf.am642.model.AlarmStateChangeEvent; +import org.etsi.osl.tmf.am642.model.ClearAlarmsCreateEvent; +import org.etsi.osl.tmf.am642.model.ClearAlarmsStateChangeEvent; +import org.etsi.osl.tmf.am642.model.CommentAlarmsCreateEvent; +import org.etsi.osl.tmf.am642.model.CommentAlarmsStateChangeEvent; +import org.etsi.osl.tmf.am642.model.EventSubscription; +import org.etsi.osl.tmf.am642.model.GroupAlarmsCreateEvent; +import org.etsi.osl.tmf.am642.model.GroupAlarmsStateChangeEvent; +import org.etsi.osl.tmf.am642.model.UnAckAlarmsCreateEvent; +import org.etsi.osl.tmf.am642.model.UnAckAlarmsStateChangeEvent; +import org.etsi.osl.tmf.am642.model.UnGroupAlarmsCreateEvent; +import org.etsi.osl.tmf.am642.model.UnGroupAlarmsStateChangeEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity AckAlarmsCreateEvent", operationId = "listenToAckAlarmsCreateEvent", description = "Example of a client listener for receiving the notification AckAlarmsCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/ackAlarmsCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToAckAlarmsCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody AckAlarmsCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity AckAlarmsStateChangeEvent", operationId = "listenToAckAlarmsStateChangeEvent", description = "Example of a client listener for receiving the notification AckAlarmsStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/ackAlarmsStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToAckAlarmsStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody AckAlarmsStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity AlarmAttributeValueChangeEvent", operationId = "listenToAlarmAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification AlarmAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/alarmAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToAlarmAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody AlarmAttributeValueChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity AlarmCreateEvent", operationId = "listenToAlarmCreateEvent", description = "Example of a client listener for receiving the notification AlarmCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/alarmCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToAlarmCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody AlarmCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity AlarmDeleteEvent", operationId = "listenToAlarmDeleteEvent", description = "Example of a client listener for receiving the notification AlarmDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/alarmDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToAlarmDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody AlarmDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity AlarmStateChangeEvent", operationId = "listenToAlarmStateChangeEvent", description = "Example of a client listener for receiving the notification AlarmStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/alarmStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToAlarmStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody AlarmStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ClearAlarmsCreateEvent", operationId = "listenToClearAlarmsCreateEvent", description = "Example of a client listener for receiving the notification ClearAlarmsCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/clearAlarmsCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToClearAlarmsCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ClearAlarmsCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ClearAlarmsStateChangeEvent", operationId = "listenToClearAlarmsStateChangeEvent", description = "Example of a client listener for receiving the notification ClearAlarmsStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/clearAlarmsStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToClearAlarmsStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ClearAlarmsStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CommentAlarmsCreateEvent", operationId = "listenToCommentAlarmsCreateEvent", description = "Example of a client listener for receiving the notification CommentAlarmsCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/commentAlarmsCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCommentAlarmsCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CommentAlarmsCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CommentAlarmsStateChangeEvent", operationId = "listenToCommentAlarmsStateChangeEvent", description = "Example of a client listener for receiving the notification CommentAlarmsStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/commentAlarmsStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCommentAlarmsStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CommentAlarmsStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity GroupAlarmsCreateEvent", operationId = "listenToGroupAlarmsCreateEvent", description = "Example of a client listener for receiving the notification GroupAlarmsCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/groupAlarmsCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToGroupAlarmsCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody GroupAlarmsCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity GroupAlarmsStateChangeEvent", operationId = "listenToGroupAlarmsStateChangeEvent", description = "Example of a client listener for receiving the notification GroupAlarmsStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/groupAlarmsStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToGroupAlarmsStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody GroupAlarmsStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity UnAckAlarmsCreateEvent", operationId = "listenToUnAckAlarmsCreateEvent", description = "Example of a client listener for receiving the notification UnAckAlarmsCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/unAckAlarmsCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToUnAckAlarmsCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody UnAckAlarmsCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity UnAckAlarmsStateChangeEvent", operationId = "listenToUnAckAlarmsStateChangeEvent", description = "Example of a client listener for receiving the notification UnAckAlarmsStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/unAckAlarmsStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToUnAckAlarmsStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody UnAckAlarmsStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity UnGroupAlarmsCreateEvent", operationId = "listenToUnGroupAlarmsCreateEvent", description = "Example of a client listener for receiving the notification UnGroupAlarmsCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/unGroupAlarmsCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToUnGroupAlarmsCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody UnGroupAlarmsCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity UnGroupAlarmsStateChangeEvent", operationId = "listenToUnGroupAlarmsStateChangeEvent", description = "Example of a client listener for receiving the notification UnGroupAlarmsStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/unGroupAlarmsStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToUnGroupAlarmsStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody UnGroupAlarmsStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/am642/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..c6e443a665fa077927d91286bd8a5ad6ece11ae1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") + +@Controller("ListenerApiController642") +@RequestMapping("/alarmManagement/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/am642/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..47d4edaff8d8bd5943f18722203bc315edc15727 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/NotFoundException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02: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/am642/api/UnAckAlarmsApi.java b/src/main/java/org/etsi/osl/tmf/am642/api/UnAckAlarmsApi.java new file mode 100644 index 0000000000000000000000000000000000000000..4fefc8271f1221aaba50c121dce128268ce74306 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/UnAckAlarmsApi.java @@ -0,0 +1,164 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am642.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.UnAckAlarms; +import org.etsi.osl.tmf.am642.model.UnAckAlarmsCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Tag(name = "unAckAlarms", description = "the unAckAlarms API") +public interface UnAckAlarmsApi { + + Logger log = LoggerFactory.getLogger(UnAckAlarmsApi.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 UnAckAlarms", operationId = "createUnAckAlarms", description = "This operation creates a UnAckAlarms entity.", tags={ "unAckAlarms", }) + @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 = "/unAckAlarms", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createUnAckAlarms(@Parameter(description = "The UnAckAlarms to be created" ,required=true ) @Valid @RequestBody UnAckAlarmsCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"ackTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"ackUserId\" : \"ackUserId\",\r\n \"unAckedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", UnAckAlarms.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 UnAckAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find UnAckAlarms objects", operationId = "listUnAckAlarms", description = "This operation list or find UnAckAlarms entities" , tags={ "unAckAlarms", }) + @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 = "/unAckAlarms", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listUnAckAlarms(@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 +, Map allParams) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"ackTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"ackUserId\" : \"ackUserId\",\r\n \"unAckedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}, {\r\n \"ackTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"ackUserId\" : \"ackUserId\",\r\n \"unAckedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UnAckAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a UnAckAlarms by ID", operationId = "retrieveUnAckAlarms", description = "This operation retrieves a UnAckAlarms entity. Attribute selection is enabled for all first level attributes.", tags={ "unAckAlarms", }) + @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 = "/unAckAlarms/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveUnAckAlarms(@Parameter(description = "Identifier of the UnAckAlarms",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("{\r\n \"ackTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"ackUserId\" : \"ackUserId\",\r\n \"unAckedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"alarmPattern\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", UnAckAlarms.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 UnAckAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/UnAckAlarmsApiController.java b/src/main/java/org/etsi/osl/tmf/am642/api/UnAckAlarmsApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..6ca16ef51f9bfdd3f20a6a806aaef6801b72ecd6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/UnAckAlarmsApiController.java @@ -0,0 +1,137 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.UnAckAlarms; +import org.etsi.osl.tmf.am642.model.UnAckAlarmsCreate; +import org.etsi.osl.tmf.am642.reposervices.UnAckAlarmsRepoService; +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.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Controller +@RequestMapping("/alarmManagement/v4/") +public class UnAckAlarmsApiController implements UnAckAlarmsApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + private static final Logger log = LoggerFactory.getLogger(UnAckAlarmsApiController.class); + + + + @Autowired + UnAckAlarmsRepoService unackAlarmRepoService; + + + @org.springframework.beans.factory.annotation.Autowired + public UnAckAlarmsApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createUnAckAlarms(@Valid UnAckAlarmsCreate body) { + try { + + UnAckAlarms c = unackAlarmRepoService.addAckAlarm( body ); + + return new ResponseEntity(c, 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_ADMIN')" ) + public ResponseEntity> listUnAckAlarms(@Valid String fields, @Valid Integer offset, + @Valid Integer limit, Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>( + unackAlarmRepoService.findAll( myfields, allParams), HttpStatus.OK); + + + } else { + + + return new ResponseEntity>( + unackAlarmRepoService.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); + } + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity retrieveUnAckAlarms(String id, @Valid String fields) { + try { + + return new ResponseEntity( unackAlarmRepoService.findById( 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/am642/api/UnGroupAlarmsApi.java b/src/main/java/org/etsi/osl/tmf/am642/api/UnGroupAlarmsApi.java new file mode 100644 index 0000000000000000000000000000000000000000..d9d855f6fba507c88f1c5ee8851bee7ba83ec4ca --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/UnGroupAlarmsApi.java @@ -0,0 +1,164 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am642.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.UnGroupAlarms; +import org.etsi.osl.tmf.am642.model.UnGroupAlarmsCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Tag(name = "unGroupAlarms", description = "the unGroupAlarms API") +public interface UnGroupAlarmsApi { + + Logger log = LoggerFactory.getLogger(UnGroupAlarmsApi.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 UnGroupAlarms", operationId = "createUnGroupAlarms", description = "This operation creates a UnGroupAlarms entity.", tags={ "unGroupAlarms", }) + @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 = "/unGroupAlarms", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createUnGroupAlarms(@Parameter(description = "The UnGroupAlarms to be created" ,required=true ) @Valid @RequestBody UnGroupAlarmsCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"@baseType\" : \"@baseType\",\r\n \"unGroupedAlarm\" : [ null, null ],\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"@type\" : \"@type\",\r\n \"correlatedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", UnGroupAlarms.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 UnGroupAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find UnGroupAlarms objects", operationId = "listUnGroupAlarms", description = "This operation list or find UnGroupAlarms entities" , tags={ "unGroupAlarms", }) + @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 = "/unGroupAlarms", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listUnGroupAlarms(@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 +, Map allParams) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"@baseType\" : \"@baseType\",\r\n \"unGroupedAlarm\" : [ null, null ],\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"@type\" : \"@type\",\r\n \"correlatedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}, {\r\n \"@baseType\" : \"@baseType\",\r\n \"unGroupedAlarm\" : [ null, null ],\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"@type\" : \"@type\",\r\n \"correlatedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UnGroupAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a UnGroupAlarms by ID", operationId = "retrieveUnGroupAlarms", description = "This operation retrieves a UnGroupAlarms entity. Attribute selection is enabled for all first level attributes.", tags={ "unGroupAlarms", }) + @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 = "/unGroupAlarms/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveUnGroupAlarms(@Parameter(description = "Identifier of the UnGroupAlarms",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("{\r\n \"@baseType\" : \"@baseType\",\r\n \"unGroupedAlarm\" : [ null, null ],\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"@type\" : \"@type\",\r\n \"correlatedAlarm\" : [ {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n }, {\r\n \"reportingSystemId\" : \"reportingSystemId\",\r\n \"alarmRaisedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@referredType\" : \"@referredType\",\r\n \"alarmClearedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObjectType\" : \"alarmedObjectType\",\r\n \"@type\" : \"@type\",\r\n \"proposedRepairedActions\" : \"proposedRepairedActions\",\r\n \"correlatedAlarm\" : [ {\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 \"alarmReportingTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"alarmedObject\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"alarmEscalation\" : true,\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"perceivedSeverity\" : \"perceivedSeverity\",\r\n \"probableCause\" : \"probableCause\",\r\n \"affectedService\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"ackSystemId\" : \"ackSystemId\",\r\n \"id\" : 0,\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\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 \"crossedThresholdInformation\" : {\r\n \"indicatorName\" : \"indicatorName\",\r\n \"@baseType\" : \"@baseType\",\r\n \"thresholdCrossingDescription\" : \"thresholdCrossingDescription\",\r\n \"granularity\" : \"granularity\",\r\n \"@type\" : \"@type\",\r\n \"observedValue\" : \"observedValue\",\r\n \"threshold\" : {\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 \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"direction\" : \"direction\",\r\n \"indicatorUnit\" : \"indicatorUnit\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"externalAlarmId\" : \"externalAlarmId\",\r\n \"clearSystemId\" : \"clearSystemId\",\r\n \"parentAlarm\" : [ null, null ],\r\n \"isRootCause\" : true,\r\n \"ackUserId\" : \"ackUserId\",\r\n \"clearUserId\" : \"clearUserId\",\r\n \"serviceAffecting\" : true,\r\n \"sourceSystemId\" : \"sourceSystemId\",\r\n \"ackState\" : \"ackState\",\r\n \"alarmType\" : \"alarmType\",\r\n \"specificProblem\" : \"specificProblem\",\r\n \"name\" : \"name\",\r\n \"plannedOutageIndicator\" : \"plannedOutageIndicator\",\r\n \"comment\" : [ {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n }, {\r\n \"systemId\" : \"systemId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"comment\" : \"comment\",\r\n \"time\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"userId\" : \"userId\"\r\n } ],\r\n \"alarmDetails\" : \"alarmDetails\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"alarmChangedTime\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", UnGroupAlarms.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 UnGroupAlarmsApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/api/UnGroupAlarmsApiController.java b/src/main/java/org/etsi/osl/tmf/am642/api/UnGroupAlarmsApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..edbc36b6ddfee89ee580224a61251b9d8666652c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/api/UnGroupAlarmsApiController.java @@ -0,0 +1,132 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am642.model.UnGroupAlarms; +import org.etsi.osl.tmf.am642.model.UnGroupAlarmsCreate; +import org.etsi.osl.tmf.am642.reposervices.UnGroupAlarmsRepoService; +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.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-15T11:15:47.327930400+02:00[Europe/Athens]") +@Controller +@RequestMapping("/alarmManagement/v4/") +public class UnGroupAlarmsApiController implements UnGroupAlarmsApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + private static final Logger log = LoggerFactory.getLogger(UnGroupAlarmsApiController.class); + + + @Autowired + UnGroupAlarmsRepoService UnGroupAlarmRepoService; + + + @org.springframework.beans.factory.annotation.Autowired + public UnGroupAlarmsApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createUnGroupAlarms(@Valid UnGroupAlarmsCreate body) { + try { + + UnGroupAlarms c = UnGroupAlarmRepoService.addUnGroupAlarms(body); + + return new ResponseEntity(c, 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_ADMIN')" ) + public ResponseEntity retrieveUnGroupAlarms(String id, @Valid String fields) { + try { + + return new ResponseEntity(UnGroupAlarmRepoService.findById(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_ADMIN')" ) + public ResponseEntity> listUnGroupAlarms(@Valid String fields, @Valid Integer offset, + @Valid Integer limit, Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>(UnGroupAlarmRepoService.findAll(myfields, allParams), + HttpStatus.OK); + + } else { + + return new ResponseEntity>(UnGroupAlarmRepoService.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); + } + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/repo/AckAlarmsRepository.java b/src/main/java/org/etsi/osl/tmf/am642/repo/AckAlarmsRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..d74a6737f0f9a7c5c9bff16be70f78b79954145a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/repo/AckAlarmsRepository.java @@ -0,0 +1,35 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.AckAlarms; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface AckAlarmsRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/repo/AlarmRepository.java b/src/main/java/org/etsi/osl/tmf/am642/repo/AlarmRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..fa5ecd44241806dfecb7e1956072d3d980d80c74 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/repo/AlarmRepository.java @@ -0,0 +1,35 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.Alarm; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface AlarmRepository extends CrudRepository,PagingAndSortingRepository { + + + Optional findByUuid(String id); + + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/repo/ClearAlarmsRepository.java b/src/main/java/org/etsi/osl/tmf/am642/repo/ClearAlarmsRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..2d2c9579b55e98acedb542cb87783b39fa126f8d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/repo/ClearAlarmsRepository.java @@ -0,0 +1,35 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.ClearAlarms; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ClearAlarmsRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/repo/CommentAlarmsRepository.java b/src/main/java/org/etsi/osl/tmf/am642/repo/CommentAlarmsRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..91e484e5ee2b6d4e32a7c157c750d2286003a2ee --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/repo/CommentAlarmsRepository.java @@ -0,0 +1,35 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.CommentAlarms; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CommentAlarmsRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/repo/GroupAlarmsRepository.java b/src/main/java/org/etsi/osl/tmf/am642/repo/GroupAlarmsRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..40bef51ecd1435caee21bb6d6133c15982fe6f63 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/repo/GroupAlarmsRepository.java @@ -0,0 +1,35 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.GroupAlarms; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface GroupAlarmsRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/repo/UnAckAlarmsRepository.java b/src/main/java/org/etsi/osl/tmf/am642/repo/UnAckAlarmsRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..b24881c7f136ddf25cf128a1393f9295b8140b40 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/repo/UnAckAlarmsRepository.java @@ -0,0 +1,35 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.UnAckAlarms; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface UnAckAlarmsRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/repo/UnGroupAlarmsRepository.java b/src/main/java/org/etsi/osl/tmf/am642/repo/UnGroupAlarmsRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..5aa830492fe71f3de27537f2f5a81ba0c25f52db --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/repo/UnGroupAlarmsRepository.java @@ -0,0 +1,35 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.UnGroupAlarms; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface UnGroupAlarmsRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/reposervices/AckAlarmsRepoService.java b/src/main/java/org/etsi/osl/tmf/am642/reposervices/AckAlarmsRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..8bdc851c0523c5851bfe9d0b3e0381c8c0ab47a6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/reposervices/AckAlarmsRepoService.java @@ -0,0 +1,167 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.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.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.AckAlarms; +import org.etsi.osl.tmf.am642.model.AckAlarmsCreate; +import org.etsi.osl.tmf.am642.repo.AckAlarmsRepository; +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.stereotype.Service; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class AckAlarmsRepoService { + + @Autowired + AckAlarmsRepository alRepo; + + private SessionFactory sessionFactory; + + @Autowired + public AckAlarmsRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public AckAlarms addAckAlarm(@Valid AckAlarmsCreate ac) { + AckAlarms al = new AckAlarms(); + + al = updateFromAPICall( al , ac); + return this.alRepo.save( al ); + } + + + + public List findAll(String fields, Map allParams) throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { + String sql = "SELECT " + + "s.uuid as uuid," + + "s.id as id," + + "s.ackTime as ackTime," + + "s.ackUserId as ackUserId," + + "s.state as state"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM AMAckAlarms s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.ackTime DESC"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + } + + public AckAlarms findById(String id) { + Optional optionalCat = this.alRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + private AckAlarms updateFromAPICall(AckAlarms al, @Valid AckAlarmsCreate aSrc) { + + al.setAckSystemId( aSrc.getAckSystemId()); + al.ackTime( OffsetDateTime.now(ZoneOffset.UTC) ); + al.setAckUserId( aSrc.getAckUserId() ); + al.setState( aSrc.getState()); + al.getAckedAlarm().addAll( aSrc.getAckedAlarm() ) ; + al.getAlarmPattern().addAll(aSrc.getAlarmPattern() ); + + return al; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/reposervices/AlarmRepoService.java b/src/main/java/org/etsi/osl/tmf/am642/reposervices/AlarmRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..1ffba458d43ca536af8ebe8aee3efbab5395f340 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/reposervices/AlarmRepoService.java @@ -0,0 +1,528 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.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.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.am642.api.AlarmApiRouteBuilderEvents; +import org.etsi.osl.tmf.am642.model.AffectedService; +import org.etsi.osl.tmf.am642.model.Alarm; +import org.etsi.osl.tmf.am642.model.AlarmCreate; +import org.etsi.osl.tmf.am642.model.AlarmCreateEvent; +import org.etsi.osl.tmf.am642.model.AlarmCreateEventPayload; +import org.etsi.osl.tmf.am642.model.AlarmRef; +import org.etsi.osl.tmf.am642.model.AlarmStateType; +import org.etsi.osl.tmf.am642.model.AlarmUpdate; +import org.etsi.osl.tmf.am642.model.Comment; +import org.etsi.osl.tmf.am642.model.RelatedPlaceRefOrValue; +import org.etsi.osl.tmf.am642.repo.AlarmRepository; +import org.etsi.osl.tmf.common.model.service.ServiceStateType; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.transform.ResultTransformer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class AlarmRepoService { + + @Autowired + AlarmRepository alarmRepo; + + @Autowired + ServiceRepoService serviceRepoService; + + @Autowired + AlarmApiRouteBuilderEvents alarmApiRouteBuilder; + + private SessionFactory sessionFactory; + + @Autowired + public AlarmRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + @Transactional + public Alarm addAlarm(@Valid AlarmCreate alarmUpdate) { + Alarm al = new Alarm(); + al.setAlarmReportingTime(OffsetDateTime.now(ZoneOffset.UTC)); + al.setAlarmChangedTime(OffsetDateTime.now(ZoneOffset.UTC)); + al.setSourceSystemId(alarmUpdate.getSourceSystemId()); + al.setAlarmRaisedTime( alarmUpdate.getAlarmRaisedTime() ); + + al = updateAlarmFromAPICall(al, alarmUpdate); + + al = updateAffectedServiceIF_NFVO(al); + + al = this.alarmRepo.save(al); + raiseAlarmCreateEvent(al); + return al; + } + + public List findAll() { + return (List) this.alarmRepo.findAll(); + } + + public Alarm findById(String id) { + Optional optionalCat = this.alarmRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + /** + * + * This one is needed if we have a specific alarm from NFVO (OSM in our case) + * In future we might have more complex things + * This function could be in OAS to find and identify the related Service from the inventory + * that is related with this NS instance + * + * @param al + * @return + */ + private Alarm updateAffectedServiceIF_NFVO(Alarm al) { + // specificProblem(DeploymentRequestID=OSM NS_ID) + + if ( (al.getSourceSystemId().equals("mano-client-service") ) && (al.getAlarmDetails() != null) ) { + if (al.getAlarmDetails().contains("DeploymentRequestID")) { + String[] vals = al.getAlarmDetails().split(";"); + for (String details : vals) { + String[] d = details.split("="); + if ( d[0].equals( "DeploymentRequestID" ) ) { + var aservices = serviceRepoService.findDeploymentRequestID( d[1] ); + + for (org.etsi.osl.tmf.sim638.model.Service service : aservices) { + if ( service.getState().equals( ServiceStateType.ACTIVE ) ) { + AffectedService as = new AffectedService(); + as.setId( service.getUuid()); + as.setBaseType("Service"); + al.getAffectedService().add(as ); + } + } + + } + } + + } + } + + return al; + } + + @Transactional + private Alarm updateAlarmFromAPICall(Alarm al, @Valid AlarmUpdate alarmUpdate) { + + if (alarmUpdate.getAckState() != null) { + al.setAckState(alarmUpdate.getAckState()); + } + if (alarmUpdate.getAckSystemId() != null) { + al.setAckSystemId(alarmUpdate.getAckSystemId()); + } + if (alarmUpdate.getAckUserId() != null) { + al.setAckUserId(alarmUpdate.getAckUserId()); + } + if (alarmUpdate.getAlarmChangedTime() != null) { + al.setAlarmChangedTime(alarmUpdate.getAlarmChangedTime()); + } + if (alarmUpdate.getAlarmClearedTime() != null) { + al.setAlarmClearedTime(alarmUpdate.getAlarmClearedTime()); + } + if (alarmUpdate.getAlarmDetails() != null) { + al.setAlarmDetails(alarmUpdate.getAlarmDetails()); + } + if (alarmUpdate.isAlarmEscalation() != null) { + al.setAlarmEscalation(alarmUpdate.isAlarmEscalation()); + } +// if (alarmUpdate.getAlarmReportingTime()!=null){ +// al.setAlarmReportingTime(alarmUpdate.getAlarmReportingTime()); +// } + if (alarmUpdate.getAlarmType() != null) { + al.setAlarmType(alarmUpdate.getAlarmType()); + } + if (alarmUpdate.getAlarmedObjectType() != null) { + al.setAlarmedObjectType(alarmUpdate.getAlarmedObjectType()); + } + if (alarmUpdate.getClearSystemId() != null) { + al.setClearSystemId(alarmUpdate.getClearSystemId()); + } + if (alarmUpdate.getClearUserId() != null) { + al.setClearUserId(alarmUpdate.getClearUserId()); + } + if (alarmUpdate.getExternalAlarmId() != null) { + al.setExternalAlarmId(alarmUpdate.getExternalAlarmId()); + } + if (alarmUpdate.isIsRootCause() != null) { + al.setIsRootCause(alarmUpdate.isIsRootCause()); + } + if (alarmUpdate.getPerceivedSeverity() != null) { + al.setPerceivedSeverity(alarmUpdate.getPerceivedSeverity()); + } + if (alarmUpdate.getPlannedOutageIndicator() != null) { + al.setPlannedOutageIndicator(alarmUpdate.getPlannedOutageIndicator()); + } + if (alarmUpdate.getProbableCause() != null) { + al.setProbableCause(alarmUpdate.getProbableCause()); + } + if (alarmUpdate.getProposedRepairedActions() != null) { + al.setProposedRepairedActions(alarmUpdate.getProposedRepairedActions()); + } + if (alarmUpdate.getReportingSystemId() != null) { + al.setReportingSystemId(alarmUpdate.getReportingSystemId()); + } + + if (alarmUpdate.isServiceAffecting() != null) { + al.setServiceAffecting(alarmUpdate.isServiceAffecting()); + } + if (alarmUpdate.getSpecificProblem() != null) { + al.setSpecificProblem(alarmUpdate.getSpecificProblem()); + } + + al.setState(AlarmStateType.raised.name()); + if (alarmUpdate.getState() != null) { + al.setState(alarmUpdate.getState()); + } + + if (alarmUpdate.getAffectedService() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (AffectedService ar : alarmUpdate.getAffectedService()) { + // find by id and reload it here. + // we need the model from resource models + boolean idexists = false; + for (AffectedService orinalAtt : al.getAffectedService()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + al.getAffectedService().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (AffectedService ss : al.getAffectedService()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (AffectedService ar : toRemove) { + al.getAffectedService().remove(ar); + } + + } + + if (alarmUpdate.getAlarmedObject() != null) { + al.setAlarmedObject(alarmUpdate.getAlarmedObject()); + } + + if (alarmUpdate.getCorrelatedAlarm() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (AlarmRef ar : alarmUpdate.getCorrelatedAlarm()) { + // find by id and reload it here. + // we need the model from resource models + boolean idexists = false; + for (AlarmRef orinalCom : al.getCorrelatedAlarm()) { + if (orinalCom.getUuid().equals(ar.getUuid())) { + idexists = true; + idAddedUpdated.put(orinalCom.getUuid(), true); + break; + } + } + + if (!idexists) { + al.getCorrelatedAlarm().add(ar); + idAddedUpdated.put(ar.getUuid(), true); + } + } + + List toRemove = new ArrayList<>(); + for (AlarmRef ss : al.getCorrelatedAlarm()) { + if (idAddedUpdated.get(ss.getUuid()) == null) { + toRemove.add(ss); + } + } + + for (AlarmRef ar : toRemove) { + al.getCorrelatedAlarm().remove(ar); + } + + } + + if (alarmUpdate.getCrossedThresholdInformation() != null) { + al.setCrossedThresholdInformation(alarmUpdate.getCrossedThresholdInformation()); + } + + if (alarmUpdate.getParentAlarm() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (AlarmRef ar : alarmUpdate.getParentAlarm()) { + // find by id and reload it here. + // we need the model from resource models + boolean idexists = false; + for (AlarmRef orinalCom : al.getParentAlarm()) { + if (orinalCom.getUuid().equals(ar.getUuid())) { + idexists = true; + idAddedUpdated.put(orinalCom.getUuid(), true); + break; + } + } + + if (!idexists) { + al.getParentAlarm().add(ar); + idAddedUpdated.put(ar.getUuid(), true); + } + } + + List toRemove = new ArrayList<>(); + for (AlarmRef ss : al.getParentAlarm()) { + if (idAddedUpdated.get(ss.getUuid()) == null) { + toRemove.add(ss); + } + } + + for (AlarmRef ar : toRemove) { + al.getParentAlarm().remove(ar); + } + + } + + if (alarmUpdate.getPlace() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (RelatedPlaceRefOrValue ar : alarmUpdate.getPlace()) { + // find by id and reload it here. + // we need the model from resource models + boolean idexists = false; + for (RelatedPlaceRefOrValue orinalCom : al.getPlace()) { + if (orinalCom.getUuid().equals(ar.getUuid())) { + idexists = true; + idAddedUpdated.put(orinalCom.getUuid(), true); + break; + } + } + + if (!idexists) { + al.getPlace().add(ar); + idAddedUpdated.put(ar.getUuid(), true); + } + } + + List toRemove = new ArrayList<>(); + for (RelatedPlaceRefOrValue ss : al.getPlace()) { + if (idAddedUpdated.get(ss.getUuid()) == null) { + toRemove.add(ss); + } + } + + for (RelatedPlaceRefOrValue ar : toRemove) { + al.getPlace().remove(ar); + } + + } + + if (alarmUpdate.getComment() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (Comment ar : alarmUpdate.getComment()) { + // find by id and reload it here. + // we need the model from resource models + boolean idexists = false; + for (Comment orinalCom : al.getComment()) { + if (orinalCom.getUuid().equals(ar.getUuid())) { + idexists = true; + idAddedUpdated.put(orinalCom.getUuid(), true); + break; + } + } + + if (!idexists) { + al.getComment().add(ar); + idAddedUpdated.put(ar.getUuid(), true); + } + } + + } + + return al; + } + + public Void deleteById(String id) { + Optional optionalCat = this.alarmRepo.findByUuid(id); + this.alarmRepo.delete(optionalCat.get()); + return null; + } + + public List findAll(@Valid String fields, Map allParams) throws UnsupportedEncodingException { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { + String sql = "SELECT " + "s.uuid as uuid," + "s.uuid as id," + "s.alarmType as alarmType," + + "s.ackState as ackState," + "s.alarmRaisedTime as alarmRaisedTime," + + "s.alarmReportingTime as alarmReportingTime," + "s.probableCause as probableCause," + + "s.sourceSystemId as sourceSystemId," + "s.state as state," + + "s.perceivedSeverity as perceivedSeverity"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f; + } + + } + sql += " FROM AMAlarm s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.alarmRaisedTime DESC"; + + List mapaEntity = session.createQuery(sql).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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + }).list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + return mapaEntity; + + } finally { + tx.commit(); + session.close(); + } + } + + @Transactional + public Alarm updateAlarm(String id, @Valid AlarmUpdate alarmUpdate) { + Alarm s = this.findByUuid(id); + if (s == null) { + return null; + } + Alarm alm = s; + alm = this.updateAlarmFromAPICall(alm, alarmUpdate); + + alm = this.alarmRepo.save(alm); + return alm; + } + + public Alarm findByUuid(String id) { + Optional optionalCat = this.alarmRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + public Alarm findByUuidEager(String id) { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); // instead of begin transaction, is it possible to continue? + Alarm dd = null; + try { + dd = session.get(Alarm.class, id); + if (dd == null) { + return this.findByUuid(id);// last resort + } + Hibernate.initialize(dd.getAffectedService()); + Hibernate.initialize(dd.getComment()); + Hibernate.initialize(dd.getCorrelatedAlarm()); + Hibernate.initialize(dd.getParentAlarm()); + Hibernate.initialize(dd.getPlace()); + + tx.commit(); + } finally { + session.close(); + } + return dd; + } + + @Transactional + private void raiseAlarmCreateEvent(Alarm alarm) { + AlarmCreateEvent e = new AlarmCreateEvent(); + AlarmCreateEventPayload p = new AlarmCreateEventPayload(); + p.setAlarm(alarm); + e.setEvent(p); + e.setTitle("AlarmCreate " + alarm.getId()); + e.setTimeOcurred( alarm.getAlarmReportingTime() ); + alarmApiRouteBuilder.publishEvent(e, alarm.getId()); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/reposervices/ClearAlarmsRepoService.java b/src/main/java/org/etsi/osl/tmf/am642/reposervices/ClearAlarmsRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..9b60048c9784c04a17e41236d0131900d64a30a6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/reposervices/ClearAlarmsRepoService.java @@ -0,0 +1,183 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.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.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.AlarmStateType; +import org.etsi.osl.tmf.am642.model.ClearAlarms; +import org.etsi.osl.tmf.am642.model.ClearAlarmsCreate; +import org.etsi.osl.tmf.am642.repo.ClearAlarmsRepository; +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.stereotype.Service; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class ClearAlarmsRepoService { + + @Autowired + ClearAlarmsRepository alRepo; + + private SessionFactory sessionFactory; + + @Autowired + public ClearAlarmsRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public ClearAlarms addClearAlarm(@Valid ClearAlarmsCreate ac) { + ClearAlarms al = new ClearAlarms(); + + al = updateFromAPICall( al , ac); + return this.alRepo.save( al ); + } + + + + public List findAll(String fields, Map allParams) throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { + String sql = "SELECT " + + "s.uuid as uuid," + + "s.id as id," + + "s.alarmClearedTime as alarmClearedTime," + + "s.clearUserId as clearUserId," + + "s.state as state"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM AMClearAlarms s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.alarmClearedTime DESC"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + } + + public ClearAlarms findById(String id) { + Optional optionalCat = this.alRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + private ClearAlarms updateFromAPICall(ClearAlarms al, @Valid ClearAlarmsCreate aSrc) { + + al.setClearSystemId( aSrc.getClearSystemId()); + al.setAlarmClearedTime( OffsetDateTime.now(ZoneOffset.UTC) ); + al.setClearUserId( aSrc.getClearUserId() ); + + if ( aSrc.getState() != null ) { + al.setState( aSrc.getState()); + } + al.setState( AlarmStateType.cleared.name() ); + if ( aSrc.getState() != null ) { + al.setState( aSrc.getState()); + } + +// maybe here we need to update the real Alarm? +// raised | updated | cleared). + + al.getClearedAlarm().addAll( aSrc.getClearedAlarm() ) ; + + + al.getAlarmPattern().addAll(aSrc.getAlarmPattern() ); + + + + return al; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/reposervices/CommentAlarmsRepoService.java b/src/main/java/org/etsi/osl/tmf/am642/reposervices/CommentAlarmsRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..9f9731e94a336021250bf682a098797e670a5629 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/reposervices/CommentAlarmsRepoService.java @@ -0,0 +1,166 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.reposervices; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.CommentAlarms; +import org.etsi.osl.tmf.am642.model.CommentAlarmsCreate; +import org.etsi.osl.tmf.am642.repo.CommentAlarmsRepository; +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.stereotype.Service; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class CommentAlarmsRepoService { + + + @Autowired + CommentAlarmsRepository alRepo; + + private SessionFactory sessionFactory; + + @Autowired + public CommentAlarmsRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public CommentAlarms addCommentAlarms(@Valid CommentAlarmsCreate ac) { + CommentAlarms al = new CommentAlarms(); + + al = updateFromAPICall( al , ac); + return this.alRepo.save( al ); + } + + + + public List findAll(String fields, Map allParams) throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { + String sql = "SELECT " + + "s.uuid as uuid," + + "s.id as id," + + "s.alarmChangedTime as alarmChangedTime," + + "s.sourceSystemId as sourceSystemId," + + "s.state as state"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM AMCommentAlarms s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.alarmChangedTime DESC"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + } + + public CommentAlarms findById(String id) { + Optional optionalCat = this.alRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + private CommentAlarms updateFromAPICall(CommentAlarms al, @Valid CommentAlarmsCreate aSrc) { + + + al.setState( aSrc.getState()); + al.setComment(aSrc.getComment()); + al.getCommentedAlarm().addAll( aSrc.getCommentedAlarm()); + al.getAlarmPattern().addAll( aSrc.getAlarmPattern() ); + + return al; + } + +} + diff --git a/src/main/java/org/etsi/osl/tmf/am642/reposervices/GroupAlarmsRepoService.java b/src/main/java/org/etsi/osl/tmf/am642/reposervices/GroupAlarmsRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..6197a4b0c78bbc1b33a5607c92c6662f12ebbff4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/reposervices/GroupAlarmsRepoService.java @@ -0,0 +1,167 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.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.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.GroupAlarms; +import org.etsi.osl.tmf.am642.model.GroupAlarmsCreate; +import org.etsi.osl.tmf.am642.repo.GroupAlarmsRepository; +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.stereotype.Service; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class GroupAlarmsRepoService { + + @Autowired + GroupAlarmsRepository alRepo; + + private SessionFactory sessionFactory; + + @Autowired + public GroupAlarmsRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public GroupAlarms addGroupAlarms(@Valid GroupAlarmsCreate ac) { + GroupAlarms al = new GroupAlarms(); + + al = updateFromAPICall( al , ac); + return this.alRepo.save( al ); + } + + + + public List findAll(String fields, Map allParams) throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { + String sql = "SELECT " + + "s.uuid as uuid," + + "s.id as id," + + "s.alarmChangedTime as alarmChangedTime," + + "s.sourceSystemId as sourceSystemId," + + "s.state as state"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM AMGroupAlarms s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.alarmChangedTime DESC"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + } + + public GroupAlarms findById(String id) { + Optional optionalCat = this.alRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + private GroupAlarms updateFromAPICall(GroupAlarms al, @Valid GroupAlarmsCreate aSrc) { + + al.setSourceSystemId( aSrc.getSourceSystemId()); + al.setAlarmChangedTime( OffsetDateTime.now(ZoneOffset.UTC) ); + al.setState( aSrc.getState()); + al.setParentAlarm( aSrc.getParentAlarm()); + al.getCorrelatedAlarm().addAll( aSrc.getCorrelatedAlarm()); + al.getGroupedAlarm().addAll( aSrc.getGroupedAlarm() ); + + return al; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/reposervices/UnAckAlarmsRepoService.java b/src/main/java/org/etsi/osl/tmf/am642/reposervices/UnAckAlarmsRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..9b7665164dcac1e6ec1ab4a3edc731e28b9b6e27 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/reposervices/UnAckAlarmsRepoService.java @@ -0,0 +1,167 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.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.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.UnAckAlarms; +import org.etsi.osl.tmf.am642.model.UnAckAlarmsCreate; +import org.etsi.osl.tmf.am642.repo.UnAckAlarmsRepository; +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.stereotype.Service; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class UnAckAlarmsRepoService { + + @Autowired + UnAckAlarmsRepository alRepo; + + private SessionFactory sessionFactory; + + @Autowired + public UnAckAlarmsRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public UnAckAlarms addAckAlarm(@Valid UnAckAlarmsCreate ac) { + UnAckAlarms al = new UnAckAlarms(); + + al = updateFromAPICall( al , ac); + return this.alRepo.save( al ); + } + + + + public List findAll(String fields, Map allParams) throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { + String sql = "SELECT " + + "s.uuid as uuid," + + "s.id as id," + + "s.ackTime as ackTime," + + "s.ackUserId as ackUserId," + + "s.state as state"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM AMUnAckAlarms s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.ackTime DESC"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + } + + public UnAckAlarms findById(String id) { + Optional optionalCat = this.alRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + private UnAckAlarms updateFromAPICall(UnAckAlarms al, @Valid UnAckAlarmsCreate aSrc) { + + al.setAckSystemId( aSrc.getAckSystemId()); + al.ackTime( OffsetDateTime.now(ZoneOffset.UTC) ); + al.setAckUserId( aSrc.getAckUserId() ); + al.setState( aSrc.getState()); + al.getUnAckedAlarm().addAll( aSrc.getUnAckedAlarm() ) ; + al.getAlarmPattern().addAll(aSrc.getAlarmPattern() ); + + return al; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am642/reposervices/UnGroupAlarmsRepoService.java b/src/main/java/org/etsi/osl/tmf/am642/reposervices/UnGroupAlarmsRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..d4e0b6f0371202b4730f51af3a9a48b616537bd2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am642/reposervices/UnGroupAlarmsRepoService.java @@ -0,0 +1,167 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.am642.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.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.am642.model.UnGroupAlarms; +import org.etsi.osl.tmf.am642.model.UnGroupAlarmsCreate; +import org.etsi.osl.tmf.am642.repo.UnGroupAlarmsRepository; +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.stereotype.Service; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class UnGroupAlarmsRepoService { + + @Autowired + UnGroupAlarmsRepository alRepo; + + private SessionFactory sessionFactory; + + @Autowired + public UnGroupAlarmsRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public UnGroupAlarms addUnGroupAlarms(@Valid UnGroupAlarmsCreate ac) { + UnGroupAlarms al = new UnGroupAlarms(); + + al = updateFromAPICall( al , ac); + return this.alRepo.save( al ); + } + + + + public List findAll(String fields, Map allParams) throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { + String sql = "SELECT " + + "s.uuid as uuid," + + "s.id as id," + + "s.alarmChangedTime as alarmChangedTime," + + "s.sourceSystemId as sourceSystemId," + + "s.state as state"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM AMUnGroupAlarms s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.alarmChangedTime DESC"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + } + + public UnGroupAlarms findById(String id) { + Optional optionalCat = this.alRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + private UnGroupAlarms updateFromAPICall(UnGroupAlarms al, @Valid UnGroupAlarmsCreate aSrc) { + + al.setSourceSystemId( aSrc.getSourceSystemId()); + al.setAlarmChangedTime( OffsetDateTime.now(ZoneOffset.UTC) ); + al.setState( aSrc.getState()); + al.setParentAlarm( aSrc.getParentAlarm()); + al.getCorrelatedAlarm().addAll( aSrc.getCorrelatedAlarm()); + al.getUnGroupedAlarm().addAll( aSrc.getUnGroupedAlarm() ); + + return al; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am651/api/AgreementApi.java b/src/main/java/org/etsi/osl/tmf/am651/api/AgreementApi.java new file mode 100644 index 0000000000000000000000000000000000000000..a93201661e224e804225bad1e8d0b2f87967b165 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/AgreementApi.java @@ -0,0 +1,216 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am651.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am651.model.Agreement; +import org.etsi.osl.tmf.am651.model.AgreementCreate; +import org.etsi.osl.tmf.am651.model.AgreementUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +@Tag(name = "agreement", description = "the agreement API") +public interface AgreementApi { + + Logger log = LoggerFactory.getLogger(AgreementApi.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 'Agreement'", operationId = "createAgreement", description = "", tags={ "agreement", }) + @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 = "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 = "/agreement", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createAgreement(@Parameter(description = "The Agreement to be created" ,required=true ) @Valid @RequestBody AgreementCreate agreement) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"agreementPeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"associatedAgreement\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"documentNumber\" : 0, \"agreementSpecification\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"type\" : \"type\", \"version\" : \"version\", \"initialDate\" : \"2000-01-23T04:56:07.000+00:00\", \"engagedPartyRole\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" } ], \"characteristic\" : [ { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" }, { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" } ], \"agreementAuthorization\" : [ { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" }, { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" } ], \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"completionDate\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"statementOfIntent\" : \"statementOfIntent\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"agreementItem\" : [ { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" }, { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" } ], \"status\" : \"status\"}", Agreement.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 AgreementApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a 'Agreement' by Id", operationId = "deleteAgreement", description = "", tags={ "agreement", }) + @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 = "/agreement/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteAgreement(@Parameter(description = "Identifier of the Agreement",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AgreementApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find 'Agreement' objects", operationId = "listAgreement", description = "" , tags={ "agreement", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/agreement", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> listAgreement(@Parameter(description = "Comma separated properties to display 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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"agreementPeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"associatedAgreement\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"documentNumber\" : 0, \"agreementSpecification\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"type\" : \"type\", \"version\" : \"version\", \"initialDate\" : \"2000-01-23T04:56:07.000+00:00\", \"engagedPartyRole\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" } ], \"characteristic\" : [ { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" }, { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" } ], \"agreementAuthorization\" : [ { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" }, { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" } ], \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"completionDate\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"statementOfIntent\" : \"statementOfIntent\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"agreementItem\" : [ { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" }, { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" } ], \"status\" : \"status\"}, { \"agreementPeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"associatedAgreement\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"documentNumber\" : 0, \"agreementSpecification\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"type\" : \"type\", \"version\" : \"version\", \"initialDate\" : \"2000-01-23T04:56:07.000+00:00\", \"engagedPartyRole\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" } ], \"characteristic\" : [ { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" }, { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" } ], \"agreementAuthorization\" : [ { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" }, { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" } ], \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"completionDate\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"statementOfIntent\" : \"statementOfIntent\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"agreementItem\" : [ { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" }, { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" } ], \"status\" : \"status\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AgreementApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a 'Agreement' by Id", operationId = "patchAgreement", description = "", tags={ "agreement", }) + @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 = "/agreement/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.PATCH) + default ResponseEntity patchAgreement(@Parameter(description = "Identifier of the Agreement",required=true) @PathVariable("id") String id,@Parameter(description = "The Agreement to be updated" ,required=true ) @Valid @RequestBody AgreementUpdate agreement) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"agreementPeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"associatedAgreement\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"documentNumber\" : 0, \"agreementSpecification\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"type\" : \"type\", \"version\" : \"version\", \"initialDate\" : \"2000-01-23T04:56:07.000+00:00\", \"engagedPartyRole\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" } ], \"characteristic\" : [ { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" }, { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" } ], \"agreementAuthorization\" : [ { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" }, { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" } ], \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"completionDate\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"statementOfIntent\" : \"statementOfIntent\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"agreementItem\" : [ { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" }, { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" } ], \"status\" : \"status\"}", Agreement.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 AgreementApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a 'Agreement' by Id", operationId = "retrieveAgreement", description = "" , tags={ "agreement", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/agreement/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> retrieveAgreement(@Parameter(description = "Identifier of the Agreement",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"agreementPeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"associatedAgreement\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"documentNumber\" : 0, \"agreementSpecification\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"type\" : \"type\", \"version\" : \"version\", \"initialDate\" : \"2000-01-23T04:56:07.000+00:00\", \"engagedPartyRole\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" } ], \"characteristic\" : [ { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" }, { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" } ], \"agreementAuthorization\" : [ { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" }, { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" } ], \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"completionDate\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"statementOfIntent\" : \"statementOfIntent\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"agreementItem\" : [ { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" }, { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" } ], \"status\" : \"status\"}, { \"agreementPeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"associatedAgreement\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"documentNumber\" : 0, \"agreementSpecification\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"type\" : \"type\", \"version\" : \"version\", \"initialDate\" : \"2000-01-23T04:56:07.000+00:00\", \"engagedPartyRole\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"partyName\" : \"partyName\", \"href\" : \"href\", \"id\" : \"id\", \"partyId\" : \"partyId\" } ], \"characteristic\" : [ { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" }, { \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"@schemaLocation\", \"value\" : \"value\" } ], \"agreementAuthorization\" : [ { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" }, { \"date\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"signatureRepresentation\" : \"signatureRepresentation\", \"state\" : \"state\" } ], \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"completionDate\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"statementOfIntent\" : \"statementOfIntent\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"agreementItem\" : [ { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" }, { \"termOrCondition\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"id\" : \"id\" } ], \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"@type\" : \"@type\" } ], \"status\" : \"status\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AgreementApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am651/api/AgreementApiController.java b/src/main/java/org/etsi/osl/tmf/am651/api/AgreementApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..2c9e65e7e4b541a2b8d690d42f1aae3be267e9b9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/AgreementApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am651.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +@Controller +@RequestMapping("/agreementManagement/v2/") +public class AgreementApiController implements AgreementApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AgreementApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am651/api/AgreementSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/am651/api/AgreementSpecificationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..3f47700f184f6c18d583618f966b77ca082fa62e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/AgreementSpecificationApi.java @@ -0,0 +1,216 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am651.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am651.model.AgreementSpecification; +import org.etsi.osl.tmf.am651.model.AgreementSpecificationCreate; +import org.etsi.osl.tmf.am651.model.AgreementSpecificationUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +@Tag(name = "agreementSpecification", description = "the agreementSpecification API") +public interface AgreementSpecificationApi { + + Logger log = LoggerFactory.getLogger(AgreementSpecificationApi.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 'AgreementSpecification'", operationId = "createAgreementSpecification", description = "", tags={ "agreementSpecification", }) + @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 = "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 = "/agreementSpecification", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createAgreementSpecification(@Parameter(description = "The Agreement Specification to be created" ,required=true ) @Valid @RequestBody AgreementSpecificationCreate agreementSpecification) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"isBundle\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"specCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"version\" : \"version\", \"serviceCategory\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, \"specificationRelationship\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" } ], \"attachment\" : [ { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" }, { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" } ], \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"}", AgreementSpecification.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 AgreementSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a 'AgreementSpecification' by Id", operationId = "deleteAgreementSpecification", description = "", tags={ "agreementSpecification", }) + @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 = "/agreementSpecification/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteAgreementSpecification(@Parameter(description = "Identifier of the Agreement Specification",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AgreementSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find 'AgreementSpecification' objects", operationId = "listAgreementSpecification", description = "" , tags={ "agreementSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/agreementSpecification", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> listAgreementSpecification(@Parameter(description = "Comma separated properties to display 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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"isBundle\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"specCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"version\" : \"version\", \"serviceCategory\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, \"specificationRelationship\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" } ], \"attachment\" : [ { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" }, { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" } ], \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"}, { \"isBundle\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"specCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"version\" : \"version\", \"serviceCategory\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, \"specificationRelationship\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" } ], \"attachment\" : [ { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" }, { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" } ], \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AgreementSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a 'AgreementSpecification' by Id", operationId = "patchAgreementSpecification", description = "", tags={ "agreementSpecification", }) + @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 = "/agreementSpecification/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.PATCH) + default ResponseEntity patchAgreementSpecification(@Parameter(description = "Identifier of the Agreement Specification",required=true) @PathVariable("id") String id,@Parameter(description = "The Agreement Specification to be updated" ,required=true ) @Valid @RequestBody AgreementSpecificationUpdate agreementSpecification) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"isBundle\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"specCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"version\" : \"version\", \"serviceCategory\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, \"specificationRelationship\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" } ], \"attachment\" : [ { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" }, { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" } ], \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"}", AgreementSpecification.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 AgreementSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a 'AgreementSpecification' by Id", operationId = "retrieveAgreementSpecification", description = "" , tags={ "agreementSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/agreementSpecification/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> retrieveAgreementSpecification(@Parameter(description = "Identifier of the Agreement Specification",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"isBundle\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"specCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"version\" : \"version\", \"serviceCategory\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, \"specificationRelationship\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" } ], \"attachment\" : [ { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" }, { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" } ], \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"}, { \"isBundle\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"specCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"specCharacteristicValue\" : [ { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" }, { \"default\" : true, \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"value\" : \"value\", \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"configurable\" : true } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"version\" : \"version\", \"serviceCategory\" : { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, \"specificationRelationship\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\" } ], \"attachment\" : [ { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" }, { \"@type\" : \"@type\", \"href\" : \"href\", \"id\" : \"id\", \"type\" : \"type\", \"url\" : \"url\" } ], \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default AgreementSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am651/api/AgreementSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/am651/api/AgreementSpecificationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..6cf2d262eb9a8d3b2cbe29a43e8014d9c3ac0f4e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/AgreementSpecificationApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am651.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +@Controller +@RequestMapping("/agreementManagement/v2/") +public class AgreementSpecificationApiController implements AgreementSpecificationApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AgreementSpecificationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am651/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/am651/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..710571ad81b9019f8cae779d9c87c8959e95f3a5 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.am651.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +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/am651/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/am651/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..a3ba45451670ac11e07c84684d3e7aefb9b5b3de --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================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.am651.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.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +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/am651/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/am651/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..a7b0ea1b4eea291447acd3a9789caf869af6e4ce --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================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.am651.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +@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/am651/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/am651/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..df3405804b41db0f2855d1ad2d4f67b5f5cd643c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am651.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am651.model.EventSubscription; +import org.etsi.osl.tmf.am651.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am651/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/am651/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..fdce842f8bc8d5457439f0dd3d9d36ea2baf7c82 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am651.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +@Controller("HubApiController651") +@RequestMapping("/agreementManagement/v2/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am651/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/am651/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..c6a41e6de7a9bda372ad0aff3ba04ab48a7f7964 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/NotFoundException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.am651.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:51:58.660+03:00") + +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/am651/api/RFC3339DateFormat.java b/src/main/java/org/etsi/osl/tmf/am651/api/RFC3339DateFormat.java new file mode 100644 index 0000000000000000000000000000000000000000..7efad729c7eb27f8790f8e32766e0951da07959e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am651/api/RFC3339DateFormat.java @@ -0,0 +1,41 @@ +/*- + * ========================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.am651.api; + +import java.text.FieldPosition; +import java.util.Date; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + + +public class RFC3339DateFormat extends ISO8601DateFormat { + + private static final long serialVersionUID = 1L; + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/am666/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..73cc7b2e9ebda43adf7a0f978ca8fa31c0e17527 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.am666.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +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/am666/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/am666/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..bfaea9c0d1c9c331cabfc777c1dcaebb48c39abb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================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.am666.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.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +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/am666/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/am666/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..930c455e1448dacefaaeb725cee7850054adf39b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================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.am666.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@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/am666/api/BillFormatApi.java b/src/main/java/org/etsi/osl/tmf/am666/api/BillFormatApi.java new file mode 100644 index 0000000000000000000000000000000000000000..2a390e3169f984c731dc013a3f752fcf07a9c355 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/BillFormatApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am666.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am666.model.BillFormat; +import org.etsi.osl.tmf.am666.model.BillFormatCreate; +import org.etsi.osl.tmf.am666.model.BillFormatUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Tag(name = "billFormat", description = "the billFormat API") +public interface BillFormatApi { + + Logger log = LoggerFactory.getLogger(BillFormatApi.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 BillFormat", operationId = "createBillFormat", description = "This operation creates a BillFormat entity.", tags={ "billFormat", }) + @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 = "/billFormat", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createBillFormat(@Parameter(description = "The BillFormat to be created" ,required=true ) @Valid @RequestBody BillFormatCreate billFormat) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", BillFormat.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 BillFormatApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a BillFormat", operationId = "deleteBillFormat", description = "This operation deletes a BillFormat entity.", tags={ "billFormat", }) + @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 = "/billFormat/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteBillFormat(@Parameter(description = "Identifier of the BillFormat",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default BillFormatApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find BillFormat objects", operationId = "listBillFormat", description = "This operation list or find BillFormat entities" , tags={ "billFormat", }) + @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 = "/billFormat", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listBillFormat(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default BillFormatApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a BillFormat", operationId = "patchBillFormat", description = "This operation updates partially a BillFormat entity.", tags={ "billFormat", }) + @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 = "/billFormat/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchBillFormat(@Parameter(description = "Identifier of the BillFormat",required=true) @PathVariable("id") String id,@Parameter(description = "The BillFormat to be updated" ,required=true ) @Valid @RequestBody BillFormatUpdate billFormat) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", BillFormat.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 BillFormatApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a BillFormat by ID", operationId = "retrieveBillFormat", description = "This operation retrieves a BillFormat entity. Attribute selection is enabled for all first level attributes.", tags={ "billFormat", }) + @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 = "/billFormat/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveBillFormat(@Parameter(description = "Identifier of the BillFormat",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("{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", BillFormat.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 BillFormatApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/BillFormatApiController.java b/src/main/java/org/etsi/osl/tmf/am666/api/BillFormatApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..05e5c00fd1be46eefedbced5f8af4c1ae547b187 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/BillFormatApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am666.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Controller +@RequestMapping("/accountManagement/v4/") +public class BillFormatApiController implements BillFormatApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public BillFormatApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/BillPresentationMediaApi.java b/src/main/java/org/etsi/osl/tmf/am666/api/BillPresentationMediaApi.java new file mode 100644 index 0000000000000000000000000000000000000000..ae46d5f9f7fa2ba88e32b90bd660a43baca8fd11 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/BillPresentationMediaApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am666.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am666.model.BillPresentationMedia; +import org.etsi.osl.tmf.am666.model.BillPresentationMediaCreate; +import org.etsi.osl.tmf.am666.model.BillPresentationMediaUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Tag(name = "billPresentationMedia", description = "the billPresentationMedia API") +public interface BillPresentationMediaApi { + + Logger log = LoggerFactory.getLogger(BillPresentationMediaApi.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 BillPresentationMedia", operationId = "createBillPresentationMedia", description = "This operation creates a BillPresentationMedia entity.", tags={ "billPresentationMedia", }) + @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 = "/billPresentationMedia", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createBillPresentationMedia(@Parameter(description = "The BillPresentationMedia to be created" ,required=true ) @Valid @RequestBody BillPresentationMediaCreate billPresentationMedia) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", BillPresentationMedia.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 BillPresentationMediaApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a BillPresentationMedia", operationId = "deleteBillPresentationMedia", description = "This operation deletes a BillPresentationMedia entity.", tags={ "billPresentationMedia", }) + @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 = "/billPresentationMedia/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteBillPresentationMedia(@Parameter(description = "Identifier of the BillPresentationMedia",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default BillPresentationMediaApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find BillPresentationMedia objects", operationId = "listBillPresentationMedia", description = "This operation list or find BillPresentationMedia entities" , tags={ "billPresentationMedia", }) + @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 = "/billPresentationMedia", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listBillPresentationMedia(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default BillPresentationMediaApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a BillPresentationMedia", operationId = "patchBillPresentationMedia", description = "This operation updates partially a BillPresentationMedia entity.", tags={ "billPresentationMedia", }) + @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 = "/billPresentationMedia/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchBillPresentationMedia(@Parameter(description = "Identifier of the BillPresentationMedia",required=true) @PathVariable("id") String id,@Parameter(description = "The BillPresentationMedia to be updated" ,required=true ) @Valid @RequestBody BillPresentationMediaUpdate billPresentationMedia) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", BillPresentationMedia.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 BillPresentationMediaApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a BillPresentationMedia by ID", operationId = "retrieveBillPresentationMedia", description = "This operation retrieves a BillPresentationMedia entity. Attribute selection is enabled for all first level attributes.", tags={ "billPresentationMedia", }) + @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 = "/billPresentationMedia/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveBillPresentationMedia(@Parameter(description = "Identifier of the BillPresentationMedia",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("{ \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", BillPresentationMedia.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 BillPresentationMediaApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/BillPresentationMediaApiController.java b/src/main/java/org/etsi/osl/tmf/am666/api/BillPresentationMediaApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..b8dda1c50705bf355c0b680661361916597a69c0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/BillPresentationMediaApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am666.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Controller +@RequestMapping("/accountManagement/v4/") +public class BillPresentationMediaApiController implements BillPresentationMediaApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public BillPresentationMediaApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/BillingAccountApi.java b/src/main/java/org/etsi/osl/tmf/am666/api/BillingAccountApi.java new file mode 100644 index 0000000000000000000000000000000000000000..f020ce5ac229a7d775fc639cc5b398d19abd1b9e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/BillingAccountApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am666.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am666.model.BillingAccount; +import org.etsi.osl.tmf.am666.model.BillingAccountCreate; +import org.etsi.osl.tmf.am666.model.BillingAccountUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Tag(name = "billingAccount", description = "the billingAccount API") +public interface BillingAccountApi { + + Logger log = LoggerFactory.getLogger(BillingAccountApi.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 BillingAccount", operationId = "createBillingAccount", description = "This operation creates a BillingAccount entity.", tags={ "billingAccount", }) + @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 = "/billingAccount", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createBillingAccount(@Parameter(description = "The BillingAccount to be created" ,required=true ) @Valid @RequestBody BillingAccountCreate billingAccount) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"ratingType\" : \"ratingType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}", BillingAccount.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 BillingAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a BillingAccount", operationId = "deleteBillingAccount", description = "This operation deletes a BillingAccount entity.", tags={ "billingAccount", }) + @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 = "/billingAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteBillingAccount(@Parameter(description = "Identifier of the BillingAccount",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default BillingAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find BillingAccount objects", operationId = "listBillingAccount", description = "This operation list or find BillingAccount entities" , tags={ "billingAccount", }) + @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 = "/billingAccount", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listBillingAccount(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"ratingType\" : \"ratingType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}, { \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"ratingType\" : \"ratingType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default BillingAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a BillingAccount", operationId = "patchBillingAccount", description = "This operation updates partially a BillingAccount entity.", tags={ "billingAccount", }) + @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 = "/billingAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchBillingAccount(@Parameter(description = "Identifier of the BillingAccount",required=true) @PathVariable("id") String id,@Parameter(description = "The BillingAccount to be updated" ,required=true ) @Valid @RequestBody BillingAccountUpdate billingAccount) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"ratingType\" : \"ratingType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}", BillingAccount.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 BillingAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a BillingAccount by ID", operationId = "retrieveBillingAccount", description = "This operation retrieves a BillingAccount entity. Attribute selection is enabled for all first level attributes.", tags={ "billingAccount", }) + @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 = "/billingAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveBillingAccount(@Parameter(description = "Identifier of the BillingAccount",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("{ \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"ratingType\" : \"ratingType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}", BillingAccount.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 BillingAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/BillingAccountApiController.java b/src/main/java/org/etsi/osl/tmf/am666/api/BillingAccountApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..02bffa280ee20b2a67fbe70ca3b5d5d2eebad711 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/BillingAccountApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am666.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Controller +@RequestMapping("/accountManagement/v4/") +public class BillingAccountApiController implements BillingAccountApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public BillingAccountApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/BillingCycleSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/am666/api/BillingCycleSpecificationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..ba6bc4c894f4117c1b1be4fcdc50f95e99136ac2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/BillingCycleSpecificationApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am666.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am666.model.BillingCycleSpecification; +import org.etsi.osl.tmf.am666.model.BillingCycleSpecificationCreate; +import org.etsi.osl.tmf.am666.model.BillingCycleSpecificationUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Tag(name = "billingCycleSpecification", description = "the billingCycleSpecification API") +public interface BillingCycleSpecificationApi { + + Logger log = LoggerFactory.getLogger(BillingCycleSpecificationApi.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 BillingCycleSpecification", operationId = "createBillingCycleSpecification", description = "This operation creates a BillingCycleSpecification entity.", tags={ "billingCycleSpecification", }) + @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 = "/billingCycleSpecification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createBillingCycleSpecification(@Parameter(description = "The BillingCycleSpecification to be created" ,required=true ) @Valid @RequestBody BillingCycleSpecificationCreate billingCycleSpecification) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 5, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"creditDateOffset\" : 1, \"frequency\" : \"frequency\", \"billingDateShift\" : 0, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 5, \"name\" : \"name\", \"chargeDateOffset\" : 6, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", BillingCycleSpecification.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 BillingCycleSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a BillingCycleSpecification", operationId = "deleteBillingCycleSpecification", description = "This operation deletes a BillingCycleSpecification entity.", tags={ "billingCycleSpecification", }) + @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 = "/billingCycleSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteBillingCycleSpecification(@Parameter(description = "Identifier of the BillingCycleSpecification",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default BillingCycleSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find BillingCycleSpecification objects", operationId = "listBillingCycleSpecification", description = "This operation list or find BillingCycleSpecification entities" , tags={ "billingCycleSpecification", }) + @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 = "/billingCycleSpecification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listBillingCycleSpecification(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 5, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"creditDateOffset\" : 1, \"frequency\" : \"frequency\", \"billingDateShift\" : 0, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 5, \"name\" : \"name\", \"chargeDateOffset\" : 6, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}, { \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 5, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"creditDateOffset\" : 1, \"frequency\" : \"frequency\", \"billingDateShift\" : 0, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 5, \"name\" : \"name\", \"chargeDateOffset\" : 6, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default BillingCycleSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a BillingCycleSpecification", operationId = "patchBillingCycleSpecification", description = "This operation updates partially a BillingCycleSpecification entity.", tags={ "billingCycleSpecification", }) + @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 = "/billingCycleSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchBillingCycleSpecification(@Parameter(description = "Identifier of the BillingCycleSpecification",required=true) @PathVariable("id") String id,@Parameter(description = "The BillingCycleSpecification to be updated" ,required=true ) @Valid @RequestBody BillingCycleSpecificationUpdate billingCycleSpecification) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 5, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"creditDateOffset\" : 1, \"frequency\" : \"frequency\", \"billingDateShift\" : 0, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 5, \"name\" : \"name\", \"chargeDateOffset\" : 6, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", BillingCycleSpecification.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 BillingCycleSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a BillingCycleSpecification by ID", operationId = "retrieveBillingCycleSpecification", description = "This operation retrieves a BillingCycleSpecification entity. Attribute selection is enabled for all first level attributes.", tags={ "billingCycleSpecification", }) + @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 = "/billingCycleSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveBillingCycleSpecification(@Parameter(description = "Identifier of the BillingCycleSpecification",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("{ \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 5, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"creditDateOffset\" : 1, \"frequency\" : \"frequency\", \"billingDateShift\" : 0, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 5, \"name\" : \"name\", \"chargeDateOffset\" : 6, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", BillingCycleSpecification.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 BillingCycleSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/BillingCycleSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/am666/api/BillingCycleSpecificationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..ada74032e5a55537f94e5037319992059e146176 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/BillingCycleSpecificationApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am666.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Controller +@RequestMapping("/accountManagement/v4/") +public class BillingCycleSpecificationApiController implements BillingCycleSpecificationApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public BillingCycleSpecificationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/FinancialAccountApi.java b/src/main/java/org/etsi/osl/tmf/am666/api/FinancialAccountApi.java new file mode 100644 index 0000000000000000000000000000000000000000..568534ed91e67b012370388258b2b75976fa10d0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/FinancialAccountApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am666.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am666.model.FinancialAccount; +import org.etsi.osl.tmf.am666.model.FinancialAccountCreate; +import org.etsi.osl.tmf.am666.model.FinancialAccountUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Tag(name = "financialAccount", description = "the financialAccount API") +public interface FinancialAccountApi { + + Logger log = LoggerFactory.getLogger(FinancialAccountApi.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 FinancialAccount", operationId = "createFinancialAccount", description = "This operation creates a FinancialAccount entity.", tags={ "financialAccount", }) + @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 = "/financialAccount", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createFinancialAccount(@Parameter(description = "The FinancialAccount to be created" ,required=true ) @Valid @RequestBody FinancialAccountCreate financialAccount) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"}", FinancialAccount.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 FinancialAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a FinancialAccount", operationId = "deleteFinancialAccount", description = "This operation deletes a FinancialAccount entity.", tags={ "financialAccount", }) + @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 = "/financialAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteFinancialAccount(@Parameter(description = "Identifier of the FinancialAccount",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FinancialAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find FinancialAccount objects", operationId = "listFinancialAccount", description = "This operation list or find FinancialAccount entities" , tags={ "financialAccount", }) + @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 = "/financialAccount", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listFinancialAccount(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"}, { \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default FinancialAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a FinancialAccount", operationId = "patchFinancialAccount", description = "This operation updates partially a FinancialAccount entity.", tags={ "financialAccount", }) + @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 = "/financialAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchFinancialAccount(@Parameter(description = "Identifier of the FinancialAccount",required=true) @PathVariable("id") String id,@Parameter(description = "The FinancialAccount to be updated" ,required=true ) @Valid @RequestBody FinancialAccountUpdate financialAccount) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"}", FinancialAccount.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 FinancialAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a FinancialAccount by ID", operationId = "retrieveFinancialAccount", description = "This operation retrieves a FinancialAccount entity. Attribute selection is enabled for all first level attributes.", tags={ "financialAccount", }) + @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 = "/financialAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveFinancialAccount(@Parameter(description = "Identifier of the FinancialAccount",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("{ \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"}", FinancialAccount.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 FinancialAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/FinancialAccountApiController.java b/src/main/java/org/etsi/osl/tmf/am666/api/FinancialAccountApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..62913e6de43bae82c59d3f11bbe448ec15971dbb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/FinancialAccountApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am666.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Controller +@RequestMapping("/accountManagement/v4/") +public class FinancialAccountApiController implements FinancialAccountApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public FinancialAccountApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/am666/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..b98c694c35f1d93f40b0376531985273c5627481 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am666.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am666.model.EventSubscription; +import org.etsi.osl.tmf.am666.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/am666/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..10f3d20a4e394b346afbff99a59c2ef1966f7c39 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am666.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Controller("HubApiController666") +@RequestMapping("/accountManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/am666/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..2e6c6f55b5c17eef95e435ace812ad5cf94433af --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/ListenerApi.java @@ -0,0 +1,384 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am666.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am666.model.BillingAccountAttributeValueChangeEvent; +import org.etsi.osl.tmf.am666.model.BillingAccountStateChangeEvent; +import org.etsi.osl.tmf.am666.model.EventSubscription; +import org.etsi.osl.tmf.am666.model.FinancialAccountAttributeValueChangeEvent; +import org.etsi.osl.tmf.am666.model.FinancialAccountCreateEvent; +import org.etsi.osl.tmf.am666.model.FinancialAccountDeleteEvent; +import org.etsi.osl.tmf.am666.model.FinancialAccountStateChangeEvent; +import org.etsi.osl.tmf.am666.model.PartyAccountAttributeValueChangeEvent; +import org.etsi.osl.tmf.am666.model.PartyAccountStateChangeEvent; +import org.etsi.osl.tmf.am666.model.SettlementAccountAttributeValueChangeEvent; +import org.etsi.osl.tmf.am666.model.SettlementAccountStateChangeEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity BillingAccountAttributeValueChangeEvent", operationId = "listenToBillingAccountAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification BillingAccountAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/billingAccountAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToBillingAccountAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody BillingAccountAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity BillingAccountStateChangeEvent", operationId = "listenToBillingAccountStateChangeEvent", description = "Example of a client listener for receiving the notification BillingAccountStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/billingAccountStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToBillingAccountStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody BillingAccountStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity FinancialAccountAttributeValueChangeEvent", operationId = "listenToFinancialAccountAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification FinancialAccountAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/financialAccountAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToFinancialAccountAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody FinancialAccountAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity FinancialAccountCreateEvent", operationId = "listenToFinancialAccountCreateEvent", description = "Example of a client listener for receiving the notification FinancialAccountCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/financialAccountCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToFinancialAccountCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody FinancialAccountCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity FinancialAccountDeleteEvent", operationId = "listenToFinancialAccountDeleteEvent", description = "Example of a client listener for receiving the notification FinancialAccountDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/financialAccountDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToFinancialAccountDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody FinancialAccountDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity FinancialAccountStateChangeEvent", operationId = "listenToFinancialAccountStateChangeEvent", description = "Example of a client listener for receiving the notification FinancialAccountStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/financialAccountStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToFinancialAccountStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody FinancialAccountStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity PartyAccountAttributeValueChangeEvent", operationId = "listenToPartyAccountAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification PartyAccountAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/partyAccountAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToPartyAccountAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody PartyAccountAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity PartyAccountStateChangeEvent", operationId = "listenToPartyAccountStateChangeEvent", description = "Example of a client listener for receiving the notification PartyAccountStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/partyAccountStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToPartyAccountStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody PartyAccountStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity SettlementAccountAttributeValueChangeEvent", operationId = "listenToSettlementAccountAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification SettlementAccountAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/settlementAccountAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToSettlementAccountAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody SettlementAccountAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity SettlementAccountStateChangeEvent", operationId = "listenToSettlementAccountStateChangeEvent", description = "Example of a client listener for receiving the notification SettlementAccountStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/settlementAccountStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToSettlementAccountStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody SettlementAccountStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/am666/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..d1d33e9379e5c9bf2c6a892ddb12e976805c407f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am666.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Controller("ListenerApiController666") +@RequestMapping("/accountManagement/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/am666/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..aec90ac40ed31e97040bdb49fea580e5673ab1fb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/NotFoundException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.am666.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +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/am666/api/PartyAccountApi.java b/src/main/java/org/etsi/osl/tmf/am666/api/PartyAccountApi.java new file mode 100644 index 0000000000000000000000000000000000000000..7a5e75c1200f324518629e6d867053b1f42f1323 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/PartyAccountApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am666.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am666.model.PartyAccount; +import org.etsi.osl.tmf.am666.model.PartyAccountCreate; +import org.etsi.osl.tmf.am666.model.PartyAccountUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Tag(name = "partyAccount", description = "the partyAccount API") +public interface PartyAccountApi { + + Logger log = LoggerFactory.getLogger(PartyAccountApi.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 PartyAccount", operationId = "createPartyAccount", description = "This operation creates a PartyAccount entity.", tags={ "partyAccount", }) + @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 = "/partyAccount", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createPartyAccount(@Parameter(description = "The PartyAccount to be created" ,required=true ) @Valid @RequestBody PartyAccountCreate partyAccount) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}", PartyAccount.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 PartyAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a PartyAccount", operationId = "deletePartyAccount", description = "This operation deletes a PartyAccount entity.", tags={ "partyAccount", }) + @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 = "/partyAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deletePartyAccount(@Parameter(description = "Identifier of the PartyAccount",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PartyAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find PartyAccount objects", operationId = "listPartyAccount", description = "This operation list or find PartyAccount entities" , tags={ "partyAccount", }) + @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 = "/partyAccount", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listPartyAccount(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}, { \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PartyAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a PartyAccount", operationId = "patchPartyAccount", description = "This operation updates partially a PartyAccount entity.", tags={ "partyAccount", }) + @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 = "/partyAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchPartyAccount(@Parameter(description = "Identifier of the PartyAccount",required=true) @PathVariable("id") String id,@Parameter(description = "The PartyAccount to be updated" ,required=true ) @Valid @RequestBody PartyAccountUpdate partyAccount) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}", PartyAccount.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 PartyAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a PartyAccount by ID", operationId = "retrievePartyAccount", description = "This operation retrieves a PartyAccount entity. Attribute selection is enabled for all first level attributes.", tags={ "partyAccount", }) + @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 = "/partyAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrievePartyAccount(@Parameter(description = "Identifier of the PartyAccount",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("{ \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}", PartyAccount.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 PartyAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/PartyAccountApiController.java b/src/main/java/org/etsi/osl/tmf/am666/api/PartyAccountApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..cab27fddae1de7b3bed8fd49a92c4c5e8b4fabb6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/PartyAccountApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am666.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Controller +@RequestMapping("/accountManagement/v4/") +public class PartyAccountApiController implements PartyAccountApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PartyAccountApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/RFC3339DateFormat.java b/src/main/java/org/etsi/osl/tmf/am666/api/RFC3339DateFormat.java new file mode 100644 index 0000000000000000000000000000000000000000..ea2d91e707d32a53dcf67329cc8a708282dd8ded --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/RFC3339DateFormat.java @@ -0,0 +1,41 @@ +/*- + * ========================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.am666.api; + +import java.text.FieldPosition; +import java.util.Date; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + + +public class RFC3339DateFormat extends ISO8601DateFormat { + + private static final long serialVersionUID = 1L; + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/SettlementAccountApi.java b/src/main/java/org/etsi/osl/tmf/am666/api/SettlementAccountApi.java new file mode 100644 index 0000000000000000000000000000000000000000..175d7bd0457891217c96529879d11bea593ce5c1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/SettlementAccountApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.am666.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.am666.model.SettlementAccount; +import org.etsi.osl.tmf.am666.model.SettlementAccountCreate; +import org.etsi.osl.tmf.am666.model.SettlementAccountUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Tag(name = "settlementAccount", description = "the settlementAccount API") +public interface SettlementAccountApi { + + Logger log = LoggerFactory.getLogger(SettlementAccountApi.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 SettlementAccount", operationId = "createSettlementAccount", description = "This operation creates a SettlementAccount entity.", tags={ "settlementAccount", }) + @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 = "/settlementAccount", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createSettlementAccount(@Parameter(description = "The SettlementAccount to be created" ,required=true ) @Valid @RequestBody SettlementAccountCreate settlementAccount) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}", SettlementAccount.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 SettlementAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a SettlementAccount", operationId = "deleteSettlementAccount", description = "This operation deletes a SettlementAccount entity.", tags={ "settlementAccount", }) + @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 = "/settlementAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteSettlementAccount(@Parameter(description = "Identifier of the SettlementAccount",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default SettlementAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find SettlementAccount objects", operationId = "listSettlementAccount", description = "This operation list or find SettlementAccount entities" , tags={ "settlementAccount", }) + @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 = "/settlementAccount", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listSettlementAccount(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}, { \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default SettlementAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a SettlementAccount", operationId = "patchSettlementAccount", description = "This operation updates partially a SettlementAccount entity.", tags={ "settlementAccount", }) + @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 = "/settlementAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchSettlementAccount(@Parameter(description = "Identifier of the SettlementAccount",required=true) @PathVariable("id") String id,@Parameter(description = "The SettlementAccount to be updated" ,required=true ) @Valid @RequestBody SettlementAccountUpdate settlementAccount) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}", SettlementAccount.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 SettlementAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a SettlementAccount by ID", operationId = "retrieveSettlementAccount", description = "This operation retrieves a SettlementAccount entity. Attribute selection is enabled for all first level attributes.", tags={ "settlementAccount", }) + @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 = "/settlementAccount/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveSettlementAccount(@Parameter(description = "Identifier of the SettlementAccount",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("{ \"defaultPaymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentPlan\" : [ { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" }, { \"numberOfPayments\" : 9, \"totalAmount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"planType\" : \"planType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"paymentMethod\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"paymentFrequency\" : \"paymentFrequency\", \"priority\" : 3, \"@schemaLocation\" : \"http://example.com/aeiou\", \"status\" : \"status\" } ], \"@type\" : \"@type\", \"accountType\" : \"accountType\", \"billStructure\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"format\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"cycleSpecification\" : { \"@referredType\" : \"@referredType\", \"billingPeriod\" : \"billingPeriod\", \"mailingDateOffset\" : 2, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"dateShift\" : 5, \"description\" : \"description\", \"creditDateOffset\" : 5, \"frequency\" : \"frequency\", \"billingDateShift\" : 6, \"@baseType\" : \"@baseType\", \"paymentDueDateOffset\" : 7, \"name\" : \"name\", \"chargeDateOffset\" : 1, \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"presentationMedia\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"description\" : \"description\", \"accountRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"financialAccount\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"accountBalance\" : { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"taxExemption\" : [ { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" }, { \"reason\" : \"reason\", \"@baseType\" : \"@baseType\", \"certificateNumber\" : \"certificateNumber\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"issuingJurisdiction\" : \"issuingJurisdiction\" } ], \"contact\" : [ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"contactName\" : \"contactName\", \"partyRoleType\" : \"partyRoleType\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"relatedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"name\" : \"name\", \"creditLimit\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"id\" : \"id\", \"href\" : \"href\", \"lastModified\" : \"2000-01-23T04:56:07.000+00:00\", \"state\" : \"state\", \"accountBalance\" : [ { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"amount\" : { \"unit\" : \"unit\", \"value\" : 0.8008282 }, \"balanceType\" : \"balanceType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"paymentStatus\" : \"paymentStatus\"}", SettlementAccount.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 SettlementAccountApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/am666/api/SettlementAccountApiController.java b/src/main/java/org/etsi/osl/tmf/am666/api/SettlementAccountApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..5ed7480bbbf2e1a843ad80a60a17dd250fccfc33 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/am666/api/SettlementAccountApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.am666.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:49:45.251+03:00") + +@Controller +@RequestMapping("/accountManagement/v4/") +public class SettlementAccountApiController implements SettlementAccountApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public SettlementAccountApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/cm629/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/cm629/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..230631aa49b44fd46bc6601d160fc412b9aae86e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.cm629.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-19T23:13:44.649+02:00") + +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/cm629/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/cm629/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..a17b218a54970aaa5ad24849817ccfa764b223bb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.cm629.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.languages.SpringCodegen", date = "2019-12-19T23:13:44.649+02:00") + +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/cm629/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/cm629/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..bf4b5be8a19e4b9a8f006fe07dd889d0a5b01770 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.cm629.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-19T23:13:44.649+02:00") + +@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/cm629/api/CustomerApi.java b/src/main/java/org/etsi/osl/tmf/cm629/api/CustomerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..f6566469a00b6b10db7cf0a2239ec14355f0603e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/CustomerApi.java @@ -0,0 +1,205 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.cm629.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.cm629.model.Customer; +import org.etsi.osl.tmf.cm629.model.CustomerCreate; +import org.etsi.osl.tmf.cm629.model.CustomerUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-19T23:13:44.649+02:00") + + +@Tag(name = "customer", description = "the customer API") +public interface CustomerApi { + + Logger log = LoggerFactory.getLogger(CustomerApi.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 Customer", operationId = "createCustomer", description = "This operation creates a Customer entity.", tags={ "customer", }) + @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 = "/customer", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createCustomer(@Parameter(description = "The Customer to be created" ,required=true ) @Valid @RequestBody CustomerCreate customer) { + + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + + @Operation(summary = "Deletes a Customer", operationId = "deleteCustomer", description = "This operation deletes a Customer entity.", tags={ "customer", }) + @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 = "/customer/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteCustomer(@Parameter(description = "Identifier of the Customer",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default CustomerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find Customer objects", operationId = "listCustomer", description = "This operation list or find Customer entities" , tags={ "customer", }) + @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 = "/customer", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listCustomer(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"creditProfile\" : [ { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"characteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"statusReason\" : \"statusReason\", \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"paymentMethod\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"engagedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : \"status\"}, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"creditProfile\" : [ { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"characteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"statusReason\" : \"statusReason\", \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"paymentMethod\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"engagedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : \"status\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default CustomerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a Customer", operationId = "patchCustomer", description = "This operation updates partially a Customer entity.", tags={ "customer", }) + @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 = "/customer/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchCustomer(@Parameter(description = "Identifier of the Customer",required=true) @PathVariable("id") String id,@Parameter(description = "The Customer to be updated" ,required=true ) @Valid @RequestBody CustomerUpdate customer) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"creditProfile\" : [ { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"characteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"statusReason\" : \"statusReason\", \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"paymentMethod\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"engagedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : \"status\"}", Customer.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 CustomerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a Customer by ID", operationId = "retrieveCustomer", description = "This operation retrieves a Customer entity. Attribute selection is enabled for all first level attributes.", tags={ "customer", }) + @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 = "/customer/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveCustomer(@Parameter(description = "Identifier of the Customer",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("{ \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"creditProfile\" : [ { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"characteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"statusReason\" : \"statusReason\", \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"paymentMethod\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"engagedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : \"status\"}", Customer.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 CustomerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/cm629/api/CustomerApiController.java b/src/main/java/org/etsi/osl/tmf/cm629/api/CustomerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..a50e73000db8fecada0cdca0a903f296db256274 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/CustomerApiController.java @@ -0,0 +1,172 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.cm629.api; + +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.cm629.model.Customer; +import org.etsi.osl.tmf.cm629.model.CustomerCreate; +import org.etsi.osl.tmf.cm629.model.CustomerUpdate; +import org.etsi.osl.tmf.cm629.service.CustomerRepoService; +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.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +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.etsi.osl.model.nfv.UserRoleType; +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-19T23:13:44.649+02:00") + +@Controller +@RequestMapping("/customerManagement/v4/") +public class CustomerApiController implements CustomerApi { + + + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + + @org.springframework.beans.factory.annotation.Autowired + public CustomerApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + + @Autowired + CustomerRepoService customerRepoService; + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity> listCustomer(@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) { + + + + + try { + Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); + SecurityContextHolder.setContext( (SecurityContext) attr ); + + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + log.info("authentication= " + authentication.toString()); + + log.info("principal ADMIN = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) )); + log.info("principal NFV_DEVELOPER = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_NFV_DEVELOPER.getValue() ) )); + log.info("principal EXPERIMENTER = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_EXPERIMENTER.getValue() ) )); + + if ( authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) ) ) { + + return new ResponseEntity>(customerRepoService.findAll(), HttpStatus.OK); + }else { + return new ResponseEntity>(HttpStatus.FORBIDDEN ); + } + + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity retrieveCustomer(@Parameter(description = "Identifier of the Customer",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + + + try { + Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); + SecurityContextHolder.setContext( (SecurityContext) attr ); + + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + log.info("authentication= " + authentication.toString()); + + log.info("principal ADMIN = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) )); + log.info("principal NFV_DEVELOPER = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_NFV_DEVELOPER.getValue() ) )); + log.info("principal EXPERIMENTER = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_EXPERIMENTER.getValue() ) )); + + if ( authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) ) ) { + + return new ResponseEntity< Customer >(customerRepoService.findById(id) , HttpStatus.OK); + }else { + return new ResponseEntity< Customer >(HttpStatus.FORBIDDEN ); + } + + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity< Customer >(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createCustomer( + @Parameter(description = "The Customer to be created", required = true) @Valid @RequestBody CustomerCreate customer) { + + try { + Customer c = customerRepoService.addCustomer(customer); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity patchCustomer(@Parameter(description = "Identifier of the Customer",required=true) @PathVariable("id") String id,@Parameter(description = "The Customer to be updated" ,required=true ) @Valid @RequestBody CustomerUpdate customer) { + + try { + Customer c = customerRepoService.updateCustomer(id, customer); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity deleteCustomer(@Parameter(description = "Identifier of the Customer",required=true) @PathVariable("id") String id) { + try { + + return new ResponseEntity( customerRepoService.deleteById( 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/cm629/api/CustomerApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/cm629/api/CustomerApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..33fb9845bdee8b2d3904ffdefe9c31f2b302aca6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/CustomerApiRouteBuilder.java @@ -0,0 +1,111 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.cm629.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.cm629.model.CustomerAttributeValueChangeEvent; +import org.etsi.osl.tmf.cm629.model.CustomerCreateEvent; +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 CustomerApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(CustomerApiRouteBuilder.class.getName()); + + @Value("${EVENT_CUSTOMER_CREATE}") + private String EVENT_CUSTOMER_CREATE = ""; + + @Value("${EVENT_CUSTOMER_CHANGED}") + private String EVENT_CUSTOMER_CHANGED = ""; + + @Autowired + private ProducerTemplate template; + + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + + } + + /** + * @param ce + * @param id + */ + public void publishEvent(Object ce, String objId) { + try { + String msgtopic = ""; + + Map map = new HashMap<>(); + map.put("objId", objId); + + if (ce instanceof CustomerCreateEvent) { + msgtopic = EVENT_CUSTOMER_CREATE; + ((CustomerCreateEvent) ce).setEventType(ce.getClass().getName()); + map.put("eventid", ((CustomerCreateEvent) ce).getEventId()); + logger.info("will send Event for type " + ((CustomerCreateEvent) ce).getEventType()); + } else if (ce instanceof CustomerAttributeValueChangeEvent) { + msgtopic = EVENT_CUSTOMER_CHANGED; + + ((CustomerAttributeValueChangeEvent) ce).setEventType(ce.getClass().getName()); + map.put("eventid", ((CustomerAttributeValueChangeEvent) ce).getEventId()); + logger.info("will send Event for type " + ((CustomerAttributeValueChangeEvent) ce).getEventType()); + } + + String apayload = toJsonString( ce ); + 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/cm629/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/cm629/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..18a6c6ab3c5486d5569c63cf9912a627401fa0ed --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.cm629.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.cm629.model.EventSubscription; +import org.etsi.osl.tmf.cm629.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-19T23:13:44.649+02:00") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener629", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener629", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/cm629/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/cm629/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..fa0e4a098bcf2411145351767241b751e6b444ad --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.cm629.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-19T23:13:44.649+02:00") + +@Controller("HubApiController629") +@RequestMapping("/customerManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/cm629/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/cm629/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..085d1db3d144b4c16c7a7d3d9408d00419a8810f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/ListenerApi.java @@ -0,0 +1,192 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.cm629.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.cm629.model.CustomerAttributeValueChangeEvent; +import org.etsi.osl.tmf.cm629.model.CustomerCreateEvent; +import org.etsi.osl.tmf.cm629.model.CustomerDeleteEvent; +import org.etsi.osl.tmf.cm629.model.CustomerStateChangeEvent; +import org.etsi.osl.tmf.cm629.model.EventSubscription; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-19T23:13:44.649+02:00") + +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity CustomerAttributeValueChangeEvent", operationId = "listenToCustomerAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification CustomerAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/customerAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCustomerAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CustomerAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CustomerCreateEvent", operationId = "listenToCustomerCreateEvent", description = "Example of a client listener for receiving the notification CustomerCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/customerCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCustomerCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CustomerCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CustomerDeleteEvent", operationId = "listenToCustomerDeleteEvent", description = "Example of a client listener for receiving the notification CustomerDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/customerDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCustomerDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CustomerDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CustomerStateChangeEvent", operationId = "listenToCustomerStateChangeEvent", description = "Example of a client listener for receiving the notification CustomerStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/customerStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCustomerStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CustomerStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/cm629/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/cm629/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..782a2d7a09a4a7221b6c2b0fb3eab4512ab98165 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/api/ListenerApiController.java @@ -0,0 +1,54 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.cm629.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-19T23:13:44.649+02:00") + +@Controller("ListenerApiController629") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/cm629/repo/CustomerRepository.java b/src/main/java/org/etsi/osl/tmf/cm629/repo/CustomerRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..0f8f9fdc2bb2e1458633ff8abcac58ff5f745539 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/repo/CustomerRepository.java @@ -0,0 +1,40 @@ +/*- + * ========================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.cm629.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.cm629.model.Customer; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface CustomerRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Iterable findByName( String name); + + List findByOrderByName(); + +} diff --git a/src/main/java/org/etsi/osl/tmf/cm629/service/CustomerRepoService.java b/src/main/java/org/etsi/osl/tmf/cm629/service/CustomerRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..0b06ba72c46ee985b88d45c4f51f1f670ed4d1ba --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/cm629/service/CustomerRepoService.java @@ -0,0 +1,152 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.cm629.service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.cm629.api.CustomerApiRouteBuilder; +import org.etsi.osl.tmf.cm629.model.Customer; +import org.etsi.osl.tmf.cm629.model.CustomerAttributeValueChangeEvent; +import org.etsi.osl.tmf.cm629.model.CustomerAttributeValueChangeEventPayload; +import org.etsi.osl.tmf.cm629.model.CustomerCreate; +import org.etsi.osl.tmf.cm629.model.CustomerCreateEvent; +import org.etsi.osl.tmf.cm629.model.CustomerCreateEventPayload; +import org.etsi.osl.tmf.cm629.model.CustomerUpdate; +import org.etsi.osl.tmf.cm629.repo.CustomerRepository; +import org.etsi.osl.tmf.pm632.model.ContactMedium; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.validation.Valid; + + +@Service +@Transactional +public class CustomerRepoService { + + @Autowired + CustomerRepository customerRepository; + + @Autowired + CustomerApiRouteBuilder customerApiRouteBuilder; + + public List findAll() { + return (List) this.customerRepository.findByOrderByName(); + } + + public Customer addCustomer(@Valid CustomerCreate customer) { + Customer c = new Customer(); + c = updateCustomerData(c, customer); + c = customerRepository.save(c); + raiseCustomerCreate( c ); + return c; + } + + public Customer updateCustomer(String id, @Valid CustomerUpdate customer) { + Customer c = this.findByUuid(id); + if ( c == null) { + return null; + } + c = this.updateCustomerData(c, customer); + c = this.customerRepository.save(c); + raiseCustomerChanged(c); + return c; + } + + private Customer findByUuid(String id) { + Optional optionalCat = this.customerRepository.findByUuid(id); + return optionalCat.orElse(null); + } + + private Customer updateCustomerData(Customer c, @Valid CustomerUpdate custUpd) { + + if ( custUpd.getName()!=null) { + c.setName( custUpd.getName() ); + } + + if ( custUpd.getEngagedParty() !=null) { + if ( ( c.getEngagedParty() ==null ) || ( c.getEngagedParty().getId() != custUpd.getEngagedParty().getId() ) ) { + // TODO: we msut load here the proper organization + c.setEngagedParty( new RelatedParty( custUpd.getEngagedParty() ) ); + } + } + + if ( custUpd.getContactMedium() !=null) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ContactMedium cmUpd : custUpd.getContactMedium()) { + //find by id and reload it here. + boolean idexists = false; + for (ContactMedium originalCm : c.getContactMedium()) { + if ( ( originalCm.getUuid()!=null ) && originalCm.getUuid().equals(cmUpd.getUuid() ) ) { + idexists = true; + idAddedUpdated.put( originalCm.getUuid(), true); + originalCm.updateWith( cmUpd ); + break; + } + } + if (!idexists) { + c.addContactMediumItem( cmUpd ); + } + + } + } + + return c; + } + + public Customer findById(String id) { + Optional c = this.customerRepository.findByUuid(id); + return c.orElse(null); + } + + public Void deleteById(String id) { + Optional c = this.customerRepository.findByUuid(id); + this.customerRepository.delete( c.get()); + return null; + } + + + private void raiseCustomerCreate(Customer c) { + + CustomerCreateEvent ce = new CustomerCreateEvent(); + CustomerCreateEventPayload event = new CustomerCreateEventPayload(); + event.setCustomer(c); + ce.setEvent(event); + customerApiRouteBuilder.publishEvent( ce, c.getId() ); + + } + + + private void raiseCustomerChanged(Customer c) { + + CustomerAttributeValueChangeEvent ce = new CustomerAttributeValueChangeEvent(); + CustomerAttributeValueChangeEventPayload event = new CustomerAttributeValueChangeEventPayload(); + event.setCustomer(c); + ce.setEvent(event); + customerApiRouteBuilder.publishEvent( ce, c.getId() ); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/ActiveMQComponentConfig.java b/src/main/java/org/etsi/osl/tmf/configuration/ActiveMQComponentConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..2bdc001822beb6f6543b087662350cf9dd643cea --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/ActiveMQComponentConfig.java @@ -0,0 +1,41 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.bugzilla + * %% + * 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.configuration; + +import org.apache.camel.component.activemq.ActiveMQComponent; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import jakarta.jms.ConnectionFactory; + +/** + * @author ctranoris + * + */ +@Configuration +public class ActiveMQComponentConfig { + + @Bean(name = "activemq") + public ActiveMQComponent createComponent(ConnectionFactory factory) { + ActiveMQComponent activeMQComponent = new ActiveMQComponent(); + activeMQComponent.setConnectionFactory(factory); + return activeMQComponent; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/ApiError.java b/src/main/java/org/etsi/osl/tmf/configuration/ApiError.java new file mode 100644 index 0000000000000000000000000000000000000000..d451b044e87c6d31693e9718a5c0f7fb9e8550b3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/ApiError.java @@ -0,0 +1,46 @@ +package org.etsi.osl.tmf.configuration; + +import java.time.LocalDateTime; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import org.springframework.http.HttpStatus; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +@Data +@EqualsAndHashCode(callSuper = false) +@AllArgsConstructor +public class ApiError { + private HttpStatus status; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss") + private LocalDateTime timestamp; + private String message; + private String debugMessage; + private List subErrors; + + private ApiError() { + timestamp = LocalDateTime.now(); + } + + ApiError(HttpStatus status) { + this(); + this.status = status; + } + + ApiError(HttpStatus status, Throwable ex) { + this(); + this.status = status; + this.message = "Unexpected error"; + this.debugMessage = ex.getLocalizedMessage(); + } + + ApiError(HttpStatus status, String message, Throwable ex) { + this(); + this.status = status; + this.message = message; + this.debugMessage = ex.getLocalizedMessage(); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/ApiSubError.java b/src/main/java/org/etsi/osl/tmf/configuration/ApiSubError.java new file mode 100644 index 0000000000000000000000000000000000000000..482949b0d204cfabc855f22d15cca7dfde3f0c53 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/ApiSubError.java @@ -0,0 +1,5 @@ +package org.etsi.osl.tmf.configuration; + +abstract class ApiSubError { + +} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/ApiValidationError.java b/src/main/java/org/etsi/osl/tmf/configuration/ApiValidationError.java new file mode 100644 index 0000000000000000000000000000000000000000..a3f3926f9b97a7df6d95062563fa1e2ecc1ea76f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/ApiValidationError.java @@ -0,0 +1,20 @@ +package org.etsi.osl.tmf.configuration; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = false) +@AllArgsConstructor +class ApiValidationError extends ApiSubError { + private String object; + private String field; + private Object rejectedValue; + private String message; + + ApiValidationError(String object, String message) { + this.object = object; + this.message = message; + } +} \ No newline at end of file diff --git a/src/main/java/org/etsi/osl/tmf/configuration/BCryptPasswordEncoderConfig.java b/src/main/java/org/etsi/osl/tmf/configuration/BCryptPasswordEncoderConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..2e92543856d4ca365b3d46bb81d92165ed1b31ca --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/BCryptPasswordEncoderConfig.java @@ -0,0 +1,35 @@ +/*- + * ========================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.configuration; + + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; + + +@Configuration +public class BCryptPasswordEncoderConfig { + + @Bean + public BCryptPasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/CustomClaimVerifier.java b/src/main/java/org/etsi/osl/tmf/configuration/CustomClaimVerifier.java new file mode 100644 index 0000000000000000000000000000000000000000..2fde2bbea775ab8a1f2a76ce78373b3dc9a8ff41 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/CustomClaimVerifier.java @@ -0,0 +1,38 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.portal.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.configuration; + +public class CustomClaimVerifier { + +} + + +//import org.springframework.security.oauth2.common.exceptions.InvalidTokenException; +//import org.springframework.security.oauth2.provider.token.store.JwtClaimsSetVerifier; +// +//public class CustomClaimVerifier implements JwtClaimsSetVerifier { +// @Override +// public void verify(Map claims) throws InvalidTokenException { +// final String username = (String) claims.get("user_name"); +// if ((username == null) || (username.length() == 0)) { +// throw new InvalidTokenException("user_name claim is empty"); +// } +// } +//} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/HomeController.java b/src/main/java/org/etsi/osl/tmf/configuration/HomeController.java new file mode 100644 index 0000000000000000000000000000000000000000..0ae32ff5f32b0b67d3db536af0795080b3597993 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/HomeController.java @@ -0,0 +1,35 @@ +/*- + * ========================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.configuration; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Home redirection to swagger api documentation + */ +@Controller +public class HomeController { + @RequestMapping(value = "/") + public String index() { + System.out.println("swagger-ui.html"); + return "redirect:swagger-ui.html"; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/MethodSecurityConfig.java b/src/main/java/org/etsi/osl/tmf/configuration/MethodSecurityConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..1907f557e65d0056d943e19066dc07e7ab1fefcb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/MethodSecurityConfig.java @@ -0,0 +1,37 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.portal.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.configuration; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration; + +@Configuration +@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true) +public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration { + +// +// @Override +// protected MethodSecurityExpressionHandler createExpressionHandler() { +// return new OAuth2MethodSecurityExpressionHandler(); +// } + + +} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/RestAuthenticationEntryPoint.java b/src/main/java/org/etsi/osl/tmf/configuration/RestAuthenticationEntryPoint.java new file mode 100644 index 0000000000000000000000000000000000000000..2993c1d08d44935dee405afc0db3e7fc179945cb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/RestAuthenticationEntryPoint.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.configuration; + +import java.io.IOException; + +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +@Component +public final class RestAuthenticationEntryPoint implements AuthenticationEntryPoint { + + /** + * From https://www.baeldung.com/securing-a-restful-web-service-with-spring-security + * + * In a standard web application, the authentication process may + * automatically trigger when an un-authenticated client tries to access a + * secured resource. This process usually redirects to a login page so that + * the user can enter credentials. However, for a REST Web Service,this + * behaviour doesn’t make much sense. We should be able to authenticate only + * by a request to the correct URI and if the user is not authenticated all + * requests should simply fail with a 401 UNAUTHORIZED status code. Spring + * Security handles this automatic triggering of the authentication process + * with the concept of an Entry Point – this is a required part of the + * configuration, and can be injected via the authenticationEntryPoint + * method. + */ + + @Override + public void commence(HttpServletRequest request, HttpServletResponse response, + AuthenticationException authException) throws IOException { + + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/RestExceptionHandler.java b/src/main/java/org/etsi/osl/tmf/configuration/RestExceptionHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..42aac3140aaa5105f903d2b9c271f92adfa2a92c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/RestExceptionHandler.java @@ -0,0 +1,32 @@ +package org.etsi.osl.tmf.configuration; + +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +@Order(Ordered.HIGHEST_PRECEDENCE) +@ControllerAdvice +public class RestExceptionHandler extends ResponseEntityExceptionHandler { + + @Override + protected ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex, + HttpHeaders headers, HttpStatusCode status, WebRequest request) { + String error = "Malformed JSON request"; + ApiError apiError = new ApiError(HttpStatus.BAD_REQUEST, error, ex); + return new ResponseEntity(apiError, apiError.getStatus()); + } + + + private ResponseEntity buildResponseEntity(ApiError apiError) { + return new ResponseEntity<>(apiError, apiError.getStatus()); + } + // other exception handlers below + +} \ No newline at end of file diff --git a/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java b/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..239be290194fb3da0c4bd4c908d742c492c08ef9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java @@ -0,0 +1,894 @@ +/*- +7 * ========================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.configuration; + +import org.springdoc.core.customizers.OpenApiCustomizer; +import org.springdoc.core.models.GroupedOpenApi; +import org.springdoc.core.utils.SpringDocUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.ExternalDocumentation; +import io.swagger.v3.oas.models.SpecVersion; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityRequirement; + +/** + * For implementing the callback and events, it might be useful to check the DDD pattern: https://www.baeldung.com/spring-data-ddd + * + * + * @author ctranoris + * + */ +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-08-29T19:18:54.771Z") + +@Configuration +@SecurityScheme(name = "security_auth", type = SecuritySchemeType.OAUTH2, bearerFormat = "JWT", +scheme = "bearer", +flows = @OAuthFlows(authorizationCode = @OAuthFlow( + authorizationUrl = "${springdoc.oAuthFlow.authorizationUrl}" + , tokenUrl = "${springdoc.oAuthFlow.tokenUrl}", scopes = { + @OAuthScope(name = "read", description = "read scope"), + @OAuthScope(name = "write", description = "write scope") }))) +public class SwaggerDocumentationConfig { + + /** + * TMF 633 Service Catalog Management + * @return + */ + @Bean + public OpenApiCustomizer scm633OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 633 Service Catalog Management") + .description("## TMF API Reference: TMF633 - Service Catalog Management" + + "### Release : 18.5-December 2018 Service Catalog API is one of Catalog Management API Family. Service Catalog API goal is to provide a catalog of services. " + + "### Resource - serviceCatalog " + + "### Operations Service Catalog API performs the following operations on the resource : - 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 (for administration purposes) - Manage notification of events") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi scm633(){ + + 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-633-ServiceCatalogManagement-v4.0.0") + .addOpenApiCustomizer( this.scm633OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.scm633.api") + .build(); + + } + + + + + /** + * TMF 620 Product Catalog Management + * @return + */ + @Bean + public OpenApiCustomizer pcm620penAPI() { + + + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 620 Product Catalog Management") + .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"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + + } + + + @Bean + public GroupedOpenApi pcm620() { + + 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-620-ProductCatalogManagement-v4.0.0") + .addOpenApiCustomizer( this.pcm620penAPI() ) + .packagesToScan("org.etsi.osl.tmf.pcm620.api") + .build(); + + } + + + + /** + * TMF 622 Product Ordering + * @return + */ + + + @Bean + public OpenApiCustomizer scm622OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 622 Product Ordering") + .description( "TMF API Reference : TMF 622 - Product Ordering Management**\\\\n\\\\n**" + + "Release : 19.0 - June 2019**\\\\n\\\\nThe Product Ordering API provides a standardized mechanism for placing a product order with all of the necessary order parameters.") + .version("1.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi scm622(){ + + 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-622-ProductOrderingManagement-v4.0.0") + .addOpenApiCustomizer( this.scm622OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.po622.api") + .build(); + + } + + + /** + * TMF 634 Resource Catalog Management + * @return + */ + + + @Bean + public OpenApiCustomizer rcm634OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 634 Resource Catalog Management") + .description("## TMF API Reference: TMF 634 Resource Catalog Management") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi rcm634(){ + + return GroupedOpenApi.builder() + .group("tmf-api-634-ResourceCatalogManagement-v4.0.0") + .addOpenApiCustomizer( this.rcm634OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.rcm634.api") + .build(); + + } + + + + /** + * TMF 638 Service Inventory Management + * @return + */ + + + @Bean + public OpenApiCustomizer sim638OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 638 Service Inventory Management") + .description("## TMF API Reference : TMF 638 - Service Inventory Management v4 Release 18.5 - Dec 2018 The intent of this API is to provide a consistent/standardized mechanism to query and manipulate the Service inventory. The Service Inventory API can be used to query the service instances for a customer via Self Service Portal or the Call Centre operator can query the service instances on behalf of the customer while a customer may have a complaint or a query. Note: Only the CustomerFacingServices instances will be presented to the customer. The Service Inventory API can be called by the Service Order Management to create a new service instance/ update an existing service instance in the Service Inventory. ### Service resource Service is an abstract base class for defining the Service hierarchy. All Services are characterized as either being possibly visible and usable by a Customer or not. This gives rise to the two subclasses of Service: CustomerFacingService and ResourceFacingService. ### Service Inventory API performs the following operations on service : - Retrieve a service or a collection of services depending on filter criteria - Partial update of a service (including updating rules) - Create a service (including default values and creation rules and for administration users only) - Delete a service (for administration users only) - Notification of events on service Copyright (c)TM Forum 2018. All Rights Reserved.") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi sim638(){ + + 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-638-ServiceInventoryManagement-v4.0.0") + .addOpenApiCustomizer( this.sim638OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.sim638.api") + .build(); + + } + + + + + /** + * TMF 641 - Service Ordering Management + * @return + */ + + + @Bean + public OpenApiCustomizer so641OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 641 - Service Ordering Management ") + .description("## TMF API Reference : TMF 641 - Service Ordering Management ## Release : 18.5 - Dec 2018 The Service Order API provides a standardized mechanism for managing Service Order, a type of order which can be used to place an order between a customer and a service provider or between a service provider and a partner and vice versa. ### Service Order resource A service order will describe a list of service order items. A service order item references an action on an existing or future service. By service we designed Customer Facing Service (CFS) as well as Resource Facing Service (RFS). From a component perspective, a service order should be available - from a Service Orchestration Component (and it could mix CFS and RFS) - from an Infrastructure Control & Management component (and it would have only RFS) ### Service Order API performs the following operations on service order : - Retrieval of a service order or a collection of service orders depending on filter criteria - Partial update of a service order (including updating rules) - Creation of a service order (including default values and creation rules) - Deletion of service order (for administration purposes) - Notification of events on Service order Copyright © TM Forum 2018. All Rights Reserved") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi so641(){ + + 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-641-ServiceOrdering-v4.0.0") + .addOpenApiCustomizer( this.so641OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.so641.api") + .build(); + + } + + + /** + * TMF 657 - Service Quality Management + * @return + */ + + + @Bean + public OpenApiCustomizer sqm657OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 657 - Service Quality Management") + .description("This is Swagger UI environment generated for the TMF Service Quality Management specification") + .version("2.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi sqm657(){ + + 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-657-ServiceQualityManagement-v2.0") + .addOpenApiCustomizer( this.sqm657OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.sqm657.api") + .build(); + + } + + + + /** + * TMF 669 - Party Role Management + * @return + */ + + + @Bean + public OpenApiCustomizer prm669OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 669 - Party Role Management") + .description("This is Swagger UI environment generated for the TMF Party Role Management specification") + .version("2.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi prm669(){ + + 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-669-Party Role Management-v4.0") + .addOpenApiCustomizer( this.prm669OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.prm669.api") + .build(); + + } + + + + /** + * TMF 632 - Party + * @return + */ + + + @Bean + public OpenApiCustomizer pm632OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + + .info(new Info().title("TMF 632 - API Party") + .description("## TMF API Reference : TMF 632 - Party ### Release : 19.0 The party API provides standardized mechanism for party management such as creation, update, retrieval, deletion and notification of events. Party can be an individual or an organization that has any kind of relation with the enterprise. Party is created to record individual or organization information before the assignment of any role. For example, within the context of a split billing mechanism, Party API allows creation of the individual or organization that will play the role of 3 rd payer for a given offer and, then, allows consultation or update of his information. ### Resources - Organization - Individual - Hub Party API performs the following operations : - Retrieve an organization or an individual - Retrieve a collection of organizations or individuals according to given criteria - Create a new organization or a new individual - Update an existing organization or an existing individual - Delete an existing organization or an existing individual - Notify events on organizatin or individual") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + +@Bean + public GroupedOpenApi pm632(){ + + 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-632-PartyManagement-v4.0.0") + .addOpenApiCustomizer( this.pm632OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.pm632.api") + .build(); + + } + + + /** + * TMF 651 - Agreement Management + * @return + */ + + + @Bean + public OpenApiCustomizer am651OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info().title("TMF 651 - Agreement Management ") + .description("This is Swagger UI environment generated for the TMF Agreement Management specification") + .version("2.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi am651(){ + + 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-651-Agreement Management-v2.0") + .addOpenApiCustomizer( this.am651OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.am651.api") + .build(); + + } + + + + + /** + * TMF 652 Resource Order Management-v4.0.0 + * @return + */ + + + @Bean + public OpenApiCustomizer rom652OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 652 Resource Order Management-v4.0.0") + .description("This is Swagger UI environment generated for the TMF 652-Resource Order Management-v4.0.0 specification") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi rom652(){ + + 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-652-ResourceOrderManagement-v4.0.0") + .addOpenApiCustomizer( this.rom652OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.ro652.api") + .build(); + + } + + + /** + * TMF 652 Resource Order Management-v4.0.0 + * @return + */ + + + @Bean + public OpenApiCustomizer am666OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 666 Account Management") + .description("This is Swagger UI environment generated for the TMF Account Management specification") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi am666(){ + + 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-666-Account Management-v4.0.0") + .addOpenApiCustomizer( this.am666OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.am666.api") + .build(); + + } + + + /** + *TMF 639 API Resource Inventory Management + * @return + */ + + + @Bean + public OpenApiCustomizer ri639penAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 639 API Resource Inventory Management") + .description("## TMF API Reference: TMF639 - Resource Inventory ### Release : 19.5 - December 2019 Resource Inventory API goal is to provide the ability to manage Resources. ### Operations Resource Inventory 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 (for administration purposes) - Manage notification of events") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi ri639(){ + + 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-639-Resource Inventory Management-v4.0.0") + .addOpenApiCustomizer( this.ri639penAPI() ) + .packagesToScan("org.etsi.osl.tmf.ri639.api") + .build(); + + } + + + + + /** + *TMF 640 API Service Activation and Configuration + * @return + */ + + + @Bean + public OpenApiCustomizer sac640penAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 640 API Service Activation and Configuration") + .description("## TMF API Reference: TMF640 - Service Activation and Configuration ### Release : 18.5 - December 2018 Service Activation and Configuration API goal is to provide the ability to activate and configure Services. ### Operations Service Activation and Configuration 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 (for administration purposes) - Manage notification of events") +// .version("3.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi sac640(){ + + 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-640-Service Activation and Configuration-v3.0.0") + .addOpenApiCustomizer( this.sac640penAPI() ) + .packagesToScan("org.etsi.osl.tmf.sac640.api") + .build(); + + } + + + + /** + *tmf-api-629-Customer Management-v4.0.0 + * @return + */ + + + @Bean + public OpenApiCustomizer cm629penAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 629 Customer Management-v4.0.0") + + .description("This is Swagger UI environment generated for the TMF Customer Management specification") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi cm629(){ + + 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-629-Customer Management-v4.0.0") + .addOpenApiCustomizer( this.cm629penAPI() ) + .packagesToScan("org.etsi.osl.tmf.cm629.api") + .build(); + + } + + + + + /** + * TMF 691 Federated ID + * @return + */ + + + @Bean + public OpenApiCustomizer fi691OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 691 Federated ID") + .description("This is Swagger UI environment generated for the TMF FederatedID specification") + .version("1.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi fi691(){ + + 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-691-Federated Identity-v1.0") + .addOpenApiCustomizer( this.fi691OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.fi691.api") + .build(); + + } + + + + /** + * TMF 642 Alarm Management + * @return + */ + + + @Bean + public OpenApiCustomizer am642OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 642 Alarm Management") + .description("## TMF API Reference: TMF642 Alarm Management API") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi am642(){ + + 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-642-Alarm Management-v4.0.0") + .addOpenApiCustomizer( this.am642OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.am642.api") + .build(); + + } + + + + /** + * TMF 653 Service Test Management + * @return + */ + + + @Bean + public OpenApiCustomizer stm653OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 653 Service Test Management") + .description("## TMF API Reference: TMF653 - Service Test Management ### Release : 20.0 - April 2020 Service Test Management API goal is to provide the ability to manage tests of provisioned Services. ### Resource - ServiceTest - ServiceTestSpecification ### Operations Service Test Management 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 (for administration purposes) - Manage notification of events") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi stm653(){ + + 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-653-Service Test Management-v4.0.0") + .addOpenApiCustomizer( this.stm653OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.stm653.api") + .build(); + + } + /** + * TMF 674 Geographic Site Management + * @return + */ + + + @Bean + public OpenApiCustomizer gsm674OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 674 Geographic Site Management") + .description("## TMF API Reference: TMF674 - Geographic Site Management ") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("TMF API Tables") + .url("https://www.tmforum.org/oda/open-apis/table")); + } + + @Bean + public GroupedOpenApi gsm674(){ + + 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-674-Geographic Site Management-v4.0.0") + .addOpenApiCustomizer( this.gsm674OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.gsm674.api") + .build(); + + } + + + /** + * LCM Rules + * @return + */ + + + @Bean + public OpenApiCustomizer lcmOpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("Openslice LCMRules specification API") + .description("This is Swagger UI environment for LCM Rules") + .version("4.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("Openslice") + .url("http://openslice.io")); + } + + @Bean + public GroupedOpenApi lcm(){ + + 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("OpensliceLCMRulesspecificationAPI") + .addOpenApiCustomizer( this.lcmOpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.lcm.api") + .build(); + + } + + + /** + * LCM Rules + * @return + */ + + + @Bean + public OpenApiCustomizer rpm685OpenAPI() { + return openApi -> openApi + .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) + .info(new Info() + .title("TMF 685 Resource Pool Management") + .description("## TMF API Reference: TMF685 Resource Pool Management ### Release : 18.0 " + + "Resources that can\r\n" + + "be reserved are only\r\n" + + "in one pool.\r\n" + + "IF a resource is not found in a pool is infinite.\r\n" + + "When one makes a reservation for a resource, then we check availability of \r\n" + + "this resource on that specific dates\r\n" + + "if checkAvailability returns the resource\r\n" + + "then it can be reserved on that specific requested date and time.") + .version("1.0.0") + .license(new License() + .name("Apache 2.0") + .url("http://openslice.io"))) + .externalDocs(new ExternalDocumentation() + .description("Openslice") + .url("http://openslice.io")); + } + + @Bean + public GroupedOpenApi rpm685(){ + + 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-685 ResourcePoolManagement") + .addOpenApiCustomizer( this.rpm685OpenAPI() ) + .packagesToScan("org.etsi.osl.tmf.rpm685.api") + .build(); + + } + + +// @Bean +// public SecurityConfiguration security() { +// return SecurityConfigurationBuilder.builder() +// +// .realm("openslice") +// .clientId(CLIENT_ID) +// .clientSecret(CLIENT_SECRET) +// .appName("oauthtoken") +// .scopeSeparator(" ") +// .build(); +// } +// +// private SecurityScheme securityScheme() { +// GrantType grantType = new AuthorizationCodeGrantBuilder() +// .tokenEndpoint(new TokenEndpoint(AUTH_SERVER + "/protocol/openid-connect/token", "oauthtoken")) +// .tokenRequestEndpoint( +// new TokenRequestEndpoint(AUTH_SERVER + "/protocol/openid-connect/auth", CLIENT_ID, CLIENT_SECRET)) +// .build(); +// +// SecurityScheme oauth = new OAuthBuilder().name("spring_oauth") +// .grantTypes(Arrays.asList(grantType)) +// .scopes(Arrays.asList(scopes())) +// .build(); +// return oauth; +// } +// +// private SecurityContext securityContext() { +// return SecurityContext.builder() +// .securityReferences( +// Arrays.asList(new SecurityReference("spring_oauth", scopes()))) +// .forPaths(PathSelectors.regex("/.*")) +// .build(); +// } +// +// private AuthorizationScope[] scopes() { +// AuthorizationScope[] scopes = { +// new AuthorizationScope("read", "for read operations"), +// new AuthorizationScope("write", "for write operations"), +// new AuthorizationScope("admin", "Access admin API"), +// new AuthorizationScope("openapi", "Access openapi API") }; +// return scopes; +// } +// + +} diff --git a/src/main/java/org/etsi/osl/tmf/configuration/WebSecurityConfigKeycloak.java b/src/main/java/org/etsi/osl/tmf/configuration/WebSecurityConfigKeycloak.java new file mode 100644 index 0000000000000000000000000000000000000000..7d8e0b04821c26e7a1072d5f95ff950eeb482b24 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/configuration/WebSecurityConfigKeycloak.java @@ -0,0 +1,354 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.portal.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.configuration; + +import java.net.URL; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.PathNotFoundException; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.core.convert.converter.Converter; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.security.authentication.AbstractAuthenticationToken; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.AuthenticationManagerResolver; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.oauth2.jwt.Jwt; +import org.springframework.security.oauth2.jwt.JwtClaimNames; +import org.springframework.security.oauth2.jwt.JwtDecoder; +import org.springframework.security.oauth2.jwt.JwtDecoders; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; +import org.springframework.security.oauth2.server.resource.authentication.JwtIssuerAuthenticationManagerResolver; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.stereotype.Component; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; + +import jakarta.servlet.http.HttpServletRequest; +import lombok.Data; +import lombok.RequiredArgsConstructor; + +@Configuration +@EnableWebSecurity +@EnableMethodSecurity +@Profile("!testing") +public class WebSecurityConfigKeycloak { + + @Bean + SecurityFilterChain filterChain(HttpSecurity http, ServerProperties serverProperties, + @Value("${origins:[]}") String[] origins, @Value("${permit-all:[]}") String[] permitAll, + AuthenticationManagerResolver authenticationManagerResolver) throws Exception { + + http.oauth2ResourceServer(oauth2 -> oauth2.authenticationManagerResolver(authenticationManagerResolver)); + + // Enable and configure CORS + http.cors(cors -> cors.configurationSource(corsConfigurationSource(origins))); + + // State-less session (state in access-token only) + http.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS)); + + // Disable CSRF because of state-less session-management + http.csrf(csrf -> csrf.disable()); + + // Return 401 (unauthorized) instead of 302 (redirect to login) when + // authorization is missing or invalid + http.exceptionHandling(eh -> eh.authenticationEntryPoint((request, response, authException) -> { + response.addHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"Restricted Content\""); + response.sendError(HttpStatus.UNAUTHORIZED.value(), HttpStatus.UNAUTHORIZED.getReasonPhrase()); + })); + + // If SSL enabled, disable http (https only) + if (serverProperties.getSsl() != null && serverProperties.getSsl().isEnabled()) { + http.requiresChannel(channel -> channel.anyRequest().requiresSecure()); + } + + // @formatter:off + http.authorizeHttpRequests(requests -> requests + //.requestMatchers(permitAll).permitAll() + .anyRequest().permitAll()); + // @formatter:on + + return http.build(); + } + + private UrlBasedCorsConfigurationSource corsConfigurationSource(String[] origins) { + final var configuration = new CorsConfiguration(); + configuration.setAllowedOrigins(Arrays.asList(origins)); + configuration.setAllowedMethods(List.of("*")); + configuration.setAllowedHeaders(List.of("*")); + configuration.setExposedHeaders(List.of("*")); + configuration.setAllowCredentials(true); + + final var source = new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", configuration); + return source; + } + + @Data + @Configuration + @ConfigurationProperties(prefix = "spring-addons") + static class SpringAddonsProperties { + private IssuerProperties[] issuers = {}; + + @Data + static class IssuerProperties { + private URL uri; + + @NestedConfigurationProperty + private ClaimMappingProperties[] claims; + + private String usernameJsonPath = JwtClaimNames.SUB; + + @Data + static class ClaimMappingProperties { + private String jsonPath; + private CaseProcessing caseProcessing = CaseProcessing.UNCHANGED; + private String prefix = ""; + + static enum CaseProcessing { + UNCHANGED, TO_LOWER, TO_UPPER + } + } + } + + public IssuerProperties get(URL issuerUri) throws MisconfigurationException { + final var issuerProperties = Stream.of(issuers).filter(iss -> issuerUri.toString().equals(iss.getUri().toString())).toList(); + if (issuerProperties.size() == 0) { + throw new MisconfigurationException( + "Missing authorities mapping properties for %s".formatted(issuerUri.toString())); + } + if (issuerProperties.size() > 1) { + throw new MisconfigurationException( + "Too many authorities mapping properties for %s".formatted(issuerUri.toString())); + } + return issuerProperties.get(0); + } + + static class MisconfigurationException extends RuntimeException { + private static final long serialVersionUID = 5887967904749547431L; + + public MisconfigurationException(String msg) { + super(msg); + } + } + } + + @RequiredArgsConstructor + static class JwtGrantedAuthoritiesConverter implements Converter> { + private final SpringAddonsProperties.IssuerProperties properties; + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Collection convert(Jwt jwt) { + + + return Stream.of(properties.claims).flatMap(claimProperties -> { + Object claim; + try { + claim = JsonPath.read(jwt.getClaims(), claimProperties.jsonPath); + } catch (PathNotFoundException e) { + claim = null; + } + if (claim == null) { + return Stream.empty(); + } + if (claim instanceof String claimStr) { + return Stream.of(claimStr.split(",")); + } + if (claim instanceof String[] claimArr) { + return Stream.of(claimArr); + } + if (Collection.class.isAssignableFrom(claim.getClass())) { + final var iter = ((Collection) claim).iterator(); + if (!iter.hasNext()) { + return Stream.empty(); + } + final var firstItem = iter.next(); + if (firstItem instanceof String) { + return (Stream) ((Collection) claim).stream(); + } + if (Collection.class.isAssignableFrom(firstItem.getClass())) { + return (Stream) ((Collection) claim).stream() + .flatMap(colItem -> ((Collection) colItem).stream()).map(String.class::cast); + } + } + return Stream.empty(); + }) /* Insert some transformation here if you want to add a prefix like "ROLE_" or force upper-case authorities */ + + .map(s -> "ROLE_" + s) + .map(SimpleGrantedAuthority::new) + .map(GrantedAuthority.class::cast).toList(); + } + } + + @Component + @RequiredArgsConstructor + static class SpringAddonsJwtAuthenticationConverter implements Converter { + private final SpringAddonsProperties springAddonsProperties; + + @Override + public AbstractAuthenticationToken convert(Jwt jwt) { + final var issuerProperties = springAddonsProperties.get(jwt.getIssuer()); + final var authorities = new JwtGrantedAuthoritiesConverter(issuerProperties).convert(jwt); + final String username = JsonPath.read(jwt.getClaims(), issuerProperties.getUsernameJsonPath()); + return new JwtAuthenticationToken(jwt, authorities, username); + } + } + + @Bean + AuthenticationManagerResolver authenticationManagerResolver( + SpringAddonsProperties addonsProperties, SpringAddonsJwtAuthenticationConverter authenticationConverter) { + final Map authenticationProviders = Stream.of(addonsProperties.getIssuers()) + .map(SpringAddonsProperties.IssuerProperties::getUri).map(URL::toString) + .collect(Collectors.toMap(issuer -> issuer, + issuer -> authenticationProvider(issuer, authenticationConverter)::authenticate)); + return new JwtIssuerAuthenticationManagerResolver( + (AuthenticationManagerResolver) authenticationProviders::get); + } + + JwtAuthenticationProvider authenticationProvider(String issuer, + SpringAddonsJwtAuthenticationConverter authenticationConverter) { + JwtDecoder decoder = JwtDecoders.fromIssuerLocation(issuer); + var provider = new JwtAuthenticationProvider(decoder); + provider.setJwtAuthenticationConverter(authenticationConverter); + return provider; + } +} + +//@Configuration +//@EnableWebSecurity +//@ComponentScan(basePackageClasses = KeycloakSecurityComponents.class) +//@Profile("!testing") +//public class WebSecurityConfigKeycloak extends KeycloakWebSecurityConfigurerAdapter { +// +// +// +// @Autowired +// private RestAuthenticationEntryPoint restAuthenticationEntryPoint; +// +// @Autowired +// public void configureGlobal( +// AuthenticationManagerBuilder auth) throws Exception { +// +// KeycloakAuthenticationProvider keycloakAuthenticationProvider +// = keycloakAuthenticationProvider(); +// keycloakAuthenticationProvider.setGrantedAuthoritiesMapper( +// new SimpleAuthorityMapper()); +// auth.authenticationProvider(keycloakAuthenticationProvider); +// } +// +// @Bean +// public KeycloakSpringBootConfigResolver KeycloakConfigResolver() { +// return new KeycloakSpringBootConfigResolver(); +// } +// +// @Bean +// @Override +// protected SessionAuthenticationStrategy sessionAuthenticationStrategy() { +// return new RegisterSessionAuthenticationStrategy( +// new SessionRegistryImpl()); +// } +// +//// +//// @Override +//// @Bean("authenticationManager") +//// public AuthenticationManager authenticationManagerBean() throws Exception { +//// return super.authenticationManagerBean(); +//// } +// +// //see also https://www.baeldung.com/securing-a-restful-web-service-with-spring-security +// @Override +// protected void configure(final HttpSecurity http) throws Exception { +// // @formatter:off +// http.authorizeRequests() +//// .antMatchers("/sessions/**").permitAll() +//// .antMatchers("/register/**").permitAll() +//// //.antMatchers("/sessions/logout").permitAll() +//// .antMatchers("/categories/**").permitAll() +//// .antMatchers("/experiments/**").permitAll() +//// .antMatchers("/vxfs/**").permitAll() +//// .antMatchers("/login").permitAll() +//// .antMatchers("/images/**").permitAll() +//// .antMatchers("/packages/**").permitAll() +//// .antMatchers("/testweb/**").permitAll() +//// .antMatchers("/oauth/token/revokeById/**").permitAll() +//// .antMatchers("/tokens/**").permitAll() +//// .antMatchers("/actuator/**").permitAll() +//// .antMatchers("/swagger/**").permitAll() +//// .antMatchers("/v2/**").permitAll() +//// .antMatchers("/swagger-ui.html").permitAll() +//// .antMatchers("/webjars/**").permitAll() +//// .antMatchers("/swagger-resources/**").permitAll() +// //.antMatchers("/admin/**").permitAll()//.hasAnyRole("admin","user","ROLE_admin","ROLE_user") +// +// .anyRequest().permitAll() +// //.and().formLogin().permitAll() +// .and().csrf().disable() +// //.cors().and().csrf().disable() // we use the filter..see below +// .exceptionHandling() +// .authenticationEntryPoint(restAuthenticationEntryPoint) +// .and() +// .logout(); +// // @formatter:on +// } +// +// +// @Bean +// public FilterRegistrationBean corsFilter() { +// +// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); +// CorsConfiguration config = new CorsConfiguration(); +// config.setAllowCredentials(true); +// config.setAllowedOriginPatterns(Collections.singletonList("*")); +// config.addAllowedHeader("*"); +// config.addAllowedMethod("*"); +// config.addAllowedOriginPattern( "*" ); +// source.registerCorsConfiguration("/**", config); +// FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source)); +// +// bean.setOrder(0); +// +// return bean; +// +// } +// +// +// +//} diff --git a/src/main/java/org/etsi/osl/tmf/fi691/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/fi691/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..542b7158be2a9907816d1ec7a21df3b0901f92f7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/fi691/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.fi691.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-20T00:39:05.842+02:00") + +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/fi691/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/fi691/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..6cfee5145f708e4fa791ef5fd3ea16a268ce5220 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/fi691/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.fi691.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.languages.SpringCodegen", date = "2019-12-20T00:39:05.842+02:00") + +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/fi691/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/fi691/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..87ff941c492e6266fc71aaf19708765189d79112 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/fi691/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.fi691.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-20T00:39:05.842+02:00") + +@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/fi691/api/UserinfoApi.java b/src/main/java/org/etsi/osl/tmf/fi691/api/UserinfoApi.java new file mode 100644 index 0000000000000000000000000000000000000000..df7eff64ad3bd463a7c381fe48d64002af281955 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/fi691/api/UserinfoApi.java @@ -0,0 +1,95 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.fi691.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.fi691.model.UserInfoType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestHeader; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-20T00:39:05.842+02:00") + +@Tag(name = "userinfo", description = "the userinfo API") +public interface UserinfoApi { + + Logger log = LoggerFactory.getLogger(UserinfoApi.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 = "Retrieve user identity information", operationId = "retrieveUserIdentity", description = "", tags={ "userinfo", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "User identity information provided" ), + @ApiResponse(responseCode = "400", description = "Invalid Token"), + @ApiResponse(responseCode = "401", description = "Invalid Token"), + @ApiResponse(responseCode = "403", description = "Forbidden"), + @ApiResponse(responseCode = "404", description = "Not Found"), + @ApiResponse(responseCode = "405", description = "Method not Allowed"), + @ApiResponse(responseCode = "500", description = "Internal Server Error") }) + @RequestMapping(value = "/userinfo", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity retrieveUserIdentity(@Parameter(description = "token to be passed as a header linked to the user whose identity is requested" ,required=true) @RequestHeader(value="Authorization", required=true) String authorization,@Parameter(description = "To apply specific filter in the 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("{ \"sub\" : \"sub\", \"zoneinfo\" : \"zoneinfo\", \"website\" : \"website\", \"birthdate\" : \"birthdate\", \"address\" : { \"country\" : \"country\", \"streetType\" : \"streetType\", \"geographicLocation\" : { \"@type\" : \"@type\", \"name\" : \"name\", \"geographicPoint\" : { \"spatialRef\" : \"spatialRef\", \"x\" : \"x\", \"accuracy\" : \"accuracy\", \"y\" : \"y\", \"z\" : \"z\" }, \"id\" : \"id\", \"href\" : \"href\", \"type\" : \"type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"city\" : \"city\", \"streetNr\" : \"streetNr\", \"@type\" : \"@type\", \"postcode\" : \"postcode\", \"locality\" : \"locality\", \"streetNrLast\" : \"streetNrLast\", \"streetNrSuffix\" : \"streetNrSuffix\", \"streetName\" : \"streetName\", \"stateOrProvince\" : \"stateOrProvince\", \"streetNrLastSuffix\" : \"streetNrLastSuffix\", \"streetSuffix\" : \"streetSuffix\", \"geographicSubAddress\" : { \"buildingName\" : \"buildingName\", \"subUnitNumber\" : \"subUnitNumber\", \"subUnitType\" : \"subUnitType\", \"levelType\" : \"levelType\", \"@type\" : \"@type\", \"name\" : \"name\", \"levelNumber\" : \"levelNumber\", \"type\" : \"type\", \"privateStreetNumber\" : \"privateStreetNumber\", \"@schemaLocation\" : \"@schemaLocation\", \"privateStreetName\" : \"privateStreetName\" }, \"@schemaLocation\" : \"@schemaLocation\" }, \"gender\" : \"gender\", \"@type\" : \"@type\", \"profile\" : \"profile\", \"legalId\" : [ { \"country\" : \"country\", \"issuingAuthority\" : \"issuingAuthority\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"identificationId\" : \"identificationId\" }, { \"country\" : \"country\", \"issuingAuthority\" : \"issuingAuthority\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\", \"identificationId\" : \"identificationId\" } ], \"preferred_username\" : \"preferred_username\", \"given_name\" : \"given_name\", \"middle_name\" : \"middle_name\", \"locale\" : \"locale\", \"picture\" : \"picture\", \"userAssets\" : [ { \"role\" : \"role\", \"entityType\" : \"customer\", \"entitlement\" : [ { \"function\" : \"function\", \"action\" : \"action\" }, { \"function\" : \"function\", \"action\" : \"action\" } ], \"id\" : \"id\", \"assetType\" : \"mobile\" }, { \"role\" : \"role\", \"entityType\" : \"customer\", \"entitlement\" : [ { \"function\" : \"function\", \"action\" : \"action\" }, { \"function\" : \"function\", \"action\" : \"action\" } ], \"id\" : \"id\", \"assetType\" : \"mobile\" } ], \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"nickname\" : \"nickname\", \"phone_number\" : \"phone_number\", \"@schemaLocation\" : \"@schemaLocation\", \"family_name\" : \"family_name\", \"email\" : \"email\"}", UserInfoType.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 UserinfoApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/fi691/api/UserinfoApiController.java b/src/main/java/org/etsi/osl/tmf/fi691/api/UserinfoApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..d316c47c23ea12407164cc07c523dfb2d9643fb2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/fi691/api/UserinfoApiController.java @@ -0,0 +1,54 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.fi691.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-20T00:39:05.842+02:00") + +@Controller +public class UserinfoApiController implements UserinfoApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserinfoApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/fi691/repo/IdentityRepository.java b/src/main/java/org/etsi/osl/tmf/fi691/repo/IdentityRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..986e13d3af4fa3cc2f0de667b9cb71d766113641 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/fi691/repo/IdentityRepository.java @@ -0,0 +1,36 @@ +/*- + * ========================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.fi691.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.fi691.model.UserInfoType; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface IdentityRepository extends PagingAndSortingRepository { + + + Optional findByUuid(String id); + Iterable findByName( String name); + Iterable findByPreferredUsername( String name); + +} diff --git a/src/main/java/org/etsi/osl/tmf/fi691/service/IdentityRepoService.java b/src/main/java/org/etsi/osl/tmf/fi691/service/IdentityRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..3e2dfc656cc0d5c7c6413b6133c2624293e6ab45 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/fi691/service/IdentityRepoService.java @@ -0,0 +1,24 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.fi691.service; + +public class IdentityRepoService { + +} diff --git a/src/main/java/org/etsi/osl/tmf/gsm674/api/ApiUtil.java b/src/main/java/org/etsi/osl/tmf/gsm674/api/ApiUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..6683c4761959adb4763b8e0a613fb47364af1c8e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/api/ApiUtil.java @@ -0,0 +1,19 @@ +package org.etsi.osl.tmf.gsm674.api; + +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.web.context.request.NativeWebRequest; + +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/gsm674/api/Generated.java b/src/main/java/org/etsi/osl/tmf/gsm674/api/Generated.java new file mode 100644 index 0000000000000000000000000000000000000000..92fbaec5167449362f97923c72969d6c4f3f655f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/api/Generated.java @@ -0,0 +1,16 @@ +package org.etsi.osl.tmf.gsm674.api; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Documented +@Retention(RUNTIME) +@Target({TYPE, METHOD, CONSTRUCTOR}) +public @interface Generated { +} diff --git a/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApi.java b/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApi.java new file mode 100644 index 0000000000000000000000000000000000000000..380afa76449809e13532ca81a60a794e04fb1925 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApi.java @@ -0,0 +1,134 @@ +package org.etsi.osl.tmf.gsm674.api; + +import com.fasterxml.jackson.databind.ObjectMapper; +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 jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +import org.etsi.osl.tmf.gsm674.model.GeographicSite; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +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 java.io.IOException; +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +@Generated +public interface GeographicSiteManagementApi { + Logger log = LoggerFactory.getLogger(GeographicSiteManagementApi.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 'GeographicSite'", operationId = "createGeographicSite", description = "", tags={ "geographicSite", }) + @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 = "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 = "/geographicSite", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createGeographicSite(@Parameter(description = "The geographic site to be created" ,required=true ) @Valid @RequestBody GeographicSite geographicSite) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Deletes a 'GeographicSite' by Id", operationId = "deleteGeographicSite", description = "", tags={ "GeographicSite", }) + @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 = "/geographicSite/{id}", + produces = { "application/json" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteGeographicSite(@Parameter(description = "Identifier of the Geographic site",required=true) @PathVariable("id") String id) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find 'GeographicSite' objects", operationId = "listGeographicSite", description = "" , tags={ "GeographicSite", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/geographicSite", + produces = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> listGeographicSite() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a 'GeographicSite' by Id", operationId = "patchGeographicSite", description = "", tags={ "GeographicSite", }) + @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 = "/geographicSite/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.PATCH) + default ResponseEntity patchGeographicalSite(@Parameter(description = "Identifier of the Geographic site",required=true) @PathVariable("id") String id,@Parameter(description = "The Service Level Specification to be updated" ,required=true ) @Valid @RequestBody GeographicSite geographicSite) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a 'GeographicSite' by Id", operationId = "retrieveGeographicSite", description = "" , tags={ "GeographicSite", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/geographicSite/{id}", + produces = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity retrieveGeographicSite(@Parameter(description = "Identifier of the Geographic site",required=true) @PathVariable("id") String id) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApiController.java b/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..475eaede144dd839288630f5c63daf275e08769e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApiController.java @@ -0,0 +1,106 @@ +package org.etsi.osl.tmf.gsm674.api; + +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.gsm674.model.GeographicSite; +import org.etsi.osl.tmf.gsm674.reposervices.GeographicSiteManagementService; +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 java.util.List; + +@Controller +@RequestMapping("/geographicSiteManagement/v5/") +public class GeographicSiteManagementApiController implements GeographicSiteManagementApi{ + + private static final String COULD_NOT_SERIALIZE="Couldn't serialize response for content type application/json"; + private final GeographicSiteManagementService geographicSiteManagementService; + + @Autowired + public GeographicSiteManagementApiController(GeographicSiteManagementService geographicSiteManagementService) { + this.geographicSiteManagementService = geographicSiteManagementService; + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity> listGeographicSite() { + + + try { + return new ResponseEntity<>(geographicSiteManagementService.findAllGeographicSites(), HttpStatus.OK); + + } catch (Exception e) { + log.error(COULD_NOT_SERIALIZE, e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity retrieveGeographicSite(@PathVariable("id") String id) { + + + try { + return new ResponseEntity<>(geographicSiteManagementService.findGeographicSiteByUUID(id), HttpStatus.OK); + + } catch (Exception e) { + log.error(COULD_NOT_SERIALIZE, e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity createGeographicSite( + @Parameter(description = "The geographic site to be created", required = true) @Valid @RequestBody GeographicSite geographicSite + ) { + + try { + + GeographicSite c = geographicSiteManagementService.createGeographicSite(geographicSite); + + return new ResponseEntity<>(c, HttpStatus.OK); + + + } catch (Exception e) { + log.error(COULD_NOT_SERIALIZE, e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity deleteGeographicSite( + @Parameter(description = "Identifier of the geographic site", required = true) @PathVariable("id") String id) { + + try { + return new ResponseEntity<>(geographicSiteManagementService.deleteGeographicSiteById(id), HttpStatus.OK); + }catch (Exception e) { + log.error(COULD_NOT_SERIALIZE, e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + + } + + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity patchGeographicalSite( + @Parameter(description = "Identifier of the ServiceOrder", required = true) @PathVariable("id") String id, + @Parameter(description = "The ServiceOrder to be updated", required = true) @Valid @RequestBody GeographicSite geographicSite) { + try{ + GeographicSite c = geographicSiteManagementService.updateGeographicSite(id, geographicSite); + + return new ResponseEntity<>(c, HttpStatus.OK); + }catch (Exception e){ + log.error(COULD_NOT_SERIALIZE, e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } +} diff --git a/src/main/java/org/etsi/osl/tmf/gsm674/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/gsm674/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..dbd091644d5dd2a02923392f918548b62ae7e980 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/api/HubApi.java @@ -0,0 +1,131 @@ +package org.etsi.osl.tmf.gsm674.api; + +import com.fasterxml.jackson.databind.ObjectMapper; +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 io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.validation.Valid; +import org.etsi.osl.tmf.gsm674.model.EventSubscription; +import org.etsi.osl.tmf.gsm674.model.EventSubscriptionInput; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +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 java.io.IOException; +import java.util.Optional; + +@Generated +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-04-24T14:24:54.867613034Z[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 { + Logger log = LoggerFactory.getLogger(HubApi.class); + default Optional getObjectMapper(){ + return Optional.empty(); + } + + default Optional getRequest() { + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + + /** + * POST /hub : Register a listener + * Sets the communication endpoint address the service instance must use to deliver information about its health state, execution state, failures and metrics. + * + * @param eventSubscriptionInput Data containing the callback endpoint to deliver the information (required) + * @return Notified (status code 201) + * or Error (status code 200) + */ + @Operation( + operationId = "registerListener", + 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" }, + responses = { + @ApiResponse(responseCode = "201", description = "Notified", content = { + @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = EventSubscription.class)), + @Content(mediaType = "application/json", schema = @Schema(implementation = EventSubscription.class)) + }), + @ApiResponse(responseCode = "default", description = "Error", content = { + @Content(mediaType = "application/json;charset=utf-8", schema = @Schema(implementation = Error.class)), + @Content(mediaType = "application/json", schema = @Schema(implementation = Error.class)) + }) + } + ) + @RequestMapping( + method = RequestMethod.POST, + value = "/hub", + produces = { "application/json;charset=utf-8", "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity registerListener( + @Parameter(name = "EventSubscriptionInput", description = "Data containing the callback endpoint to deliver the information", required = true) @Valid @RequestBody EventSubscriptionInput eventSubscriptionInput + ) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}",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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + + /** + * DELETE /hub/{id} : Unregister a listener + * Resets the communication endpoint address the service instance must use to deliver information about its health state, execution state, failures and metrics. + * + * @param id Identifier of the Service (required) + * @return Deleted (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "unregisterListener", + 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" }, + 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 unregisterListener( + @Parameter(name = "id", description = "Identifier of the Service", required = true, in = ParameterIn.PATH) @PathVariable("id") String id + ) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/gsm674/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/gsm674/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..71195a53eb10d27b6a4f3429b6684c0db85e5b3b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/api/HubApiController.java @@ -0,0 +1,28 @@ +package org.etsi.osl.tmf.gsm674.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 java.util.Optional; + + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-04-24T14:24:54.867613034Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller("HubApiController674") +@RequestMapping("/geographicSiteManagement/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/gsm674/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/gsm674/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..3c15fc7515642eaef9e4e0ecd7ec5ae74924b13f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/api/ListenerApi.java @@ -0,0 +1,217 @@ + +package org.etsi.osl.tmf.gsm674.api; +import com.fasterxml.jackson.databind.ObjectMapper; +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.gsm674.model.GeographicSiteAttributeValueChangeEvent; +import org.etsi.osl.tmf.gsm674.model.GeographicSiteCreateEvent; +import org.etsi.osl.tmf.gsm674.model.GeographicSiteDeleteEvent; +import org.etsi.osl.tmf.gsm674.model.GeographicSiteStateChangeEvent; + +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.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.context.request.NativeWebRequest; + +import java.util.Optional; + +@Generated +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-04-24T14:24:54.867613034Z[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 { + Logger log = LoggerFactory.getLogger(ListenerApi.class); + default Optional getRequest() { + return Optional.empty(); + } + default Optional getObjectMapper() { + return Optional.empty(); + } + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + /** + * POST /listener/geographicSiteAttributeValueChangeEvent : Client listener for entity GeographicSiteCreateEvent + * Example of a client listener for receiving the notification GeographicSiteAttributeValueChangeEvent + * + * @param geographicSiteAttributeValueChangeEvent The event data (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "geographicSiteAttributeValueChangeEvent", + summary = "Client listener for entity GeographicSiteCreateEvent", + description = "Example of a client listener for receiving the notification GeographicSiteAttributeValueChangeEvent", + 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/geographicSiteAttributeValueChangeEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity geographicSiteAttributeValueChangeEvent( + @Parameter(name = "GeographicSiteAttributeValueChangeEvent", description = "The event data", required = true) @Valid @RequestBody GeographicSiteAttributeValueChangeEvent geographicSiteAttributeValueChangeEvent + ) { + 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/geographicSiteCreateEvent : Client listener for entity GeographicSiteCreateEvent + * Example of a client listener for receiving the notification GeographicSiteCreateEvent + * + * @param geographicSiteCreateEvent The event data (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "geographicSiteCreateEvent", + summary = "Client listener for entity GeographicSiteCreateEvent", + description = "Example of a client listener for receiving the notification GeographicSiteCreateEvent", + 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/geographicSiteCreateEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity geographicSiteCreateEvent( + @Parameter(name = "GeographicSiteCreateEvent", description = "The event data", required = true) @Valid @RequestBody GeographicSiteCreateEvent geographicSiteCreateEvent + ) { + 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/geographicSiteDeleteEvent : Client listener for entity GeographicSiteCreateEvent + * Example of a client listener for receiving the notification GeographicSiteDeleteEvent + * + * @param geographicSiteDeleteEvent The event data (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "geographicSiteDeleteEvent", + summary = "Client listener for entity GeographicSiteCreateEvent", + description = "Example of a client listener for receiving the notification GeographicSiteDeleteEvent", + 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/geographicSiteDeleteEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity geographicSiteDeleteEvent( + @Parameter(name = "GeographicSiteDeleteEvent", description = "The event data", required = true) @Valid @RequestBody GeographicSiteDeleteEvent geographicSiteDeleteEvent + ) { + 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/geographicSiteStateChangeEvent : Client listener for entity GeographicSiteCreateEvent + * Example of a client listener for receiving the notification GeographicSiteStateChangeEvent + * + * @param geographicSiteStateChangeEvent The event data (required) + * @return Notified (status code 204) + * or Error (status code 200) + */ + @Operation( + operationId = "geographicSiteStateChangeEvent", + summary = "Client listener for entity GeographicSiteCreateEvent", + description = "Example of a client listener for receiving the notification GeographicSiteStateChangeEvent", + 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/geographicSiteStateChangeEvent", + produces = { "application/json" }, + consumes = { "application/json" } + ) + + default ResponseEntity geographicSiteStateChangeEvent( + @Parameter(name = "GeographicSiteStateChangeEvent", description = "The event data", required = true) @Valid @RequestBody GeographicSiteStateChangeEvent geographicSiteStateChangeEvent + ) { + 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/gsm674/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/gsm674/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..bfdcd763980b701f1680713c1a1ffdc2b44c1bd3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/api/ListenerApiController.java @@ -0,0 +1,27 @@ +package org.etsi.osl.tmf.gsm674.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 java.util.Optional; + + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2024-04-24T14:24:54.867613034Z[Etc/UTC]", comments = "Generator version: 7.6.0-SNAPSHOT") +@Controller("ListenerApiController674") +@RequestMapping("/geographicSiteManagement/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/gsm674/repo/GeographicSiteManagementRepository.java b/src/main/java/org/etsi/osl/tmf/gsm674/repo/GeographicSiteManagementRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..c65f209878f0d4524667bea677006f0b61eba100 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/repo/GeographicSiteManagementRepository.java @@ -0,0 +1,14 @@ +package org.etsi.osl.tmf.gsm674.repo; + +import org.etsi.osl.tmf.gsm674.model.GeographicSite; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface GeographicSiteManagementRepository extends CrudRepository, PagingAndSortingRepository { + Optional findByUuid(String id); + +} diff --git a/src/main/java/org/etsi/osl/tmf/gsm674/reposervices/GeographicSiteManagementService.java b/src/main/java/org/etsi/osl/tmf/gsm674/reposervices/GeographicSiteManagementService.java new file mode 100644 index 0000000000000000000000000000000000000000..1206d8201224198c4ff587db4ef8940ce4b2ecfc --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/gsm674/reposervices/GeographicSiteManagementService.java @@ -0,0 +1,125 @@ +package org.etsi.osl.tmf.gsm674.reposervices; + +import org.etsi.osl.tmf.gsm674.model.CalendarPeriod; +import org.etsi.osl.tmf.gsm674.model.GeographicSite; +import org.etsi.osl.tmf.gsm674.model.GeographicSiteRelationship; +import org.etsi.osl.tmf.gsm674.model.PlaceRefOrValue; +import org.etsi.osl.tmf.gsm674.repo.GeographicSiteManagementRepository; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +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 GeographicSiteManagementService { + private static final Logger log = LoggerFactory.getLogger(GeographicSiteManagementService.class); + + private final GeographicSiteManagementRepository geographicSiteManagementRepository; + + @Autowired + public GeographicSiteManagementService(GeographicSiteManagementRepository geographicSiteManagementRepository) { + this.geographicSiteManagementRepository = geographicSiteManagementRepository; + } + + public List findAllGeographicSites(){ + return (List) geographicSiteManagementRepository.findAll(); + } + + public GeographicSite findGeographicSiteByUUID(String uuid){ + Optional gs=geographicSiteManagementRepository.findByUuid(uuid); + return gs.orElse(null); + + } + + public GeographicSite createGeographicSite(GeographicSite geographicSite){ + log.info("Add another geographic site: {}",geographicSite); + return geographicSiteManagementRepository.save(geographicSite); + + } + + public GeographicSite updateGeographicSite(String id,GeographicSite geographicSite){ + log.info("Update geographic site with id: {}",id); + Optional gs=geographicSiteManagementRepository.findByUuid(id); + return gs.map(site -> updateFields(geographicSite, site)).orElse(null); + } + + public Void deleteGeographicSiteById(String id){ + log.info("Delete geographic site with id: {}",id); + GeographicSite gs=geographicSiteManagementRepository.findByUuid(id).orElseThrow(); + geographicSiteManagementRepository.delete(gs); + return null; + } + + private GeographicSite updateFields(GeographicSite newSite, GeographicSite existingSite){ + + if(newSite.getDescription()!=null) existingSite.setDescription(newSite.getDescription()); + if(newSite.getCode()!=null) existingSite.setCode(newSite.getCode()); + if (newSite.getStatus()!=null) existingSite.setStatus(newSite.getStatus()); + + if(newSite.getSiteRelationship() !=null){ + for(GeographicSiteRelationship n : newSite.getSiteRelationship()){ + if(n.getUuid()==null){ + existingSite.addSiteRelationshipItem(n); + }else { + for (GeographicSiteRelationship oldGeographicRelationship : existingSite.getSiteRelationship()){ + if (n.getUuid().equals(oldGeographicRelationship.getUuid())){ + if (n.getRole() !=null) oldGeographicRelationship.setRole(n.getRole()); + if (n.getRelationshipType() !=null) oldGeographicRelationship.setRelationshipType(n.getRelationshipType()); + if (n.getValidFor() !=null) oldGeographicRelationship.setValidFor(n.getValidFor()); + } + } + } + } + } + + if(newSite.getCalendar()!=null){ + for(CalendarPeriod c: newSite.getCalendar()){ + if(c.getUuid()==null){ + existingSite.addCalendarItem(c); + } else { + for (CalendarPeriod oldCalendarPeriod: existingSite.getCalendar()){ + if (c.getUuid().equals(oldCalendarPeriod.getUuid())){ + if( c.getDay() !=null) oldCalendarPeriod.setDay(c.getDay()); + if( c.getStatus() !=null) oldCalendarPeriod.setStatus(c.getStatus()); + if( c.getTimeZone() !=null) oldCalendarPeriod.setTimeZone(c.getTimeZone()); + if( c.getHourPeriod() !=null) oldCalendarPeriod.setHourPeriod(c.getHourPeriod()); + } + } + } + } + } + + if(newSite.getPlace()!=null){ + for(PlaceRefOrValue p: newSite.getPlace()){ + if (p.getUuid()==null){ + existingSite.addPlaceItem(p); + } + } + } + + if(newSite.getRelatedParty()!=null){ + for(RelatedParty party: newSite.getRelatedParty()){ + if(party.getUuid()==null){ + existingSite.addRelatedPartyItem(party); + } else { + for (RelatedParty rp: existingSite.getRelatedParty()){ + if(party.getUuid().equals(rp.getUuid())){ + if (party.getRole() !=null) rp.setRole(party.getRole()); + if (party.getName() !=null) rp.setName(party.getName()); + } + } + } + } + } + + geographicSiteManagementRepository.save(existingSite); + return existingSite; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/lcm/api/LCMRuleSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/lcm/api/LCMRuleSpecificationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..019b66df6b04fe71a7af988cebd60fed23712a0b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/lcm/api/LCMRuleSpecificationApi.java @@ -0,0 +1,168 @@ +package org.etsi.osl.tmf.lcm.api; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecification; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationCreate; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationUpdate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + + +@Tag(name = "lcmRuleSpecification") +public interface LCMRuleSpecificationApi { + + + Logger log = LoggerFactory.getLogger(LCMRuleSpecificationApi.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 LCM RuleSpecification", operationId = "createLCMRuleSpecification", description = "This operation creates a LCM RuleSpecification entity." , tags = { + "lcmRuleSpecification", }) + @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 = "/lcmRuleSpecification", produces = { "application/json;charset=utf-8" }, consumes = { + "application/json;charset=utf-8" }, method = RequestMethod.POST) + default ResponseEntity createLCMRuleSpecification( + @Parameter(description = "The RuleSpecification to be created", required = true) @Valid @RequestBody LCMRuleSpecificationCreate body) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Deletes a LCM RuleSpecification", operationId = "deleteLCMRuleSpecification", description = "This operation deletes a LCM RuleSpecification entity.", tags = { + "lcmRuleSpecification", }) + @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 = "/lcmRuleSpecification/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.DELETE) + default ResponseEntity deleteLCMRuleSpecification( + @Parameter(description = "Identifier of the RuleSpecification", required = true) @PathVariable("id") String id) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default LCM RuleSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "List or find LCM RuleSpecification objects", operationId = "listLCMRuleSpecification", description = "This operation list or find LCM RuleSpecification entities" , tags = { + "lcmRuleSpecification", }) + @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 = "/lcmRuleSpecification", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + ResponseEntity> listLCMRuleSpecification( + @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); + + + @Operation(summary = "List or find LCM RuleSpecification objects by Service Specification ID", operationId = "listLCMRuleSpecificationsByServiceSpecID", description = "This operation list or find LCM RuleSpecification entities by SpecID" , tags = { + "lcmRuleSpecification", }) + @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 = "/lcmRuleSpecification/serviceSpec/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + ResponseEntity> listLCMRuleSpecificationBySpecID( + @Parameter(description = "Identifier of the ServiceSpecification Id", required = true) @PathVariable("id") String id, + @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); + + + + @Operation(summary = "Updates partially a LCM RuleSpecification", operationId = "patchLCMRuleSpecification", description = "This operation updates partially a LCM RuleSpecification entity." , tags = { + "lcmRuleSpecification", }) + @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 = "/lcmRuleSpecification/{id}", produces = { + "application/json;charset=utf-8" }, consumes = { + "application/json;charset=utf-8" }, method = RequestMethod.PATCH) + default ResponseEntity patchLCMRuleSpecification( + @Parameter(description = "The LCM RuleSpecification to be updated", required = true) @Valid @RequestBody LCMRuleSpecificationUpdate body, + @Parameter(description = "Identifier of the LCM RuleSpecification", required = true) @PathVariable("id") String id) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Retrieves a LCM RuleSpecification by ID", operationId = "retrieveLCMRuleSpecification", description = "This operation retrieves a LCM RuleSpecification entity. Attribute selection is enabled for all first level attributes." , tags = { + "lcmRuleSpecification", }) + @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 = "/lcmRuleSpecification/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity retrieveLCMRuleSpecification( + @Parameter(description = "Identifier of the LCM RuleSpecification", required = true) @PathVariable("id") String id, + @Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} + diff --git a/src/main/java/org/etsi/osl/tmf/lcm/api/LCMRuleSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/lcm/api/LCMRuleSpecificationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..1abb3658cd197e1b8deb305b8bbed374c059b707 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/lcm/api/LCMRuleSpecificationApiController.java @@ -0,0 +1,159 @@ +package org.etsi.osl.tmf.lcm.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecification; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationCreate; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationUpdate; +import org.etsi.osl.tmf.lcm.reposervices.LCMRuleSpecificationRepoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + + +@Controller +@RequestMapping("/lcmrulesmanagement/v1/") +public class LCMRuleSpecificationApiController implements LCMRuleSpecificationApi { + + private static final Logger log = LoggerFactory.getLogger(LCMRuleSpecificationApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Autowired + LCMRuleSpecificationRepoService lcmRuleSpecificationRepoService; + + @Value("${spring.application.name}") + private String compname; + + @org.springframework.beans.factory.annotation.Autowired + public LCMRuleSpecificationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createLCMRuleSpecification(@Valid LCMRuleSpecificationCreate body) { + try { + + LCMRuleSpecification c = lcmRuleSpecificationRepoService.addLCMRuleSpecification( body ); + + return new ResponseEntity(c, 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_ADMIN')" ) + public ResponseEntity deleteLCMRuleSpecification(String id) { + try { + + return new ResponseEntity( lcmRuleSpecificationRepoService.deleteById( 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_ADMIN')" ) + public ResponseEntity retrieveLCMRuleSpecification(String id, @Valid String fields) { + try { + + return new ResponseEntity( lcmRuleSpecificationRepoService.findById( 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_ADMIN')" ) + public ResponseEntity patchLCMRuleSpecification(@Valid LCMRuleSpecificationUpdate body, String id) { + LCMRuleSpecification c = lcmRuleSpecificationRepoService.updateLCMRuleSpecification( id, body ); + + return new ResponseEntity(c, HttpStatus.OK); + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity> listLCMRuleSpecification(@Valid String fields, + @Valid Integer offset, @Valid Integer limit, @Valid Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = null; + return new ResponseEntity>( + lcmRuleSpecificationRepoService.findAll( myfields, allParams), HttpStatus.OK); + + + } else { + + + return new ResponseEntity>( + lcmRuleSpecificationRepoService.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); + } + } + + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity> listLCMRuleSpecificationBySpecID(String id, @Valid String fields, + @Valid Integer offset, @Valid Integer limit, @Valid Map allParams) { + try { + + + return new ResponseEntity>( + lcmRuleSpecificationRepoService.findByServiceSpecificationRefId(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/lcm/api/LCMRuleSpecificationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/lcm/api/LCMRuleSpecificationApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..ba24c901749ad68cf4afc555ccb5e132c9f65fa7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/lcm/api/LCMRuleSpecificationApiRouteBuilder.java @@ -0,0 +1,52 @@ +package org.etsi.osl.tmf.lcm.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.lcm.reposervices.LCMRuleSpecificationRepoService; +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; + +/** + * @author ctranoris + * + */ +@Configuration +@Component +public class LCMRuleSpecificationApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog( LCMRuleSpecificationApiRouteBuilder.class.getName()); + + @Value("${CATALOG_GET_LCMRULE_BY_ID}") + private String CATALOG_GET_LCMRULE_BY_ID = ""; + + @Value("${CATALOG_GET_LCMRULES_BY_SPECID_PHASE}") + private String CATALOG_GET_LCMRULES_BY_SPECID_PHASE = ""; + + + @Autowired + LCMRuleSpecificationRepoService lcmRuleSpecificationRepoService; + + @Override + public void configure() throws Exception { + + from( CATALOG_GET_LCMRULE_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_LCMRULE_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( lcmRuleSpecificationRepoService, "findByUuidEager") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + from( CATALOG_GET_LCMRULES_BY_SPECID_PHASE ) + .log(LoggingLevel.INFO, log, CATALOG_GET_LCMRULES_BY_SPECID_PHASE + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( lcmRuleSpecificationRepoService, "findByServiceSpecificationRefIdAndPhase(${header.servicespecid}, ${header.phasename})") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/lcm/repo/LCMRuleSpecificationRepository.java b/src/main/java/org/etsi/osl/tmf/lcm/repo/LCMRuleSpecificationRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..4cdca9903451b09b7daa52bb40f99e0299c4e0e0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/lcm/repo/LCMRuleSpecificationRepository.java @@ -0,0 +1,42 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.lcm.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecification; +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(value = "lcmRuleSpecificationRepository") +public interface LCMRuleSpecificationRepository extends CrudRepository, PagingAndSortingRepository { + + Optional findByUuid(String id); + + @Query("SELECT sc FROM LCMRuleSpec sc JOIN FETCH sc.serviceSpecs spec WHERE spec.id = ?1 ORDER BY sc.priority") + List findByServiceSpecificationRef(String id); + + @Query("SELECT sc FROM LCMRuleSpec sc JOIN FETCH sc.serviceSpecs spec WHERE spec.id = ?1 AND sc.lcmrulephase LIKE ?2 ORDER BY sc.priority") + List findByServiceSpecificationRefAndPhase(String id, String phaseName); + +} diff --git a/src/main/java/org/etsi/osl/tmf/lcm/reposervices/LCMRuleSpecificationRepoService.java b/src/main/java/org/etsi/osl/tmf/lcm/reposervices/LCMRuleSpecificationRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..895fd1b80e579df4dafae2812a8d6aec238d1610 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/lcm/reposervices/LCMRuleSpecificationRepoService.java @@ -0,0 +1,352 @@ +package org.etsi.osl.tmf.lcm.reposervices; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecification; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationCreate; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationUpdate; +import org.etsi.osl.tmf.lcm.repo.LCMRuleSpecificationRepository; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + + + +@Service(value = "lcmRuleSpecificationRepoService") +public class LCMRuleSpecificationRepoService { + + + @Autowired + LCMRuleSpecificationRepository lcmRuleSpecificationRepository; + + + private SessionFactory sessionFactory; + + @Autowired + public LCMRuleSpecificationRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + + + @Transactional + public LCMRuleSpecification addLCMRuleSpecification(@Valid LCMRuleSpecificationCreate ruleSpecificationCreate) { + + LCMRuleSpecification as = new LCMRuleSpecification(); + as = updateLCMRuleSpecificationFromAPICall( as, ruleSpecificationCreate); + as = this.lcmRuleSpecificationRepository.save(as); + return as; + } + + + + public List findAll() { + return (List) this.lcmRuleSpecificationRepository.findAll(); + } + + + public Void deleteById(String id) { + Optional optionalCat = this.lcmRuleSpecificationRepository.findByUuid(id); + this.lcmRuleSpecificationRepository.delete(optionalCat.get()); + return null; + } + + + @Transactional + public LCMRuleSpecification updateLCMRuleSpecification(String id, @Valid LCMRuleSpecificationUpdate body) { + + LCMRuleSpecification s = this.findByUuid(id); + if (s == null) { + return null; + } + LCMRuleSpecification alm = s; + alm = this.updateLCMRuleSpecificationFromAPICall(alm, body); + + alm = this.lcmRuleSpecificationRepository.save(alm); + return alm; + } + + + @Transactional + public LCMRuleSpecification findByUuid(String id) { + Optional optionalCat = this.lcmRuleSpecificationRepository.findByUuid(id); + return optionalCat.orElse(null); + } + + public List findAll(String myfields, @Valid Map allParams) + throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { +// String sql = "SELECT s FROM ServiceSpecification s"; + String sql = "SELECT " + + "s.uuid as uuid," + + "s.uuid as id," + + "s.name as name," + + "s.description as description," + + "s.priority as priority," + + "s.lcmrulephase as lcmrulephase"; + + if (myfields != null) { + String[] field = myfields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM LCMRuleSpec s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.priority, s.name"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + } + + + @Transactional + public LCMRuleSpecification findById(String id) { + Optional optionalCat = this.lcmRuleSpecificationRepository.findByUuid(id); + return optionalCat.orElse(null); + } + + + @Transactional + public LCMRuleSpecification findByUuidEager(String id) { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); // instead of begin transaction, is it possible to continue? + LCMRuleSpecification ls = null; + try { + ls = session.get(LCMRuleSpecification.class, id); + if ( ls == null) { + return this.findByUuid(id);// last resort + } + Hibernate.initialize(ls.getServiceSpecs() ); + tx.commit(); + } finally { + session.close(); + } + + return ls; + } + + @Transactional + public List findByServiceSpecificationRefId(String serviceSpecId) { + //return this.lcmRuleSpecificationRepository.findByServiceSpecificationRef( serviceSpecId ); + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { +// String sql = "SELECT s FROM ServiceSpecification s"; + String sql = "SELECT " + + "s.uuid as uuid," + + "s.uuid as id," //this is correct + + "s.name as name," + + "s.description as description," + + "s.priority as priority," + + "s.lcmrulephase as lcmrulephase"; + + + sql += " FROM LCMRuleSpec s JOIN s.serviceSpecs spec WHERE spec.id LIKE '" + serviceSpecId+"'"; + //sql += " FROM LCMRuleSpec s JOIN s.serviceSpecs spec"; + + sql += " ORDER BY s.priority, s.name"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + 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(); + } + } + + @Transactional + public List findByServiceSpecificationRefIdAndPhase(String serviceSpecId, String phaseName) { + + + return this.lcmRuleSpecificationRepository.findByServiceSpecificationRefAndPhase( serviceSpecId, phaseName ); + } + + + private LCMRuleSpecification updateLCMRuleSpecificationFromAPICall(LCMRuleSpecification as, + @Valid LCMRuleSpecificationUpdate ruleSpecificationUpdate) { + + if ( ruleSpecificationUpdate.getName() != null) { + as.setName( ruleSpecificationUpdate.getName() ); + } + + if ( ruleSpecificationUpdate.getDescription() != null) { + as.setDescription( ruleSpecificationUpdate.getDescription() ); + } + + if ( ruleSpecificationUpdate.getLcmrulephase() != null) { + as.setLcmrulephase( ruleSpecificationUpdate.getLcmrulephase() ); + + } + + if ( ruleSpecificationUpdate.getPriority() != 0) { + as.setPriority( ruleSpecificationUpdate.getPriority() ); + } + + + + if ( ruleSpecificationUpdate.getLifecycleStatus() != null) { + as.setLifecycleStatus( ruleSpecificationUpdate.getLifecycleStatus() ); + } + + if ( ruleSpecificationUpdate.getContent() != null) { + as.setContent( ruleSpecificationUpdate.getContent() ); + } + if ( ruleSpecificationUpdate.getCode() != null) { + as.setCode( ruleSpecificationUpdate.getCode() ); + } + + if ( ruleSpecificationUpdate.getServiceSpecs() != null) { + Map idAddedUpdated = new HashMap<>(); + + for (ServiceSpecificationRef ar : ruleSpecificationUpdate.getServiceSpecs()) { + // find by id and reload it here. + + boolean idexists = false; + for (ServiceSpecificationRef orinalCom : as.getServiceSpecs()) { + if (ar.getId()!=null && orinalCom.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalCom.getId(), true); + break; + } + } + + if (!idexists) { + as.getServiceSpecs().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (ServiceSpecificationRef ss : as.getServiceSpecs()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (ServiceSpecificationRef ar : toRemove) { + as.getServiceSpecs().remove(ar); + } + + } + + return as; + } + + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..16a8ace17e9f2c42b1d3dacfbcd7789538944abd --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.pcm620.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +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/pcm620/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..987cce619bb5fea44f6b615fa8dc5a2bf9e0fdda --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================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.pcm620.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.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +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/pcm620/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..cef90ec1ccbaa6687cc3f4891fdf891a8cacd827 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================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.pcm620.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@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/pcm620/api/CatalogApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/CatalogApi.java new file mode 100644 index 0000000000000000000000000000000000000000..ef1430e5f3b3f8dc47428e96a82578f86cc826c9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/CatalogApi.java @@ -0,0 +1,212 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.Catalog; +import org.etsi.osl.tmf.pcm620.model.CatalogCreate; +import org.etsi.osl.tmf.pcm620.model.CatalogUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Tag(name = "catalog", description = "the catalog API") +public interface CatalogApi { + + Logger log = LoggerFactory.getLogger(CatalogApi.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 Catalog", operationId = "createCatalog", description = "This operation creates a Catalog entity.", tags={ "catalog", }) + @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 = "/catalog", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createCatalog(@Parameter(description = "The Catalog to be created" ,required=true ) @Valid @RequestBody CatalogCreate catalog) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"catalogType\" : \"catalogType\", \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"}", Catalog.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 CatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a Catalog", operationId = "deleteCatalog", description = "This operation deletes a Catalog entity.", tags={ "catalog", }) + @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 = "/catalog/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteCatalog(@Parameter(description = "Identifier of the Catalog",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default CatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find Catalog objects", operationId = "listCatalog", description = "This operation list or find Catalog entities" , tags={ "catalog", }) + @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 = "/catalog", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listCatalog(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"catalogType\" : \"catalogType\", \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"}, { \"catalogType\" : \"catalogType\", \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default CatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a Catalog", operationId = "patchCatalog", description = "This operation updates partially a Catalog entity.", tags={ "catalog", }) + @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 = "/catalog/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchCatalog(@Parameter(description = "Identifier of the Catalog",required=true) @PathVariable("id") String id,@Parameter(description = "The Catalog to be updated" ,required=true ) @Valid @RequestBody CatalogUpdate catalog) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"catalogType\" : \"catalogType\", \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"}", Catalog.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 CatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a Catalog by ID", operationId = "retrieveCatalog", description = "This operation retrieves a Catalog entity. Attribute selection is enabled for all first level attributes.", tags={ "catalog", }) + @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 = "/catalog/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveCatalog(@Parameter(description = "Identifier of the Catalog",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("{ \"catalogType\" : \"catalogType\", \"lifecycleStatus\" : \"lifecycleStatus\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\"}", Catalog.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 CatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/CatalogApiController.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/CatalogApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..a2952a6cb9794cd697bb399f038775207aa8c50b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/CatalogApiController.java @@ -0,0 +1,114 @@ +/*- + * ========================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.pcm620.api; + +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.Catalog; +import org.etsi.osl.tmf.pcm620.model.CatalogCreate; +import org.etsi.osl.tmf.pcm620.model.CatalogUpdate; +import org.etsi.osl.tmf.pcm620.reposervices.ProductCatalogRepoService; +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.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Controller +@RequestMapping("/productCatalogManagement/v4/") +public class CatalogApiController implements CatalogApi { + + private static final Logger log = LoggerFactory.getLogger(CatalogApiController.class); + + @Autowired + ProductCatalogRepoService catalogRepoService; + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Autowired + public CatalogApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public ResponseEntity createCatalog(@Valid CatalogCreate catalog) { + try { + + Catalog c = catalogRepoService.addCatalog(catalog); + + return new ResponseEntity(c, 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 deleteCatalog(String id) { + try { + + return new ResponseEntity( catalogRepoService.deleteById( 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> listCatalog(@Valid String fields, @Valid Integer offset, + @Valid Integer limit) { + try { + return new ResponseEntity>( catalogRepoService.findAll() , 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 patchCatalog(String id, @Valid CatalogUpdate catalog) { + Catalog c = catalogRepoService.updateCatalog( id, catalog ); + + return new ResponseEntity< Catalog>(c, HttpStatus.OK); + } + + @Override + public ResponseEntity retrieveCatalog(String id, @Valid String fields) { + try { + + return new ResponseEntity( catalogRepoService.findById( 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/api/CategoryApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/CategoryApi.java new file mode 100644 index 0000000000000000000000000000000000000000..ebae861a22ec1d0621a9b761f20c023dc6b6a1e6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/CategoryApi.java @@ -0,0 +1,212 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.Category; +import org.etsi.osl.tmf.pcm620.model.CategoryCreate; +import org.etsi.osl.tmf.pcm620.model.CategoryUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Tag(name = "category", description = "the category API") +public interface CategoryApi { + + Logger log = LoggerFactory.getLogger(CategoryApi.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 Category", operationId = "createCategory", description = "This operation creates a Category entity.", tags={ "category", }) + @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 = "/category", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createCategory(@Parameter(description = "The Category to be created" ,required=true ) @Valid @RequestBody CategoryCreate category) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"subCategory\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"isRoot\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"version\" : \"version\", \"parentId\" : \"parentId\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", Category.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 CategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a Category", operationId = "deleteCategory", description = "This operation deletes a Category entity.", tags={ "category", }) + @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 = "/category/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteCategory(@Parameter(description = "Identifier of the Category",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default CategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find Category objects", operationId = "listCategory", description = "This operation list or find Category entities" , tags={ "category", }) + @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 = "/category", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listCategory(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"subCategory\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"isRoot\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"version\" : \"version\", \"parentId\" : \"parentId\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}, { \"subCategory\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"isRoot\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"version\" : \"version\", \"parentId\" : \"parentId\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default CategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a Category", operationId = "patchCategory", description = "This operation updates partially a Category entity.", tags={ "category", }) + @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 = "/category/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchCategory(@Parameter(description = "Identifier of the Category",required=true) @PathVariable("id") String id,@Parameter(description = "The Category to be updated" ,required=true ) @Valid @RequestBody CategoryUpdate category) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"subCategory\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"isRoot\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"version\" : \"version\", \"parentId\" : \"parentId\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", Category.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 CategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a Category by ID", operationId = "retrieveCategory", description = "This operation retrieves a Category entity. Attribute selection is enabled for all first level attributes.", tags={ "category", }) + @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 = "/category/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveCategory(@Parameter(description = "Identifier of the Category",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("{ \"subCategory\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"isRoot\" : true, \"lifecycleStatus\" : \"lifecycleStatus\", \"productOffering\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"version\" : \"version\", \"parentId\" : \"parentId\", \"@baseType\" : \"@baseType\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\"}", Category.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 CategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/CategoryApiController.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/CategoryApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..6c51fb762247bfcd6f9af20298f4a97fe9d0f094 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/CategoryApiController.java @@ -0,0 +1,124 @@ +/*- + * ========================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.pcm620.api; + +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.Category; +import org.etsi.osl.tmf.pcm620.model.CategoryCreate; +import org.etsi.osl.tmf.pcm620.model.CategoryUpdate; +import org.etsi.osl.tmf.pcm620.reposervices.ProductCategoryRepoService; +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.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Controller +@RequestMapping("/productCatalogManagement/v4/") +public class CategoryApiController implements CategoryApi { + + + private static final Logger log = LoggerFactory.getLogger( CategoryApiController.class); + + @Autowired + ProductCategoryRepoService categoryRepoService; + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public CategoryApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public ResponseEntity createCategory(@Valid CategoryCreate category) { + try { + + Category c = categoryRepoService.addCategory( category ); + + return new ResponseEntity(c, 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 deleteCategory(String id) { + try { + if ( categoryRepoService.deleteById(id) ) { + return new ResponseEntity(HttpStatus.OK); + + } else { + return new ResponseEntity(HttpStatus.NOT_MODIFIED ); + } + + } 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> listCategory(@Valid String fields, @Valid Integer offset, + @Valid Integer limit) { + + try { + return new ResponseEntity>(categoryRepoService.findAll(), 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 patchCategory(String id, @Valid CategoryUpdate category) { + Category c = categoryRepoService.updateCategory(id, category); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @Override + public ResponseEntity retrieveCategory(String id, @Valid String fields) { + try { + + return new ResponseEntity(categoryRepoService.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/pcm620/api/ExportJobApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ExportJobApi.java new file mode 100644 index 0000000000000000000000000000000000000000..3c2581d46f514c1e4943f261486b593265ea3d96 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ExportJobApi.java @@ -0,0 +1,183 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.ExportJob; +import org.etsi.osl.tmf.pcm620.model.ExportJobCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Tag(name = "exportJob", description = "the exportJob API") +public interface ExportJobApi { + + Logger log = LoggerFactory.getLogger(ExportJobApi.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 ExportJob", operationId = "createExportJob", description = "This operation creates a ExportJob entity.", tags={ "exportJob", }) + @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 = "/exportJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createExportJob(@Parameter(description = "The ExportJob to be created" ,required=true ) @Valid @RequestBody ExportJobCreate exportJob) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@type\" : \"@type\", \"query\" : \"query\", \"errorLog\" : \"errorLog\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"url\" : \"url\", \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"status\" : { }}", ExportJob.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 ExportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ExportJob", operationId = "deleteExportJob", description = "This operation deletes a ExportJob entity.", tags={ "exportJob", }) + @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 = "/exportJob/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteExportJob(@Parameter(description = "Identifier of the ExportJob",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ExportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ExportJob objects", operationId = "listExportJob", description = "This operation list or find ExportJob entities" , tags={ "exportJob", }) + @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 = "/exportJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listExportJob(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"@type\" : \"@type\", \"query\" : \"query\", \"errorLog\" : \"errorLog\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"url\" : \"url\", \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"status\" : { }}, { \"@type\" : \"@type\", \"query\" : \"query\", \"errorLog\" : \"errorLog\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"url\" : \"url\", \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"status\" : { }} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ExportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ExportJob by ID", operationId = "retrieveExportJob", description = "This operation retrieves a ExportJob entity. Attribute selection is enabled for all first level attributes.", tags={ "exportJob", }) + @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 = "/exportJob/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveExportJob(@Parameter(description = "Identifier of the ExportJob",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("{ \"@type\" : \"@type\", \"query\" : \"query\", \"errorLog\" : \"errorLog\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"url\" : \"url\", \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"status\" : { }}", ExportJob.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 ExportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ExportJobApiController.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ExportJobApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..1107adb1e55e1dc41a8d2a1de94b4385b6bea111 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ExportJobApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Controller( "ExportJobApiController620" ) +@RequestMapping("/productCatalogManagement/v4/") +public class ExportJobApiController implements ExportJobApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ExportJobApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..2de26104383c378d8a2b034566518b35e3eefd52 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.EventSubscription; +import org.etsi.osl.tmf.pcm620.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..55177431990a0cec5dcf93349f54e941558159d7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Controller("HubApiController620") +@RequestMapping("/productCatalogManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ImportJobApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ImportJobApi.java new file mode 100644 index 0000000000000000000000000000000000000000..3bcde9b55ab629979dd2cd684441a64a92e3c4df --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ImportJobApi.java @@ -0,0 +1,183 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.ImportJob; +import org.etsi.osl.tmf.pcm620.model.ImportJobCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Tag(name = "importJob", description = "the importJob API") +public interface ImportJobApi { + + Logger log = LoggerFactory.getLogger(ImportJobApi.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 ImportJob", operationId = "createImportJob", description = "This operation creates a ImportJob entity.", tags={ "importJob", }) + @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 = "/importJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createImportJob(@Parameter(description = "The ImportJob to be created" ,required=true ) @Valid @RequestBody ImportJobCreate importJob) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"errorLog\" : \"errorLog\", \"id\" : \"id\", \"href\" : \"href\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"url\" : \"url\", \"status\" : { }}", ImportJob.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 ImportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ImportJob", operationId = "deleteImportJob", description = "This operation deletes a ImportJob entity.", tags={ "importJob", }) + @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 = "/importJob/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteImportJob(@Parameter(description = "Identifier of the ImportJob",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ImportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ImportJob objects", operationId = "listImportJob", description = "This operation list or find ImportJob entities" , tags={ "importJob", }) + @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 = "/importJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listImportJob(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"errorLog\" : \"errorLog\", \"id\" : \"id\", \"href\" : \"href\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"url\" : \"url\", \"status\" : { }}, { \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"errorLog\" : \"errorLog\", \"id\" : \"id\", \"href\" : \"href\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"url\" : \"url\", \"status\" : { }} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ImportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ImportJob by ID", operationId = "retrieveImportJob", description = "This operation retrieves a ImportJob entity. Attribute selection is enabled for all first level attributes.", tags={ "importJob", }) + @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 = "/importJob/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveImportJob(@Parameter(description = "Identifier of the ImportJob",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("{ \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"errorLog\" : \"errorLog\", \"id\" : \"id\", \"href\" : \"href\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"url\" : \"url\", \"status\" : { }}", ImportJob.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 ImportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ImportJobApiController.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ImportJobApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..1fc0c78adfc9310bdd46193f680f8787cc4db78b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ImportJobApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Controller("ImportJobApiController620") +@RequestMapping("/productCatalogManagement/v4/") +public class ImportJobApiController implements ImportJobApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ImportJobApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..200f4bb0f9e0e3389be4f5271e6d91e002c1774f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ListenerApi.java @@ -0,0 +1,544 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.CatalogBatchEvent; +import org.etsi.osl.tmf.pcm620.model.CatalogCreateEvent; +import org.etsi.osl.tmf.pcm620.model.CatalogDeleteEvent; +import org.etsi.osl.tmf.pcm620.model.CategoryCreateEvent; +import org.etsi.osl.tmf.pcm620.model.CategoryDeleteEvent; +import org.etsi.osl.tmf.pcm620.model.EventSubscription; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingAttributeValueChangeEvent; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingCreateEvent; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingDeleteEvent; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceAttributeValueChangeEvent; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceCreateEvent; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceDeleteEvent; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceStateChangeEvent; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingStateChangeEvent; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCreateEvent; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationDeleteEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity CatalogBatchEvent", operationId = "listenToCatalogBatchEvent", description = "Example of a client listener for receiving the notification CatalogBatchEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/catalogBatchEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCatalogBatchEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CatalogBatchEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CatalogCreateEvent", operationId = "listenToCatalogCreateEvent", description = "Example of a client listener for receiving the notification CatalogCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/catalogCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCatalogCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CatalogCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CatalogDeleteEvent", operationId = "listenToCatalogDeleteEvent", description = "Example of a client listener for receiving the notification CatalogDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/catalogDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCatalogDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CatalogDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CategoryCreateEvent", operationId = "listenToCategoryCreateEvent", description = "Example of a client listener for receiving the notification CategoryCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/categoryCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCategoryCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CategoryCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CategoryDeleteEvent", operationId = "listenToCategoryDeleteEvent", description = "Example of a client listener for receiving the notification CategoryDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/categoryDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCategoryDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CategoryDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOfferingAttributeValueChangeEvent", operationId = "listenToProductOfferingAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification ProductOfferingAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOfferingAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOfferingAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOfferingAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOfferingCreateEvent", operationId = "listenToProductOfferingCreateEvent", description = "Example of a client listener for receiving the notification ProductOfferingCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOfferingCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOfferingCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOfferingCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOfferingDeleteEvent", operationId = "listenToProductOfferingDeleteEvent", description = "Example of a client listener for receiving the notification ProductOfferingDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOfferingDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOfferingDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOfferingDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOfferingPriceAttributeValueChangeEvent", operationId = "listenToProductOfferingPriceAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification ProductOfferingPriceAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOfferingPriceAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOfferingPriceAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOfferingPriceAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOfferingPriceCreateEvent", operationId = "listenToProductOfferingPriceCreateEvent", description = "Example of a client listener for receiving the notification ProductOfferingPriceCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOfferingPriceCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOfferingPriceCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOfferingPriceCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOfferingPriceDeleteEvent", operationId = "listenToProductOfferingPriceDeleteEvent", description = "Example of a client listener for receiving the notification ProductOfferingPriceDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOfferingPriceDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOfferingPriceDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOfferingPriceDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOfferingPriceStateChangeEvent", operationId = "listenToProductOfferingPriceStateChangeEvent", description = "Example of a client listener for receiving the notification ProductOfferingPriceStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOfferingPriceStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOfferingPriceStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOfferingPriceStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOfferingStateChangeEvent", operationId = "listenToProductOfferingStateChangeEvent", description = "Example of a client listener for receiving the notification ProductOfferingStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOfferingStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOfferingStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOfferingStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductSpecificationCreateEvent", operationId = "listenToProductSpecificationCreateEvent", description = "Example of a client listener for receiving the notification ProductSpecificationCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productSpecificationCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductSpecificationCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductSpecificationCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductSpecificationDeleteEvent", operationId = "listenToProductSpecificationDeleteEvent", description = "Example of a client listener for receiving the notification ProductSpecificationDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productSpecificationDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductSpecificationDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductSpecificationDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..77f66dba6f60dbdbbf072faafc1d03b133649088 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Controller("ListenerApiController620") +@RequestMapping("/productCatalogManagement/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..93493d57e149197e7b251dbd46265d648d51f40d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/NotFoundException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.pcm620.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +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/pcm620/api/ProductOfferingApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApi.java new file mode 100644 index 0000000000000000000000000000000000000000..3b0eacf57af62f8a30f4838f1fd8dd1f82d73742 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApi.java @@ -0,0 +1,227 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.ProductOffering; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingCreate; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingUpdate; +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; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Tag(name = "productOffering", description = "the productOffering API") +public interface ProductOfferingApi { + + Logger log = LoggerFactory.getLogger(ProductOfferingApi.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 ProductOffering", operationId = "createProductOffering", description = "This operation creates a ProductOffering entity." , tags = { + "productOffering", }) + @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 = "/productOffering", produces = { "application/json;charset=utf-8" }, consumes = { + "application/json;charset=utf-8" }, method = RequestMethod.POST) + default ResponseEntity createProductOffering( + @Parameter(description = "The ProductOffering to be created", required = true) @Valid @RequestBody ProductOfferingCreate productOffering) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "{ \"isBundle\" : true, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"serviceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@type\" : \"@type\", \"channel\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"description\" : \"description\", \"productOfferingPrice\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"resourceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"statusReason\" : \"statusReason\", \"bundledProductOffering\" : [ { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"marketSegment\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isSellable\" : true, \"serviceLevelAgreement\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"version\" : \"version\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]}", + ProductOffering.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 ProductOfferingApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Deletes a ProductOffering", operationId = "deleteProductOffering", description = "This operation deletes a ProductOffering entity.", tags = { + "productOffering", }) + @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 = "/productOffering/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.DELETE) + default ResponseEntity deleteProductOffering( + @Parameter(description = "Identifier of the ProductOffering", required = true) @PathVariable("id") String id) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ProductOfferingApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "List or find ProductOffering objects", operationId = "listProductOffering", description = "This operation list or find ProductOffering entities" , 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", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity> listProductOffering( + @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( + "[ { \"isBundle\" : true, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"serviceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@type\" : \"@type\", \"channel\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"description\" : \"description\", \"productOfferingPrice\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"resourceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"statusReason\" : \"statusReason\", \"bundledProductOffering\" : [ { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"marketSegment\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isSellable\" : true, \"serviceLevelAgreement\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"version\" : \"version\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]}, { \"isBundle\" : true, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"serviceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@type\" : \"@type\", \"channel\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"description\" : \"description\", \"productOfferingPrice\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"resourceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"statusReason\" : \"statusReason\", \"bundledProductOffering\" : [ { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"marketSegment\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isSellable\" : true, \"serviceLevelAgreement\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"version\" : \"version\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]} ]", + 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); + } + } + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ProductOfferingApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Updates partially a ProductOffering", operationId = "patchProductOffering", description = "This operation updates partially a ProductOffering entity." , tags = { + "productOffering", }) + @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 = "/productOffering/{id}", produces = { "application/json;charset=utf-8" }, consumes = { + "application/json;charset=utf-8" }, method = RequestMethod.PATCH) + default ResponseEntity patchProductOffering( + @Parameter(description = "Identifier of the ProductOffering", required = true) @PathVariable("id") String id, + @Parameter(description = "The ProductOffering to be updated", required = true) @Valid @RequestBody ProductOfferingUpdate productOffering) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "{ \"isBundle\" : true, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"serviceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@type\" : \"@type\", \"channel\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"description\" : \"description\", \"productOfferingPrice\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"resourceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"statusReason\" : \"statusReason\", \"bundledProductOffering\" : [ { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"marketSegment\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isSellable\" : true, \"serviceLevelAgreement\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"version\" : \"version\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]}", + ProductOffering.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 ProductOfferingApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "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/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity retrieveProductOffering( + @Parameter(description = "Identifier of the ProductOffering", 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( + "{ \"isBundle\" : true, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"serviceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@type\" : \"@type\", \"channel\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"description\" : \"description\", \"productOfferingPrice\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"resourceCandidate\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"statusReason\" : \"statusReason\", \"bundledProductOffering\" : [ { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"bundledProductOfferingOption\" : { \"@baseType\" : \"@baseType\", \"numberRelOfferDefault\" : 6, \"numberRelOfferLowerLimit\" : 1, \"@type\" : \"@type\", \"numberRelOfferUpperLimit\" : 5, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"marketSegment\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isSellable\" : true, \"serviceLevelAgreement\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"version\" : \"version\", \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"category\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]}", + ProductOffering.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 ProductOfferingApi interface so no example is generated"); + } + 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 new file mode 100644 index 0000000000000000000000000000000000000000..c22b53ea188f9f749058ba2d145b53ed8582501c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingApiController.java @@ -0,0 +1,171 @@ +/*- + * ========================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.pcm620.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.centrallog.client.CLevel; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.pcm620.model.ProductOffering; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingCreate; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingUpdate; +import org.etsi.osl.tmf.pcm620.reposervices.ProductOfferingRepoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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.core.Authentication; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Controller +@RequestMapping("/productCatalogManagement/v4/") +public class ProductOfferingApiController implements ProductOfferingApi { + + Logger log = LoggerFactory.getLogger(ProductOfferingApiController.class); + + + private final ObjectMapper objectMapper; + private final HttpServletRequest request; + + @Autowired + ProductOfferingRepoService productOfferingRepoService; + + + @Value("${spring.application.name}") + private String compname; + + + @Autowired + private CentralLogger centralLogger; + + @org.springframework.beans.factory.annotation.Autowired + public ProductOfferingApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createProductOffering(@Valid ProductOfferingCreate productOffering) { + try { + + ProductOffering c = productOfferingRepoService.addProductOffering(productOffering); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity deleteProductOffering(String id) { + try { + + return new ResponseEntity(productOfferingRepoService.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> listProductOffering(@Valid String fields, @Valid Integer offset, + @Valid Integer limit, + @Valid Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>( + productOfferingRepoService.findAll( myfields, allParams), HttpStatus.OK); +// return new ResponseEntity>(serviceSpecificationRepoService.findAll(), +// HttpStatus.OK); + + + } else { + + + return new ResponseEntity>( + productOfferingRepoService.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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity patchProductOffering(String id, + @Valid ProductOfferingUpdate productOffering) { + ProductOffering c = productOfferingRepoService.updateProductOffering(id, productOffering); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @Override + public ResponseEntity retrieveProductOffering(String id, @Valid String fields) { + try { + + Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); + + if ( attr!=null) { + SecurityContextHolder.setContext( (SecurityContext) attr ); + } + if ( SecurityContextHolder.getContext().getAuthentication() != null ) { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + centralLogger.log( CLevel.INFO, "User " + authentication.getName() + " retrieve spec id: "+ id , compname ); + } else { + centralLogger.log( CLevel.INFO, "Anonymous retrieve spec id: "+ id, compname ); + } + + return new ResponseEntity(productOfferingRepoService.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/pcm620/api/ProductOfferingPriceApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingPriceApi.java new file mode 100644 index 0000000000000000000000000000000000000000..81f97485c8ec3f0d00c88394b6185c6053b43953 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingPriceApi.java @@ -0,0 +1,214 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPrice; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceCreate; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Tag(name = "productOfferingPrice", description = "the productOfferingPrice API") +public interface ProductOfferingPriceApi { + + Logger log = LoggerFactory.getLogger(ProductOfferingPriceApi.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 ProductOfferingPrice", operationId = "createProductOfferingPrice", description = "This operation creates a ProductOfferingPrice entity.", tags={ "productOfferingPrice", }) + @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 = "/productOfferingPrice", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createProductOfferingPrice(@Parameter(description = "The ProductOfferingPrice to be created" ,required=true ) @Valid @RequestBody ProductOfferingPriceCreate productOfferingPrice) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"isBundle\" : true, \"popRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"@type\" : \"@type\", \"description\" : \"description\", \"recurringChargePeriodType\" : \"recurringChargePeriodType\", \"recurringChargePeriodLength\" : 6, \"@baseType\" : \"@baseType\", \"price\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"percentage\" : 0.8008282, \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"bundledPopRelationship\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"unitOfMeasure\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"priceType\" : \"priceType\", \"tax\" : [ { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" }, { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" } ], \"version\" : \"version\", \"pricingLogicAlgorithm\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"constraint\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]}", ProductOfferingPrice.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 ProductOfferingPriceApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ProductOfferingPrice", operationId = "deleteProductOfferingPrice", description = "This operation deletes a ProductOfferingPrice entity.", tags={ "productOfferingPrice", }) + @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 = "/productOfferingPrice/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteProductOfferingPrice(@Parameter(description = "Identifier of the ProductOfferingPrice",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ProductOfferingPriceApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ProductOfferingPrice objects", operationId = "listProductOfferingPrice", description = "This operation list or find ProductOfferingPrice entities" , tags={ "productOfferingPrice", }) + @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 = "/productOfferingPrice", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listProductOfferingPrice(@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, + @Valid Map allParams) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"isBundle\" : true, \"popRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"@type\" : \"@type\", \"description\" : \"description\", \"recurringChargePeriodType\" : \"recurringChargePeriodType\", \"recurringChargePeriodLength\" : 6, \"@baseType\" : \"@baseType\", \"price\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"percentage\" : 0.8008282, \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"bundledPopRelationship\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"unitOfMeasure\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"priceType\" : \"priceType\", \"tax\" : [ { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" }, { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" } ], \"version\" : \"version\", \"pricingLogicAlgorithm\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"constraint\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]}, { \"isBundle\" : true, \"popRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"@type\" : \"@type\", \"description\" : \"description\", \"recurringChargePeriodType\" : \"recurringChargePeriodType\", \"recurringChargePeriodLength\" : 6, \"@baseType\" : \"@baseType\", \"price\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"percentage\" : 0.8008282, \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"bundledPopRelationship\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"unitOfMeasure\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"priceType\" : \"priceType\", \"tax\" : [ { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" }, { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" } ], \"version\" : \"version\", \"pricingLogicAlgorithm\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"constraint\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ProductOfferingPriceApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a ProductOfferingPrice", operationId = "patchProductOfferingPrice", description = "This operation updates partially a ProductOfferingPrice entity.", tags={ "productOfferingPrice", }) + @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 = "/productOfferingPrice/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchProductOfferingPrice(@Parameter(description = "Identifier of the ProductOfferingPrice",required=true) @PathVariable("id") String id,@Parameter(description = "The ProductOfferingPrice to be updated" ,required=true ) @Valid @RequestBody ProductOfferingPriceUpdate productOfferingPrice) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"isBundle\" : true, \"popRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"@type\" : \"@type\", \"description\" : \"description\", \"recurringChargePeriodType\" : \"recurringChargePeriodType\", \"recurringChargePeriodLength\" : 6, \"@baseType\" : \"@baseType\", \"price\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"percentage\" : 0.8008282, \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"bundledPopRelationship\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"unitOfMeasure\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"priceType\" : \"priceType\", \"tax\" : [ { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" }, { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" } ], \"version\" : \"version\", \"pricingLogicAlgorithm\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"constraint\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]}", ProductOfferingPrice.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 ProductOfferingPriceApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ProductOfferingPrice by ID", operationId = "retrieveProductOfferingPrice", description = "This operation retrieves a ProductOfferingPrice entity. Attribute selection is enabled for all first level attributes.", tags={ "productOfferingPrice", }) + @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 = "/productOfferingPrice/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveProductOfferingPrice(@Parameter(description = "Identifier of the ProductOfferingPrice",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("{ \"isBundle\" : true, \"popRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"@type\" : \"@type\", \"description\" : \"description\", \"recurringChargePeriodType\" : \"recurringChargePeriodType\", \"recurringChargePeriodLength\" : 6, \"@baseType\" : \"@baseType\", \"price\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"percentage\" : 0.8008282, \"id\" : \"id\", \"href\" : \"href\", \"place\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@schemaLocation\" : \"@schemaLocation\", \"bundledPopRelationship\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productOfferingTerm\" : [ { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"duration\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"prodSpecCharValueUse\" : [ { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 }, { \"minCardinality\" : 2, \"productSpecification\" : { \"@referredType\" : \"@referredType\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"description\" : \"description\", \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"maxCardinality\" : 5 } ], \"unitOfMeasure\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"priceType\" : \"priceType\", \"tax\" : [ { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" }, { \"taxRate\" : 5.962134, \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"taxAmount\" : { \"unit\" : \"unit\", \"value\" : 1.4658129 }, \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxCategory\" : \"taxCategory\" } ], \"version\" : \"version\", \"pricingLogicAlgorithm\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"plaSpecId\" : \"plaSpecId\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"constraint\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ]}", ProductOfferingPrice.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 ProductOfferingPriceApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingPriceApiController.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingPriceApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..80a9d37164cd9fc311039283f9e2afd33fc900ed --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductOfferingPriceApiController.java @@ -0,0 +1,188 @@ +/*- + * ========================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.pcm620.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.centrallog.client.CLevel; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPrice; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceCreate; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceUpdate; +import org.etsi.osl.tmf.pcm620.reposervices.ProductOfferingPriceRepoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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.core.Authentication; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Controller +@RequestMapping("/productCatalogManagement/v4/") +public class ProductOfferingPriceApiController implements ProductOfferingPriceApi { + + + Logger log = LoggerFactory.getLogger(ProductOfferingPriceApiController.class); + + + @Autowired + ProductOfferingPriceRepoService productOfferingPriceRepoService; + + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + + @Value("${spring.application.name}") + private String compname; + + + @Autowired + private CentralLogger centralLogger; + + + @org.springframework.beans.factory.annotation.Autowired + public ProductOfferingPriceApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createProductOfferingPrice( + @Valid ProductOfferingPriceCreate productOfferingPrice) { + try { + + ProductOfferingPrice c = productOfferingPriceRepoService.addProductOfferingPrice( productOfferingPrice); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity deleteProductOfferingPrice(String id) { + try { + + return new ResponseEntity(productOfferingPriceRepoService.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> listProductOfferingPrice(@Valid String fields, + @Valid Integer offset, @Valid Integer limit, + @Valid Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>( + productOfferingPriceRepoService.findAll( myfields, allParams), HttpStatus.OK); +// return new ResponseEntity>(serviceSpecificationRepoService.findAll(), +// HttpStatus.OK); + + + } else { + + + return new ResponseEntity>( + productOfferingPriceRepoService.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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity patchProductOfferingPrice(String id, + @Valid ProductOfferingPriceUpdate productOfferingPrice) { + ProductOfferingPrice c = productOfferingPriceRepoService.updateProductOfferingPrice(id, productOfferingPrice); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @Override + public ResponseEntity retrieveProductOfferingPrice(String id, @Valid String fields) { + try { + + Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); + + if ( attr!=null) { + SecurityContextHolder.setContext( (SecurityContext) attr ); + } + if ( SecurityContextHolder.getContext().getAuthentication() != null ) { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + centralLogger.log( CLevel.INFO, "User " + authentication.getName() + " retrieve spec id: "+ id , compname ); + } else { + centralLogger.log( CLevel.INFO, "Anonymous retrieve spec id: "+ id, compname ); + } + + return new ResponseEntity(productOfferingPriceRepoService.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/pcm620/api/ProductSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..ba318d19e115cb1cd30131a4ec4363ce6eb5d00d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApi.java @@ -0,0 +1,214 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pcm620.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pcm620.model.ProductSpecification; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCreate; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Tag(name = "productSpecification", description = "the productSpecification API") +public interface ProductSpecificationApi { + + Logger log = LoggerFactory.getLogger(ProductSpecificationApi.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 ProductSpecification", operationId = "createProductSpecification", description = "This operation creates a ProductSpecification entity.", tags={ "productSpecification", }) + @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 = "/productSpecification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createProductSpecification(@Parameter(description = "The ProductSpecification to be created" ,required=true ) @Valid @RequestBody ProductSpecificationCreate productSpecification) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"isBundle\" : true, \"productSpecCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"resourceSpecification\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"serviceSpecification\" : [ { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"description\" : \"description\", \"productNumber\" : \"productNumber\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"bundledProductSpecification\" : [ { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"productSpecificationRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"brand\" : \"brand\"}", ProductSpecification.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 ProductSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ProductSpecification", operationId = "deleteProductSpecification", description = "This operation deletes a ProductSpecification entity.", tags={ "productSpecification", }) + @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 = "/productSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteProductSpecification(@Parameter(description = "Identifier of the ProductSpecification",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ProductSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ProductSpecification objects", operationId = "listProductSpecification", description = "This operation list or find ProductSpecification entities" , tags={ "productSpecification", }) + @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 = "/productSpecification", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listProductSpecification(@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, + @Valid Map allParams) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"isBundle\" : true, \"productSpecCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"resourceSpecification\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"serviceSpecification\" : [ { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"description\" : \"description\", \"productNumber\" : \"productNumber\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"bundledProductSpecification\" : [ { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"productSpecificationRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"brand\" : \"brand\"}, { \"isBundle\" : true, \"productSpecCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"resourceSpecification\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"serviceSpecification\" : [ { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"description\" : \"description\", \"productNumber\" : \"productNumber\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"bundledProductSpecification\" : [ { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"productSpecificationRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"brand\" : \"brand\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ProductSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a ProductSpecification", operationId = "patchProductSpecification", description = "This operation updates partially a ProductSpecification entity.", tags={ "productSpecification", }) + @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 = "/productSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchProductSpecification(@Parameter(description = "Identifier of the ProductSpecification",required=true) @PathVariable("id") String id,@Parameter(description = "The ProductSpecification to be updated" ,required=true ) @Valid @RequestBody ProductSpecificationUpdate productSpecification) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"isBundle\" : true, \"productSpecCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"resourceSpecification\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"serviceSpecification\" : [ { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"description\" : \"description\", \"productNumber\" : \"productNumber\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"bundledProductSpecification\" : [ { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"productSpecificationRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"brand\" : \"brand\"}", ProductSpecification.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 ProductSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ProductSpecification by ID", operationId = "retrieveProductSpecification", description = "This operation retrieves a ProductSpecification entity. Attribute selection is enabled for all first level attributes.", tags={ "productSpecification", }) + @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 = "/productSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveProductSpecification(@Parameter(description = "Identifier of the ProductSpecification",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("{ \"isBundle\" : true, \"productSpecCharacteristic\" : [ { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true }, { \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isUnique\" : true, \"description\" : \"description\", \"maxCardinality\" : 0, \"minCardinality\" : 6, \"regex\" : \"regex\", \"@baseType\" : \"@baseType\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"productSpecCharRelationship\" : [ { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"charSpecSeq\" : 1, \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"productSpecCharacteristicValue\" : [ { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" }, { \"rangeInterval\" : \"rangeInterval\", \"isDefault\" : true, \"regex\" : \"regex\", \"valueTo\" : \"valueTo\", \"unitOfMeasure\" : \"unitOfMeasure\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { }, \"valueFrom\" : \"valueFrom\" } ], \"@schemaLocation\" : \"http://example.com/aeiou\", \"extensible\" : true, \"configurable\" : true } ], \"lifecycleStatus\" : \"lifecycleStatus\", \"targetProductSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"resourceSpecification\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"serviceSpecification\" : [ { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" }, { \"targetServiceSchema\" : { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"version\" : \"version\" } ], \"description\" : \"description\", \"productNumber\" : \"productNumber\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"version\" : \"version\", \"attachment\" : [ { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 0.8008282, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"bundledProductSpecification\" : [ { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"lifecycleStatus\" : \"lifecycleStatus\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\", \"name\" : \"name\", \"productSpecificationRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"brand\" : \"brand\"}", ProductSpecification.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 ProductSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..48b5f47f713a8eb315c851714141c9ec8fea2dc5 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/ProductSpecificationApiController.java @@ -0,0 +1,171 @@ +/*- + * ========================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.pcm620.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.centrallog.client.CLevel; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.pcm620.model.ProductSpecification; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCreate; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationUpdate; +import org.etsi.osl.tmf.pcm620.reposervices.ProductSpecificationRepoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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.core.Authentication; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:15:57.249+03:00") + +@Controller +@RequestMapping("/productCatalogManagement/v4/") +public class ProductSpecificationApiController implements ProductSpecificationApi { + + Logger log = LoggerFactory.getLogger(ProductSpecificationApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Value("${spring.application.name}") + private String compname; + + @Autowired + ProductSpecificationRepoService productSpecificationRepoService; + + @Autowired + private CentralLogger centralLogger; + + @org.springframework.beans.factory.annotation.Autowired + public ProductSpecificationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createProductSpecification( + @Valid ProductSpecificationCreate productSpecification) { + try { + + ProductSpecification c = productSpecificationRepoService.addProductSpecification(productSpecification); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity deleteProductSpecification(String id) { + try { + + return new ResponseEntity(productSpecificationRepoService.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> listProductSpecification(@Valid String fields, + @Valid Integer offset, @Valid Integer limit, + @Parameter(hidden = true) @Valid @RequestParam Map allParams) { + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>( + productSpecificationRepoService.findAll( myfields, allParams), HttpStatus.OK); +// return new ResponseEntity>(serviceSpecificationRepoService.findAll(), +// HttpStatus.OK); + + + } else { + + + return new ResponseEntity>( + productSpecificationRepoService.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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity patchProductSpecification(String id, + @Valid ProductSpecificationUpdate productSpecification) { + ProductSpecification c = productSpecificationRepoService.updateProductSpecification(id, productSpecification); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @Override + public ResponseEntity retrieveProductSpecification(String id, @Valid String fields) { + try { + + Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); + + if ( attr!=null) { + SecurityContextHolder.setContext( (SecurityContext) attr ); + } + if ( SecurityContextHolder.getContext().getAuthentication() != null ) { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + centralLogger.log( CLevel.INFO, "User " + authentication.getName() + " retrieve spec id: "+ id , compname ); + } else { + centralLogger.log( CLevel.INFO, "Anonymous retrieve spec id: "+ id, compname ); + } + + return new ResponseEntity( productSpecificationRepoService.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/pcm620/api/RFC3339DateFormat.java b/src/main/java/org/etsi/osl/tmf/pcm620/api/RFC3339DateFormat.java new file mode 100644 index 0000000000000000000000000000000000000000..fc86830ffc164aa9182d19836feabc00b70fde5a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/api/RFC3339DateFormat.java @@ -0,0 +1,41 @@ +/*- + * ========================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.pcm620.api; + +import java.text.FieldPosition; +import java.util.Date; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + + +public class RFC3339DateFormat extends ISO8601DateFormat { + + private static final long serialVersionUID = 1L; + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/repo/AttachmentRepository.java b/src/main/java/org/etsi/osl/tmf/pcm620/repo/AttachmentRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..99741aaf1cc31d49e4e90b96c4e222df22f27a99 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/repo/AttachmentRepository.java @@ -0,0 +1,39 @@ +/*- + * ========================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.pcm620.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.Attachment; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface AttachmentRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + List findByNameContaining(String name); + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductCatalogRepository.java b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductCatalogRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..37a7a2b945614ec6aa808ff9c55d68a0b9a17d01 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductCatalogRepository.java @@ -0,0 +1,37 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.pcm620.model.Catalog; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductCatalogRepository extends CrudRepository, PagingAndSortingRepository{ + + Optional findByUuid(String id); + + Optional findByName(String aName); + + List findByOrderByName(); +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductCategoriesRepository.java b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductCategoriesRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..954154e775e336634754f8963e0aeef9d39413fa --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductCategoriesRepository.java @@ -0,0 +1,38 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.pcm620.model.Category; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductCategoriesRepository extends CrudRepository,PagingAndSortingRepository { + + Optional findByUuid(String id); + + Optional findByName(String aName); + + List findByOrderByName(); + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductOfferingPriceRepository.java b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductOfferingPriceRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..1f7cdefa7538067b00d5b4ba298a91b88e6532da --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductOfferingPriceRepository.java @@ -0,0 +1,38 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPrice; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductOfferingPriceRepository extends CrudRepository, PagingAndSortingRepository { + + Optional findByUuid(String id); + + List findByNameAndVersion(String aname, String aversion); + + List findByOrderByName(); + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductOfferingRepository.java b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductOfferingRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..7661e35fda65d1282cfdd90614c63cc33474c781 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductOfferingRepository.java @@ -0,0 +1,38 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.pcm620.model.ProductOffering; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductOfferingRepository extends CrudRepository,PagingAndSortingRepository { + + Optional findByUuid(String id); + + List findByNameAndVersion(String aname, String aversion); + + List findByOrderByName(); + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductSpecificationRepository.java b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductSpecificationRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..689acbb5bc0c10d5b40d49d64327a7b8ac32cd9e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/repo/ProductSpecificationRepository.java @@ -0,0 +1,38 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.pcm620.model.ProductSpecification; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ProductSpecificationRepository extends CrudRepository, PagingAndSortingRepository { + + Optional findByUuid(String id); + + List findByNameAndVersion(String aname, String aversion); + + List findByOrderByName(); + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/AttachmentRepoService.java b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/AttachmentRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..6f994e5a4cc00935afc85c9e81ed4b29b8e2361e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/AttachmentRepoService.java @@ -0,0 +1,58 @@ +/*- + * ========================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.pcm620.reposervices; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.pcm620.repo.AttachmentRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import jakarta.validation.Valid; + + +@Service +public class AttachmentRepoService { + + + @Autowired + AttachmentRepository attachmentRepo; + + public Attachment addAttachment(Attachment c) { + + return this.attachmentRepo.save(c); + } + + public Attachment updateAttachment(@Valid Attachment attachment) { + return this.attachmentRepo.save( attachment ); + } + + public Attachment findByUuid(String attid) { + Optional ret = this.attachmentRepo.findByUuid(attid); + return ret.orElse(null); + + } + + public List findByLogoName(String attid) { + + List ret = this.attachmentRepo.findByNameContaining(attid); + return ret; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCatalogRepoService.java b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCatalogRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..126999bd90598748e8c8d91146cb28b070f282ac --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCatalogRepoService.java @@ -0,0 +1,135 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.reposervices; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.pcm620.model.Catalog; +import org.etsi.osl.tmf.pcm620.model.CatalogCreate; +import org.etsi.osl.tmf.pcm620.model.CatalogUpdate; +import org.etsi.osl.tmf.pcm620.model.Category; +import org.etsi.osl.tmf.pcm620.model.CategoryRef; +import org.etsi.osl.tmf.pcm620.repo.ProductCatalogRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import jakarta.validation.Valid; + +@Service +public class ProductCatalogRepoService { + + + @Autowired + ProductCatalogRepository catalogRepo; + + @Autowired + ProductCategoryRepoService categRepoService; + + + public Catalog addCatalog(Catalog c) { + + return this.catalogRepo.save(c); + } + + public Catalog addCatalog(@Valid CatalogCreate serviceCat) { + + Catalog sc = new Catalog(); + + sc = updateCatalogDataFromAPICall(sc, serviceCat); + return this.catalogRepo.save(sc); + } + + public List findAll() { + return (List) this.catalogRepo.findByOrderByName(); + } + + public Catalog findById(String id) { + Optional optionalCat = this.catalogRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + + public Catalog findByName(String aName) { + Optional optionalCat = this.catalogRepo.findByName( aName ); + return optionalCat.orElse(null); + } + + public Void deleteById(String id) { + Optional optionalCat = this.catalogRepo.findByUuid(id); + this.catalogRepo.delete(optionalCat.get()); + return null; + + } + + public Catalog updateCatalog(String id, CatalogUpdate Catalog) { + + Optional optSC = catalogRepo.findByUuid(id); + if (optSC == null) { + return null; + } + Catalog sc = optSC.get(); + sc = updateCatalogDataFromAPICall(sc, Catalog); + return this.catalogRepo.save(sc); + } + + public Catalog updateCatalogDataFromAPICall(Catalog sc, CatalogUpdate Catalog) { + + if (Catalog.getName()!=null){ + sc.setName(Catalog.getName()); + } + if (Catalog.getDescription()!=null){ + sc.setDescription(Catalog.getDescription()); + } + if (Catalog.getLifecycleStatus() != null) { + sc.setLifecycleStatusEnum(ELifecycle.getEnum(Catalog.getLifecycleStatus())); + } + if (Catalog.getVersion() != null) { + sc.setVersion(Catalog.getVersion()); + } + sc.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + TimePeriod tp = new TimePeriod(); + if (Catalog.getValidFor() != null) { + tp.setStartDateTime(Catalog.getValidFor().getStartDateTime()); + tp.setEndDateTime(Catalog.getValidFor().getEndDateTime()); + sc.setValidFor(tp); + } + + // add any new category + if (Catalog.getCategory() != null) { + + sc.getCategoryObj().clear(); + for (CategoryRef scref : Catalog.getCategory()) { + Category servcat = this.categRepoService.findByUuid(scref.getId()); + sc.addCategory(servcat); + } + } + + return sc; + + } + + public Catalog updateCatalog(Catalog scatalog) { + return this.catalogRepo.save(scatalog); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCategoryRepoService.java b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCategoryRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..60ebcca044262ec1f144f26d8f63ca2e01d46891 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductCategoryRepoService.java @@ -0,0 +1,324 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.reposervices; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.pcm620.model.Category; +import org.etsi.osl.tmf.pcm620.model.CategoryCreate; +import org.etsi.osl.tmf.pcm620.model.CategoryRef; +import org.etsi.osl.tmf.pcm620.model.CategoryUpdate; +import org.etsi.osl.tmf.pcm620.model.ProductOffering; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingRef; +import org.etsi.osl.tmf.pcm620.repo.ProductCatalogRepository; +import org.etsi.osl.tmf.pcm620.repo.ProductCategoriesRepository; +import org.etsi.osl.tmf.pcm620.repo.ProductOfferingRepository; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class ProductCategoryRepoService { + + @Autowired + ProductCategoriesRepository categsRepo; + + @Autowired + ProductCatalogRepository catalogRepo; + + @Autowired + ProductOfferingRepository prodsOfferingRepo; + + private SessionFactory sessionFactory; + + /** + * from + * https://stackoverflow.com/questions/25063995/spring-boot-handle-to-hibernate-sessionfactory + * + * @param factory + */ + @Autowired + public ProductCategoryRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + + public Category addCategory(Category c) { + + return this.categsRepo.save( c ); + } + + public Category addCategory(@Valid CategoryCreate Category) { + + + Category sc = new Category() ; + sc = updateCategoryDataFromAPICall(sc, Category); + return this.categsRepo.save( sc ); + + } + + public List findAll() { + return (List) this.categsRepo.findByOrderByName(); + } + + public Category findByUuid(String id) { + Optional optionalCat = this.categsRepo.findByUuid( id ); + return optionalCat + .orElse(null); + } + + + public Category findByIdEager(String id) { +// Optional optionalCat = this.categsRepo.findByIdEager( id ); +// return optionalCat +// .orElse(null); + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + Category dd = null; + try { + dd = (Category) session.get(Category.class, id); + Hibernate.initialize( dd.getCategoryObj() ); + Hibernate.initialize( dd.getProductOfferingRefs() ); + for (ProductOfferingRef sc : dd.getProductOfferingRefs()) { + Hibernate.initialize(sc ); + } + + tx.commit(); + } finally { + session.close(); + } + return dd; + } + + + + + + public boolean deleteById(String id) { + Optional optionalCat = this.categsRepo.findByUuid( id ); + if ( optionalCat.get().getCategoryObj().size()>0 ) { + return false; //has children + } + + + if ( optionalCat.get().getParentId() != null ) { + Category parentCat = (this.categsRepo.findByUuid( optionalCat.get().getParentId() )).get(); + + //remove from parent category + for (Category ss : parentCat.getCategoryObj()) { + if ( ss.getId() == optionalCat.get().getId() ) { + parentCat.getCategoryObj().remove(ss); + break; + } + } + parentCat = this.categsRepo.save(parentCat); + } + + + this.categsRepo.delete( optionalCat.get()); + return true; + + } + + public Category updateCategory(String id, @Valid CategoryUpdate Category) { + Optional optionalCat = this.categsRepo.findByUuid( id ); + if ( optionalCat == null ) { + return null; + } + + Category sc = optionalCat.get(); + sc = updateCategoryDataFromAPICall(sc, Category); + return this.categsRepo.save( sc ); + } + + public Category updateCategoryDataFromAPICall( Category acat, CategoryUpdate prodCatUpd ) + { + if (prodCatUpd.getName()!=null) { + acat.setName( prodCatUpd.getName() ); + } + if (prodCatUpd.getDescription()!=null) { + acat.setDescription( prodCatUpd.getDescription()); + } + if ( prodCatUpd.isIsRoot() != null ) { + acat.setIsRoot( prodCatUpd.isIsRoot()); + } + + if ( prodCatUpd.getLifecycleStatus() != null ) { + acat.setLifecycleStatusEnum ( ELifecycle.getEnum( prodCatUpd.getLifecycleStatus() ) ); + } + + + if ( prodCatUpd.getVersion() != null ) { + acat.setVersion( prodCatUpd.getVersion() ); + } + acat.setLastUpdate( OffsetDateTime.now(ZoneOffset.UTC) ); + TimePeriod tp = new TimePeriod(); + if ( prodCatUpd.getValidFor() != null ) { + tp.setStartDateTime( prodCatUpd.getValidFor().getStartDateTime() ); + tp.setEndDateTime( prodCatUpd.getValidFor().getEndDateTime() ); + acat.setValidFor( tp ); + } + + if ( prodCatUpd.getProductOffering() != null ) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + for (ProductOfferingRef por : prodCatUpd.getProductOffering()) { + //find by id and reload it here. + boolean idexists = false; + for (ProductOfferingRef originalProfOffRef : acat.getProductOfferingRefs()) { + if ( originalProfOffRef.getId().equals( por.getId())) { + idexists = true; + idAddedUpdated.put( originalProfOffRef.getId(), true); + break; + } + } + if (!idexists) { + Optional profOffToAdd = this.prodsOfferingRepo.findByUuid( por.getId() ); + if ( profOffToAdd.isPresent() ) { + ProductOffering poffget = profOffToAdd.get(); + + + acat.getProductOfferingObj().add(poffget); + idAddedUpdated.put( poffget.getId(), true); + + + + } + } + } + List toRemove = new ArrayList<>(); + for (ProductOfferingRef ss : acat.getProductOfferingRefs()) { + if ( idAddedUpdated.get( ss.getId() ) == null ) { + toRemove.add(ss); + } + } + + for (ProductOfferingRef ar : toRemove) { + Optional profOffToDelete = this.prodsOfferingRepo.findByUuid( ar.getId() ); + if ( profOffToDelete.isPresent() ) { + acat.getProductOfferingObj().remove(profOffToDelete.get()); + + } + } + + } + + + if ( prodCatUpd.getSubCategory() !=null ) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (CategoryRef ref : prodCatUpd.getSubCategory() ) { + //find by id and reload it here. + boolean idexists = false; + for (Category originalSCat : acat.getCategoryObj()) { + if ( originalSCat.getId().equals( ref.getId())) { + idexists = true; + idAddedUpdated.put( originalSCat.getId(), true); + break; + } + } + if (!idexists) { + Optional catToAdd = this.categsRepo.findByUuid( ref.getId() ); + if ( catToAdd.isPresent() ) { + Category scatadd = catToAdd.get(); + acat.getCategoryObj().add( scatadd ); + idAddedUpdated.put( ref.getId(), true); + + scatadd.setParentId( acat.getUuid()); + scatadd = this.categsRepo.save( scatadd ); + } + } + } + List toRemove = new ArrayList<>(); + for (Category ss : acat.getCategoryObj()) { + if ( idAddedUpdated.get( ss.getId() ) == null ) { + toRemove.add(ss); + } + } + + for (Category ar : toRemove) { + acat.getCategoryObj().remove(ar); + } + } + + +// if ( prodCatUpd.getServiceCandidate() !=null ) { +// //reattach fromDB +// Map idAddedUpdated = new HashMap<>(); +// +// for (ServiceCandidateRef ref : prodCatUpd.getServiceCandidate() ) { +// //find by id and reload it here. +// boolean idexists = false; +// for (ServiceCandidate originalSCat : acat.getServiceCandidateObj()) { +// if ( originalSCat.getId().equals( ref.getId())) { +// idexists = true; +// idAddedUpdated.put( originalSCat.getId(), true); +// break; +// } +// } +// if (!idexists) { +// Optional catToAdd = this.candidateRepo.findByUuid( ref.getId() ); +// if ( catToAdd.isPresent() ) { +// ServiceCandidate scatadd = catToAdd.get(); +// acat.getServiceCandidateObj().add( scatadd ); +// idAddedUpdated.put( ref.getId(), true); +// +// } +// } +// } +// List toRemove = new ArrayList<>(); +// for (ServiceCandidate ss : acat.getServiceCandidateObj()) { +// if ( idAddedUpdated.get( ss.getId() ) == null ) { +// toRemove.add(ss); +// } +// } +// +// for (ServiceCandidate ar : toRemove) { +// acat.getServiceCandidateObj().remove(ar); +// } +// } + + return acat; + } + + + public Category findByName(String aName) { + Optional optionalCat = this.categsRepo.findByName( aName ); + return optionalCat + .orElse(null); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingPriceRepoService.java b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingPriceRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..bffff81ec013962bf143190de4dfc67911472caa --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingPriceRepoService.java @@ -0,0 +1,354 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.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.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPrice; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceCreate; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceUpdate; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCharacteristicValueUse; +import org.etsi.osl.tmf.pcm620.repo.ProductOfferingPriceRepository; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class ProductOfferingPriceRepoService { + + + @Autowired + ProductOfferingPriceRepository prodsOfferingRepo; + + + + private SessionFactory sessionFactory; + + + /** + * from + * https://stackoverflow.com/questions/25063995/spring-boot-handle-to-hibernate-sessionfactory + * + * @param factory + */ + @Autowired + public ProductOfferingPriceRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public ProductOfferingPrice addProductOfferingPrice(@Valid ProductOfferingPriceCreate serviceProductOfferingPrice) { + + ProductOfferingPrice serviceSpec = new ProductOfferingPrice(); + serviceSpec = this.updateProductOfferingPriceDataFromAPIcall(serviceSpec, serviceProductOfferingPrice); + serviceSpec = this.prodsOfferingRepo.save(serviceSpec); + + + return this.prodsOfferingRepo.save(serviceSpec); + } + + public List findAll() { + return (List) this.prodsOfferingRepo.findByOrderByName(); + } + + /** + * + * This findAll is optimized on fields. + * @param fields + * @param allParams + * @return + * @throws UnsupportedEncodingException + */ + @Transactional + public List findAll(@Valid String fields, Map allParams) + throws UnsupportedEncodingException { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { +// String sql = "SELECT s FROM ProductOfferingPrice s"; + String sql = "SELECT " + + "s.uuid as uuid," + + "s.id as id," + + "s.name as name," + + "s.description as description," + + "s.isBundle as isBundle," + + "s.version as version," + + "s.type as type"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM ProductOfferingPrice s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.name"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ProductOfferingPrice s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + + } + +// @Transactional(propagation=Propagation.REQUIRED , readOnly=true, +// noRollbackFor=Exception.class) + public ProductOfferingPrice findByUuid(String id) { + Optional optionalCat = this.prodsOfferingRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + public ProductOfferingPrice findByUuidEager(String id) { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); // instead of begin transaction, is it possible to continue? + ProductOfferingPrice dd = null; + try { + dd = session.get(ProductOfferingPrice.class, id); + if (dd == null) { + return this.findByUuid(id);// last resort + } + Hibernate.initialize(dd.getConstraint() ); + Hibernate.initialize(dd.getPlace() ); + Hibernate.initialize(dd.getBundledPopRelationship()); + Hibernate.initialize(dd.getProductOfferingTerm()); + Hibernate.initialize(dd.getTax() ); + for (ProductSpecificationCharacteristicValueUse schar : dd.getProdSpecCharValueUse()) { + Hibernate.initialize(schar.getProductSpecCharacteristicValue() ); + + } + Hibernate.initialize(dd.getPricingLogicAlgorithm() ) ; + + tx.commit(); + } finally { + session.close(); + } + return dd; + } + + public Void deleteByUuid(String id) { + Optional optionalCat = this.prodsOfferingRepo.findByUuid(id); + ProductOfferingPrice s = optionalCat.get(); + if (s == null) { + return null; + } + + + /** + * prior deleting we need to delete other dependency objects + */ + + this.prodsOfferingRepo.delete(s); + return null; + } + + + @Transactional + public ProductOfferingPrice updateProductOfferingPrice(String id, + @Valid ProductOfferingPriceUpdate aProductOfferingPrice) { + + ProductOfferingPrice s = this.findByUuid(id); + if (s == null) { + return null; + } + ProductOfferingPrice prodOff = s; + prodOff = this.updateProductOfferingPriceDataFromAPIcall(prodOff, aProductOfferingPrice); + + prodOff = this.prodsOfferingRepo.save(prodOff); + + + + return this.prodsOfferingRepo.save(prodOff); + + } + + + @Transactional + private ProductOfferingPrice updateProductOfferingPriceDataFromAPIcall(ProductOfferingPrice prodOffering, + ProductOfferingPriceUpdate prodOfferingUpd) { + + + + if (prodOfferingUpd.getName() != null) { + prodOffering.setName(prodOfferingUpd.getName()); + } + + if (prodOfferingUpd.getDescription() != null) { + prodOffering.setDescription(prodOfferingUpd.getDescription()); + + } + + if (prodOfferingUpd.isIsBundle() != null) { + prodOffering.isBundle(prodOfferingUpd.isIsBundle()); + } + + + + prodOffering.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + + + if (prodOfferingUpd.getLifecycleStatus() != null) { + prodOffering.setLifecycleStatusEnum(ELifecycle.getEnum(prodOfferingUpd.getLifecycleStatus())); + } + + if (prodOfferingUpd.getVersion() != null) { + prodOffering.setVersion(prodOfferingUpd.getVersion()); + } + + + + + + + /** + * Update ServiceSpecCharacteristic list We need to compare by name, since IDs + * will not exist + */ + if (prodOfferingUpd.getProdSpecCharValueUse() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (ProductSpecificationCharacteristicValueUse charUpd : prodOfferingUpd.getProdSpecCharValueUse()) { + + boolean nameExists = false; + for (ProductSpecificationCharacteristicValueUse originalProdChar : prodOffering.getProdSpecCharValueUse()) { + if (originalProdChar.getName().equals(charUpd.getName())) { + nameExists = true; + idAddedUpdated.put(originalProdChar.getName(), true); + originalProdChar.updateWith(charUpd); + break; + } + } + + if (!nameExists) { + prodOffering.getProdSpecCharValueUse().add(new ProductSpecificationCharacteristicValueUse(charUpd)); + idAddedUpdated.put(charUpd.getName(), true); + } + + } + + List toRemove = new ArrayList<>(); + for (ProductSpecificationCharacteristicValueUse ss : prodOffering.getProdSpecCharValueUse()) { + if (idAddedUpdated.get(ss.getName()) == null) { + toRemove.add(ss); + } + } + + for (ProductSpecificationCharacteristicValueUse serviceSpecCharacteristic : toRemove) { + prodOffering.getProdSpecCharValueUse().remove(serviceSpecCharacteristic); + } + + } + + + + + + + TimePeriod tp = new TimePeriod(); + if (prodOfferingUpd.getValidFor() != null) { + tp.setStartDateTime(prodOfferingUpd.getValidFor().getStartDateTime()); + tp.setEndDateTime(prodOfferingUpd.getValidFor().getEndDateTime()); + prodOffering.setValidFor(tp); + } + + + + return prodOffering; + } + +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..b53dd5b0be6b91e419e748ff62d1583c3582dc58 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductOfferingRepoService.java @@ -0,0 +1,546 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.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.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.am651.model.AgreementRef; +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.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.ProductSpecificationCharacteristicValueUse; +import org.etsi.osl.tmf.pcm620.repo.ProductOfferingRepository; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class ProductOfferingRepoService { + + + @Autowired + ProductOfferingRepository prodsOfferingRepo; + + + + private SessionFactory sessionFactory; + + + /** + * from + * https://stackoverflow.com/questions/25063995/spring-boot-handle-to-hibernate-sessionfactory + * + * @param factory + */ + @Autowired + public ProductOfferingRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public ProductOffering addProductOffering(@Valid ProductOfferingCreate serviceProductOffering) { + + ProductOffering serviceSpec = new ProductOffering(); + serviceSpec = this.updateProductOfferingDataFromAPIcall(serviceSpec, serviceProductOffering); + serviceSpec = this.prodsOfferingRepo.save(serviceSpec); + + + return this.prodsOfferingRepo.save(serviceSpec); + } + + public List findAll() { + return (List) this.prodsOfferingRepo.findByOrderByName(); + } + + /** + * + * This findAll is optimized on fields. + * @param fields + * @param allParams + * @return + * @throws UnsupportedEncodingException + */ + @Transactional + public List findAll(@Valid String fields, Map allParams) + throws UnsupportedEncodingException { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { +// String sql = "SELECT s FROM ProductOffering s"; + String sql = "SELECT " + + "s.uuid as uuid," + + "s.name as name," + + "s.description as description," + + "s.isBundle as isBundle," + + "s.version as version," + + "s.type as type"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM ProductOffering s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.name"; + + + + List mapaEntity = session + .createQuery(sql ) + .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 != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ProductOffering s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + + } + +// @Transactional(propagation=Propagation.REQUIRED , readOnly=true, +// noRollbackFor=Exception.class) + public ProductOffering findByUuid(String id) { + Optional optionalCat = this.prodsOfferingRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + public ProductOffering findByUuidEager(String id) { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); // instead of begin transaction, is it possible to continue? + ProductOffering dd = null; + try { + dd = session.get(ProductOffering.class, id); + if (dd == null) { + return this.findByUuid(id);// last resort + } + Hibernate.initialize(dd.getAttachment()); + Hibernate.initialize(dd.getAgreement() ); + Hibernate.initialize(dd.getBundledProductOffering() ); + Hibernate.initialize(dd.getCategory()); + Hibernate.initialize(dd.getMarketSegment()); + for (ProductSpecificationCharacteristicValueUse schar : dd.getProdSpecCharValueUse()) { + Hibernate.initialize(schar.getProductSpecCharacteristicValue() ); + + } + Hibernate.initialize(dd.getPlace() ); + Hibernate.initialize(dd.getProductOfferingPrice() ); + Hibernate.initialize(dd.getProductOfferingTerm() ); + Hibernate.initialize(dd.getServiceCandidate() ); + Hibernate.initialize(dd.getResourceCandidate() ); + + tx.commit(); + } finally { + session.close(); + } + return dd; + } + + public Void deleteByUuid(String id) { + Optional optionalCat = this.prodsOfferingRepo.findByUuid(id); + ProductOffering s = optionalCat.get(); + if (s == null) { + return null; + } + + + /** + * prior deleting we need to delete other dependency objects + */ + + this.prodsOfferingRepo.delete(s); + return null; + } + + + @Transactional + public ProductOffering updateProductOffering(String id, + @Valid ProductOfferingUpdate aProductOffering) { + + ProductOffering s = this.findByUuid(id); + if (s == null) { + return null; + } + ProductOffering prodOff = s; + prodOff = this.updateProductOfferingDataFromAPIcall(prodOff, aProductOffering); + + prodOff = this.prodsOfferingRepo.save(prodOff); + + + + return this.prodsOfferingRepo.save(prodOff); + + } + + + @Transactional + private ProductOffering updateProductOfferingDataFromAPIcall(ProductOffering prodOffering, + ProductOfferingUpdate prodOfferingUpd) { + + + + if (prodOfferingUpd.getName() != null) { + prodOffering.setName(prodOfferingUpd.getName()); + } + + if (prodOfferingUpd.getDescription() != null) { + prodOffering.setDescription(prodOfferingUpd.getDescription()); + + } + + if (prodOfferingUpd.isIsBundle() != null) { + prodOffering.isBundle(prodOfferingUpd.isIsBundle()); + } + + if (prodOfferingUpd.isIsSellable() != null) { + prodOffering.isSellable(prodOfferingUpd.isIsSellable()); + + } + + if (prodOfferingUpd.getStatusReason() != null) { + prodOffering.setStatusReason(prodOfferingUpd.getStatusReason()); + + } + + prodOffering.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + + + if (prodOfferingUpd.getLifecycleStatus() != null) { + prodOffering.setLifecycleStatusEnum(ELifecycle.getEnum(prodOfferingUpd.getLifecycleStatus())); + } + + if (prodOfferingUpd.getVersion() != null) { + prodOffering.setVersion(prodOfferingUpd.getVersion()); + } + + if ( prodOfferingUpd.getServiceLevelAgreement() != null ) { + prodOffering.setServiceLevelAgreement( prodOfferingUpd.getServiceLevelAgreement() ); + } + + if ( prodOfferingUpd.getServiceCandidate() != null ) { + prodOffering.setServiceCandidate( prodOfferingUpd.getServiceCandidate() ); + } + + if ( prodOfferingUpd.getResourceCandidate() != null ) { + prodOffering.setResourceCandidate( prodOfferingUpd.getResourceCandidate() ); + } + + if ( prodOfferingUpd.getProductSpecification() != null ) { + prodOffering.setProductSpecification( prodOfferingUpd.getProductSpecification() ); + } + + + /** + * Update Attachment list + */ + if (prodOfferingUpd.getAttachment() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (AttachmentRefOrValue ar : prodOfferingUpd.getAttachment()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (AttachmentRefOrValue orinalAtt : prodOffering.getAttachment()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + prodOffering.getAttachment().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (AttachmentRefOrValue ss : prodOffering.getAttachment()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (AttachmentRefOrValue ar : toRemove) { + prodOffering.getAttachment().remove(ar); + } + + } + + + + + + /** + * Update ServiceSpecCharacteristic list We need to compare by name, since IDs + * will not exist + */ + if (prodOfferingUpd.getProdSpecCharValueUse() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (ProductSpecificationCharacteristicValueUse charUpd : prodOfferingUpd.getProdSpecCharValueUse()) { + + boolean nameExists = false; + for (ProductSpecificationCharacteristicValueUse originalProdChar : prodOffering.getProdSpecCharValueUse()) { + if (originalProdChar.getName().equals(charUpd.getName())) { + nameExists = true; + idAddedUpdated.put(originalProdChar.getName(), true); + originalProdChar.updateWith(charUpd); + break; + } + } + + if (!nameExists) { + prodOffering.getProdSpecCharValueUse().add(new ProductSpecificationCharacteristicValueUse(charUpd)); + idAddedUpdated.put(charUpd.getName(), true); + } + + } + + List toRemove = new ArrayList<>(); + for (ProductSpecificationCharacteristicValueUse ss : prodOffering.getProdSpecCharValueUse()) { + if (idAddedUpdated.get(ss.getName()) == null) { + toRemove.add(ss); + } + } + + for (ProductSpecificationCharacteristicValueUse serviceSpecCharacteristic : toRemove) { + prodOffering.getProdSpecCharValueUse().remove(serviceSpecCharacteristic); + } + + } + + + + /** + * Update ProductOfferingPriceRef list + */ + if (prodOfferingUpd.getProductOfferingPrice() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ProductOfferingPriceRef ar : prodOfferingUpd.getProductOfferingPrice()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (ProductOfferingPriceRef orinalAtt : prodOffering.getProductOfferingPrice()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + prodOffering.getProductOfferingPrice().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (ProductOfferingPriceRef ss : prodOffering.getProductOfferingPrice()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (ProductOfferingPriceRef ar : toRemove) { + prodOffering.getProductOfferingPrice().remove(ar); + } + + } + + + + /** + * Update BundledProductOffering list + */ + if (prodOfferingUpd.getBundledProductOffering() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (BundledProductOffering ar : prodOfferingUpd.getBundledProductOffering()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (BundledProductOffering orinalAtt : prodOffering.getBundledProductOffering()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + prodOffering.getBundledProductOffering().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (BundledProductOffering ss : prodOffering.getBundledProductOffering()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (BundledProductOffering ar : toRemove) { + prodOffering.getBundledProductOffering().remove(ar); + } + + } + + + + /** + * Update BundledProductOffering list + */ + if (prodOfferingUpd.getAgreement() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (AgreementRef ar : prodOfferingUpd.getAgreement()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (AgreementRef orinalAtt : prodOffering.getAgreement()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + prodOffering.getAgreement().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (AgreementRef ss : prodOffering.getAgreement()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (AgreementRef ar : toRemove) { + prodOffering.getAgreement().remove(ar); + } + + } + + + TimePeriod tp = new TimePeriod(); + if (prodOfferingUpd.getValidFor() != null) { + tp.setStartDateTime(prodOfferingUpd.getValidFor().getStartDateTime()); + tp.setEndDateTime(prodOfferingUpd.getValidFor().getEndDateTime()); + prodOffering.setValidFor(tp); + } + + + + return prodOffering; + } + +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..2994b2aea69a05b52b4309ccf9da950156f8cdd2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pcm620/reposervices/ProductSpecificationRepoService.java @@ -0,0 +1,601 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.pcm620.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.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +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.BundledProductSpecification; +import org.etsi.osl.tmf.pcm620.model.ProductSpecification; +import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCharacteristic; +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.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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class ProductSpecificationRepoService { + + + @Autowired + ProductSpecificationRepository prodsOfferingRepo; + + + + private SessionFactory sessionFactory; + + + /** + * from + * https://stackoverflow.com/questions/25063995/spring-boot-handle-to-hibernate-sessionfactory + * + * @param factory + */ + @Autowired + public ProductSpecificationRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public ProductSpecification addProductSpecification(@Valid ProductSpecificationCreate serviceProductSpecification) { + + ProductSpecification serviceSpec = new ProductSpecification(); + serviceSpec = this.updateProductSpecificationDataFromAPIcall(serviceSpec, serviceProductSpecification); + serviceSpec = this.prodsOfferingRepo.save(serviceSpec); + + + return this.prodsOfferingRepo.save(serviceSpec); + } + + public List findAll() { + return (List) this.prodsOfferingRepo.findByOrderByName(); + } + + /** + * + * This findAll is optimized on fields. + * @param fields + * @param allParams + * @return + * @throws UnsupportedEncodingException + */ + @Transactional + public List findAll(@Valid String fields, Map allParams) + throws UnsupportedEncodingException { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { +// String sql = "SELECT s FROM ProductSpecification s"; + String sql = "SELECT " + + "s.uuid as uuid," + + "s.name as name," + + "s.description as description," + + "s.isBundle as isBundle," + + "s.version as version," + + "s.type as type"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM ProductSpecification s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.name"; + + + + List mapaEntity = session + .createQuery(sql ) + .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 != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ProductSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + + } + +// @Transactional(propagation=Propagation.REQUIRED , readOnly=true, +// noRollbackFor=Exception.class) + public ProductSpecification findByUuid(String id) { + Optional optionalCat = this.prodsOfferingRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + public ProductSpecification findByUuidEager(String id) { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); // instead of begin transaction, is it possible to continue? + ProductSpecification dd = null; + try { + dd = session.get(ProductSpecification.class, id); + if (dd == null) { + 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() ); + for (ProductSpecificationCharacteristic schar : dd.getProductSpecCharacteristic() ) { + Hibernate.initialize(schar.getProductSpecCharacteristicValue() ); + + } + + + tx.commit(); + } finally { + session.close(); + } + return dd; + } + + public Void deleteByUuid(String id) { + Optional optionalCat = this.prodsOfferingRepo.findByUuid(id); + ProductSpecification s = optionalCat.get(); + if (s == null) { + return null; + } + + + /** + * prior deleting we need to delete other dependency objects + */ + + this.prodsOfferingRepo.delete(s); + return null; + } + + + @Transactional + public ProductSpecification updateProductSpecification(String id, + @Valid ProductSpecificationUpdate aProductSpecification) { + + ProductSpecification s = this.findByUuid(id); + if (s == null) { + return null; + } + ProductSpecification prodOff = s; + prodOff = this.updateProductSpecificationDataFromAPIcall(prodOff, aProductSpecification); + + prodOff = this.prodsOfferingRepo.save(prodOff); + + + + return this.prodsOfferingRepo.save(prodOff); + + } + + + @Transactional + private ProductSpecification updateProductSpecificationDataFromAPIcall(ProductSpecification prodSpec, + ProductSpecificationUpdate prodSpecUpd) { + + + + if (prodSpecUpd.getName() != null) { + prodSpec.setName(prodSpecUpd.getName()); + } + + if (prodSpecUpd.getDescription() != null) { + prodSpec.setDescription(prodSpecUpd.getDescription()); + + } + + if (prodSpecUpd.isIsBundle() != null) { + prodSpec.isBundle(prodSpecUpd.isIsBundle()); + } + + if (prodSpecUpd.getBrand() != null) { + prodSpec.setBrand( prodSpecUpd.getBrand() ); + + } + + if (prodSpecUpd.getProductNumber() != null) { + prodSpec.setProductNumber(prodSpecUpd.getProductNumber()); + + } + + prodSpec.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + + + if (prodSpecUpd.getLifecycleStatus() != null) { + prodSpec.setLifecycleStatusEnum(ELifecycle.getEnum(prodSpecUpd.getLifecycleStatus())); + } + + if (prodSpecUpd.getVersion() != null) { + prodSpec.setVersion(prodSpecUpd.getVersion()); + } + + + + /** + * Update Attachment list + */ + if (prodSpecUpd.getAttachment() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (AttachmentRefOrValue ar : prodSpecUpd.getAttachment()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (AttachmentRefOrValue orinalAtt : prodSpec.getAttachment()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + prodSpec.getAttachment().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (AttachmentRefOrValue ss : prodSpec.getAttachment()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (AttachmentRefOrValue ar : toRemove) { + prodSpec.getAttachment().remove(ar); + } + + } + + + + + /** + * Update BundledProductSpecification list + */ + if (prodSpecUpd.getBundledProductSpecification() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (BundledProductSpecification ar : prodSpecUpd.getBundledProductSpecification()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (BundledProductSpecification orinalAtt : prodSpec.getBundledProductSpecification()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + prodSpec.getBundledProductSpecification().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (BundledProductSpecification ss : prodSpec.getBundledProductSpecification()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (BundledProductSpecification ar : toRemove) { + prodSpec.getBundledProductSpecification().remove(ar); + } + + } + + + /** + * Update ProductSpecificationCharacteristic list + */ + if (prodSpecUpd.getProductSpecCharacteristic() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ProductSpecificationCharacteristic ar : prodSpecUpd.getProductSpecCharacteristic()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (ProductSpecificationCharacteristic orinalAtt : prodSpec.getProductSpecCharacteristic()) { + if (orinalAtt.getName().equals(ar.getName())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getName(), true); + break; + } + } + + if (!idexists) { + prodSpec.getProductSpecCharacteristic().add(ar); + idAddedUpdated.put(ar.getName(), true); + } + } + + List toRemove = new ArrayList<>(); + for (ProductSpecificationCharacteristic ss : prodSpec.getProductSpecCharacteristic()) { + if (idAddedUpdated.get(ss.getName()) == null) { + toRemove.add(ss); + } + } + + for (ProductSpecificationCharacteristic ar : toRemove) { + prodSpec.getProductSpecCharacteristic().remove(ar); + } + + } + + + + + /** + * Update ProductSpecificationRelationship list + */ + if (prodSpecUpd.getProductSpecificationRelationship() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ProductSpecificationRelationship ar : prodSpecUpd.getProductSpecificationRelationship() ) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (ProductSpecificationRelationship orinalAtt : prodSpec.getProductSpecificationRelationship()) { + if (orinalAtt.getUuid().equals(ar.getUuid())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getUuid(), true); + break; + } + } + + if (!idexists) { + prodSpec.getProductSpecificationRelationship().add(ar); + idAddedUpdated.put(ar.getUuid(), true); + } + } + + List toRemove = new ArrayList<>(); + for (ProductSpecificationRelationship ss : prodSpec.getProductSpecificationRelationship()) { + if (idAddedUpdated.get(ss.getUuid()) == null) { + toRemove.add(ss); + } + } + + for (ProductSpecificationRelationship ar : toRemove) { + prodSpec.getProductSpecificationRelationship().remove(ar); + } + + } + + /** + * Update RelatedParty list + */ + if (prodSpecUpd.getRelatedParty() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (RelatedParty ar : prodSpecUpd.getRelatedParty() ) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (RelatedParty orinalAtt : prodSpec.getRelatedParty()) { + if (orinalAtt.getUuid().equals(ar.getUuid())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getUuid(), true); + break; + } + } + + if (!idexists) { + prodSpec.getRelatedParty().add(ar); + idAddedUpdated.put(ar.getUuid(), true); + } + } + + List toRemove = new ArrayList<>(); + for (RelatedParty ss : prodSpec.getRelatedParty()) { + if (idAddedUpdated.get(ss.getUuid()) == null) { + toRemove.add(ss); + } + } + + for (RelatedParty ar : toRemove) { + prodSpec.getRelatedParty().remove(ar); + } + + } + + + /** + * Update ResourceSpecificationRef list + */ + if (prodSpecUpd.getResourceSpecification() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ResourceSpecificationRef ar : prodSpecUpd.getResourceSpecification() ) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (ResourceSpecificationRef orinalAtt : prodSpec.getResourceSpecification()) { + if (orinalAtt.getUuid().equals(ar.getUuid())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getUuid(), true); + break; + } + } + + if (!idexists) { + prodSpec.getResourceSpecification().add(ar); + idAddedUpdated.put(ar.getUuid(), true); + } + } + + List toRemove = new ArrayList<>(); + for (ResourceSpecificationRef ss : prodSpec.getResourceSpecification()) { + if (idAddedUpdated.get(ss.getUuid()) == null) { + toRemove.add(ss); + } + } + + for (ResourceSpecificationRef ar : toRemove) { + prodSpec.getResourceSpecification().remove(ar); + } + } + + /** + * Update ResourceSpecificationRef list + */ + if (prodSpecUpd.getServiceSpecification() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ServiceSpecificationRef ar : prodSpecUpd.getServiceSpecification() ) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (ServiceSpecificationRef orinalAtt : prodSpec.getServiceSpecification()) { + if (orinalAtt.getUuid().equals(ar.getUuid())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getUuid(), true); + break; + } + } + + if (!idexists) { + prodSpec.getServiceSpecification().add(ar); + idAddedUpdated.put(ar.getUuid(), true); + } + } + + List toRemove = new ArrayList<>(); + for (ServiceSpecificationRef ss : prodSpec.getServiceSpecification()) { + if (idAddedUpdated.get(ss.getUuid()) == null) { + toRemove.add(ss); + } + } + + for (ServiceSpecificationRef ar : toRemove) { + prodSpec.getServiceSpecification().remove(ar); + } + } + + + TimePeriod tp = new TimePeriod(); + if (prodSpecUpd.getValidFor() != null) { + tp.setStartDateTime(prodSpecUpd.getValidFor().getStartDateTime()); + tp.setEndDateTime(prodSpecUpd.getValidFor().getEndDateTime()); + prodSpec.setValidFor(tp); + } + + + + return prodSpec; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/pm632/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..6a6aac08461d94401b3c00ed9724ea735406d0d7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.pm632.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +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/pm632/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/pm632/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..88dcbedcfe13055ecadaf1fc29a8896d0ed4c00d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================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.pm632.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.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +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/pm632/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/pm632/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..a6b544e6abcea6b36f8ef3b293449cb7911bc881 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================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.pm632.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +@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/pm632/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/pm632/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..49a9b2ab9cc408daebbc71741df3d1fc3c463f96 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm632.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pm632.model.EventSubscription; +import org.etsi.osl.tmf.pm632.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/pm632/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..f9ea2e65c0bbf4a53990f23ea194598b6da88ef8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.pm632.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +@Controller("HubApiController632") +@RequestMapping("/party/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/api/IndividualApi.java b/src/main/java/org/etsi/osl/tmf/pm632/api/IndividualApi.java new file mode 100644 index 0000000000000000000000000000000000000000..64bb315d1df30c2617c0148af4610b7f0c7cb65f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/IndividualApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm632.api; + +import java.io.IOException; +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pm632.model.Individual; +import org.etsi.osl.tmf.pm632.model.IndividualCreate; +import org.etsi.osl.tmf.pm632.model.IndividualUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +@Tag(name = "individual", description = "the individual API") +public interface IndividualApi { + + Logger log = LoggerFactory.getLogger(IndividualApi.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 Individual", operationId = "createIndividual", description = "This operation creates a Individual entity.", tags={ "individual", }) + @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 = "/individual", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createIndividual(@Parameter(description = "The Individual to be created" ,required=true ) @Valid @RequestBody IndividualCreate individual) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"aristocraticTitle\" : \"aristocraticTitle\", \"gender\" : \"gender\", \"disability\" : [ { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"individualIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"countryOfBirth\" : \"countryOfBirth\", \"familyName\" : \"familyName\", \"skill\" : [ { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"deathDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"generation\" : \"generation\", \"placeOfBirth\" : \"placeOfBirth\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"birthDate\" : \"2000-01-23T04:56:07.000+00:00\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"languageAbility\" : [ { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" }, { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" } ], \"nationality\" : \"nationality\", \"preferredGivenName\" : \"preferredGivenName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"location\" : \"location\", \"middleName\" : \"middleName\", \"otherName\" : [ { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"maritalStatus\" : \"maritalStatus\", \"status\" : { }}", Individual.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 IndividualApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a Individual", operationId = "deleteIndividual", description = "This operation deletes a Individual entity.", tags={ "individual", }) + @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 = "/individual/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteIndividual(@Parameter(description = "Identifier of the Individual",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default IndividualApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find Individual objects", operationId = "listIndividual", description = "This operation list or find Individual entities" , tags={ "individual", }) + @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 = "/individual", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listIndividual(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"aristocraticTitle\" : \"aristocraticTitle\", \"gender\" : \"gender\", \"disability\" : [ { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"individualIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"countryOfBirth\" : \"countryOfBirth\", \"familyName\" : \"familyName\", \"skill\" : [ { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"deathDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"generation\" : \"generation\", \"placeOfBirth\" : \"placeOfBirth\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"birthDate\" : \"2000-01-23T04:56:07.000+00:00\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"languageAbility\" : [ { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" }, { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" } ], \"nationality\" : \"nationality\", \"preferredGivenName\" : \"preferredGivenName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"location\" : \"location\", \"middleName\" : \"middleName\", \"otherName\" : [ { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"maritalStatus\" : \"maritalStatus\", \"status\" : { }}, { \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"aristocraticTitle\" : \"aristocraticTitle\", \"gender\" : \"gender\", \"disability\" : [ { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"individualIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"countryOfBirth\" : \"countryOfBirth\", \"familyName\" : \"familyName\", \"skill\" : [ { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"deathDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"generation\" : \"generation\", \"placeOfBirth\" : \"placeOfBirth\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"birthDate\" : \"2000-01-23T04:56:07.000+00:00\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"languageAbility\" : [ { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" }, { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" } ], \"nationality\" : \"nationality\", \"preferredGivenName\" : \"preferredGivenName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"location\" : \"location\", \"middleName\" : \"middleName\", \"otherName\" : [ { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"maritalStatus\" : \"maritalStatus\", \"status\" : { }} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default IndividualApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a Individual", operationId = "patchIndividual", description = "This operation updates partially a Individual entity.", tags={ "individual", }) + @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 = "/individual/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchIndividual(@Parameter(description = "Identifier of the Individual",required=true) @PathVariable("id") String id,@Parameter(description = "The Individual to be updated" ,required=true ) @Valid @RequestBody IndividualUpdate individual) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"aristocraticTitle\" : \"aristocraticTitle\", \"gender\" : \"gender\", \"disability\" : [ { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"individualIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"countryOfBirth\" : \"countryOfBirth\", \"familyName\" : \"familyName\", \"skill\" : [ { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"deathDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"generation\" : \"generation\", \"placeOfBirth\" : \"placeOfBirth\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"birthDate\" : \"2000-01-23T04:56:07.000+00:00\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"languageAbility\" : [ { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" }, { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" } ], \"nationality\" : \"nationality\", \"preferredGivenName\" : \"preferredGivenName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"location\" : \"location\", \"middleName\" : \"middleName\", \"otherName\" : [ { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"maritalStatus\" : \"maritalStatus\", \"status\" : { }}", Individual.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 IndividualApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a Individual by ID", operationId = "retrieveIndividual", description = "This operation retrieves a Individual entity. Attribute selection is enabled for all first level attributes.", tags={ "individual", }) + @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 = "/individual/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveIndividual( + Principal principal, + @Parameter(description = "Identifier of the Individual",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("{ \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"aristocraticTitle\" : \"aristocraticTitle\", \"gender\" : \"gender\", \"disability\" : [ { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@baseType\" : \"@baseType\", \"disabilityCode\" : \"disabilityCode\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"disabilityName\" : \"disabilityName\", \"@type\" : \"@type\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"individualIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"countryOfBirth\" : \"countryOfBirth\", \"familyName\" : \"familyName\", \"skill\" : [ { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"skillName\" : \"skillName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"evaluatedLevel\" : \"evaluatedLevel\", \"skillCode\" : \"skillCode\", \"comment\" : \"comment\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"deathDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"generation\" : \"generation\", \"placeOfBirth\" : \"placeOfBirth\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"birthDate\" : \"2000-01-23T04:56:07.000+00:00\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"languageAbility\" : [ { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" }, { \"readingProficiency\" : \"readingProficiency\", \"writingProficiency\" : \"writingProficiency\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"isFavouriteLanguage\" : true, \"speakingProficiency\" : \"speakingProficiency\", \"listeningProficiency\" : \"listeningProficiency\", \"languageCode\" : \"languageCode\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"languageName\" : \"languageName\" } ], \"nationality\" : \"nationality\", \"preferredGivenName\" : \"preferredGivenName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"location\" : \"location\", \"middleName\" : \"middleName\", \"otherName\" : [ { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"generation\" : \"generation\", \"aristocraticTitle\" : \"aristocraticTitle\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"formattedName\" : \"formattedName\", \"givenName\" : \"givenName\", \"fullName\" : \"fullName\", \"title\" : \"title\", \"legalName\" : \"legalName\", \"@baseType\" : \"@baseType\", \"preferredGivenName\" : \"preferredGivenName\", \"familyName\" : \"familyName\", \"familyNamePrefix\" : \"familyNamePrefix\", \"middleName\" : \"middleName\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"maritalStatus\" : \"maritalStatus\", \"status\" : { }}", Individual.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 IndividualApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/api/IndividualApiController.java b/src/main/java/org/etsi/osl/tmf/pm632/api/IndividualApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..4946fe2154075d5467b43c9756e5bccf8115fb3e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/IndividualApiController.java @@ -0,0 +1,202 @@ +/*- + * ========================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.pm632.api; + +import java.security.Principal; +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pm632.model.ContactMedium; +import org.etsi.osl.tmf.pm632.model.Individual; +import org.etsi.osl.tmf.pm632.model.IndividualCreate; +import org.etsi.osl.tmf.pm632.model.IndividualUpdate; +import org.etsi.osl.tmf.pm632.model.MediumCharacteristic; +import org.etsi.osl.tmf.pm632.reposervices.IndividualRepoService; +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.security.oauth2.jwt.Jwt; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; +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.etsi.osl.model.nfv.UserRoleType; +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +@Controller +@RequestMapping("/party/v4/") +public class IndividualApiController implements IndividualApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public IndividualApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Autowired + IndividualRepoService individualRepoService; + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity> listIndividual(@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) { + + + + + try { + + + + return new ResponseEntity>(individualRepoService.findAll(), 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("hasAnyAuthority('USER" }) + @PreAuthorize("hasAnyAuthority('ROLE_USER', 'ROLE_ADMIN')") + public ResponseEntity retrieveIndividual( + Principal principal, + @Parameter(description = "Identifier of the Individual",required=true) @PathVariable("id") String id, + @Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + + + + try { + + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + + if ( id.equals( "myuser" ) ) { + + log.debug("principal= " + principal.toString()); + + Individual ind = individualRepoService.findByUsername( principal.getName() ); + + + if ( ind != null ) { + log.debug("principal.name {} ", principal.getName()); + return new ResponseEntity< Individual >( ind , HttpStatus.OK); + } else + { + @Valid + IndividualCreate individualnew = new IndividualCreate(); + individualnew.setPreferredGivenName( principal.getName() ); + individualnew.setFamilyName("N/A"); + individualnew.setGivenName("N/A"); + ContactMedium contactMediumItem = new ContactMedium(); + contactMediumItem.setPreferred(true); + contactMediumItem.setMediumType("main"); + MediumCharacteristic mc = new MediumCharacteristic(); + contactMediumItem.setCharacteristic(mc ); + individualnew.addContactMediumItem(contactMediumItem ); + mc.setEmailAddress( "na@example.com" ); + + if ( principal instanceof JwtAuthenticationToken) { + JwtAuthenticationToken pr = ( JwtAuthenticationToken ) principal; + + + Jwt lp = (Jwt) pr.getPrincipal(); + individualnew.setPreferredGivenName( lp.getClaimAsString("preferred_username") ); + individualnew.setFamilyName( lp.getClaimAsString("name") ); + individualnew.setGivenName( lp.getClaimAsString("given_name") ); + + mc.setEmailAddress( lp.getClaimAsString("email") ); + + + } + return new ResponseEntity< Individual > ( individualRepoService.addIndividual(individualnew) , HttpStatus.OK); + } + + + + } else if ( authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) ) ) { + + return new ResponseEntity< Individual >(individualRepoService.findById(id) , HttpStatus.OK); + }else { + return new ResponseEntity< Individual >(HttpStatus.FORBIDDEN ); + } + + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity< Individual >(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createIndividual( + @Parameter(description = "The Individual to be created", required = true) @Valid @RequestBody IndividualCreate individual) { + + try { + Individual c = individualRepoService.addIndividual(individual); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN' , 'ROLE_USER')" ) + public ResponseEntity patchIndividual(@Parameter(description = "Identifier of the Individual",required=true) @PathVariable("id") String id,@Parameter(description = "The Individual to be updated" ,required=true ) @Valid @RequestBody IndividualUpdate individual) { + + try { + Individual c = individualRepoService.updateIndividual(id, individual); + + return new ResponseEntity(c, HttpStatus.OK); + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + public ResponseEntity deleteIndividual(@Parameter(description = "Identifier of the Individual",required=true) @PathVariable("id") String id) { + try { + + return new ResponseEntity( individualRepoService.deleteById( 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/pm632/api/IndividualApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/pm632/api/IndividualApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..ccc920fe042b22a46f6773797c6085122d92cc25 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/IndividualApiRouteBuilder.java @@ -0,0 +1,111 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.pm632.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.pm632.model.IndividualAttributeValueChangeEvent; +import org.etsi.osl.tmf.pm632.model.IndividualCreateEvent; +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 IndividualApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(IndividualApiRouteBuilder.class.getName()); + + @Value("${EVENT_INDIVIDUAL_CREATE}") + private String EVENT_INDIVIDUAL_CREATE = ""; + + @Value("${EVENT_INDIVIDUAL_CHANGED}") + private String EVENT_INDIVIDUAL_CHANGED = ""; + + @Autowired + private ProducerTemplate template; + + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + + } + + /** + * @param ce + * @param id + */ + public void publishEvent(Object ce, String objId) { + try { + String msgtopic = ""; + + Map map = new HashMap<>(); + map.put("objId", objId); + + if (ce instanceof IndividualCreateEvent) { + msgtopic = EVENT_INDIVIDUAL_CREATE; + ((IndividualCreateEvent) ce).setEventType(ce.getClass().getName()); + map.put("eventid", ((IndividualCreateEvent) ce).getEventId()); + logger.info("will send Event for type " + ((IndividualCreateEvent) ce).getEventType()); + } else if (ce instanceof IndividualAttributeValueChangeEvent) { + msgtopic = EVENT_INDIVIDUAL_CHANGED; + + ((IndividualAttributeValueChangeEvent) ce).setEventType(ce.getClass().getName()); + map.put("eventid", ((IndividualAttributeValueChangeEvent) ce).getEventId()); + logger.info("will send Event for type " + ((IndividualAttributeValueChangeEvent) ce).getEventType()); + } + + String apayload = toJsonString( ce ); + 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/pm632/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/pm632/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..cb5191484d84031b3cb18e926623c21aa3c471dd --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/ListenerApi.java @@ -0,0 +1,320 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm632.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pm632.model.EventSubscription; +import org.etsi.osl.tmf.pm632.model.IndividualAttributeValueChangeEvent; +import org.etsi.osl.tmf.pm632.model.IndividualCreateEvent; +import org.etsi.osl.tmf.pm632.model.IndividualDeleteEvent; +import org.etsi.osl.tmf.pm632.model.IndividualStateChangeEvent; +import org.etsi.osl.tmf.pm632.model.OrganizationAttributeValueChangeEvent; +import org.etsi.osl.tmf.pm632.model.OrganizationCreateEvent; +import org.etsi.osl.tmf.pm632.model.OrganizationDeleteEvent; +import org.etsi.osl.tmf.pm632.model.OrganizationStateChangeEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity IndividualAttributeValueChangeEvent", operationId = "listenToIndividualAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification IndividualAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/individualAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToIndividualAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody IndividualAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity IndividualCreateEvent", operationId = "listenToIndividualCreateEvent", description = "Example of a client listener for receiving the notification IndividualCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/individualCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToIndividualCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody IndividualCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity IndividualDeleteEvent", operationId = "listenToIndividualDeleteEvent", description = "Example of a client listener for receiving the notification IndividualDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/individualDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToIndividualDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody IndividualDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity IndividualStateChangeEvent", operationId = "listenToIndividualStateChangeEvent", description = "Example of a client listener for receiving the notification IndividualStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/individualStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToIndividualStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody IndividualStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity OrganizationAttributeValueChangeEvent", operationId = "listenToOrganizationAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification OrganizationAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/organizationAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToOrganizationAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody OrganizationAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity OrganizationCreateEvent", operationId = "listenToOrganizationCreateEvent", description = "Example of a client listener for receiving the notification OrganizationCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/organizationCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToOrganizationCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody OrganizationCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity OrganizationDeleteEvent", operationId = "listenToOrganizationDeleteEvent", description = "Example of a client listener for receiving the notification OrganizationDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/organizationDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToOrganizationDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody OrganizationDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity OrganizationStateChangeEvent", operationId = "listenToOrganizationStateChangeEvent", description = "Example of a client listener for receiving the notification OrganizationStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/organizationStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToOrganizationStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody OrganizationStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/pm632/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..140fb935d6c948cad3d6b7bed8e3740625e18f04 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.pm632.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +@Controller("ListenerApiController632") +@RequestMapping("/party/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/pm632/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..02157b187ede190ebae0cfe7e9f3b72e0872b534 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/NotFoundException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.pm632.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +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/pm632/api/OrganizationApi.java b/src/main/java/org/etsi/osl/tmf/pm632/api/OrganizationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..1152ff698e273c818baf2b5bd73bdbdd8e14d6a8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/OrganizationApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.pm632.api; + +import java.io.IOException; +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pm632.model.Organization; +import org.etsi.osl.tmf.pm632.model.OrganizationCreate; +import org.etsi.osl.tmf.pm632.model.OrganizationUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +@Tag(name = "organization", description = "the organization API") +public interface OrganizationApi { + + Logger log = LoggerFactory.getLogger(OrganizationApi.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 Organization", operationId = "createOrganization", description = "This operation creates a Organization entity.", tags={ "organization", }) + @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 = "/organization", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createOrganization( + Principal principal, + @Parameter(description = "The Organization to be created" ,required=true ) @Valid @RequestBody OrganizationCreate organization) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"tradingName\" : \"tradingName\", \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"organizationChildRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"nameType\" : \"nameType\", \"organizationType\" : \"organizationType\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"existsDuring\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isHeadOffice\" : true, \"name\" : \"name\", \"isLegalEntity\" : true, \"otherName\" : [ { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"organizationIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"organizationParentRelationship\" : { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : { }}", Organization.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 OrganizationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a Organization", operationId = "deleteOrganization", description = "This operation deletes a Organization entity.", tags={ "organization", }) + @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 = "/organization/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteOrganization(@Parameter(description = "Identifier of the Organization",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default OrganizationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find Organization objects", operationId = "listOrganization", description = "This operation list or find Organization entities" , tags={ "organization", }) + @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 = "/organization", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listOrganization(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"tradingName\" : \"tradingName\", \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"organizationChildRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"nameType\" : \"nameType\", \"organizationType\" : \"organizationType\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"existsDuring\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isHeadOffice\" : true, \"name\" : \"name\", \"isLegalEntity\" : true, \"otherName\" : [ { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"organizationIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"organizationParentRelationship\" : { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : { }}, { \"tradingName\" : \"tradingName\", \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"organizationChildRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"nameType\" : \"nameType\", \"organizationType\" : \"organizationType\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"existsDuring\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isHeadOffice\" : true, \"name\" : \"name\", \"isLegalEntity\" : true, \"otherName\" : [ { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"organizationIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"organizationParentRelationship\" : { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : { }} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default OrganizationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a Organization", operationId = "patchOrganization", description = "This operation updates partially a Organization entity.", tags={ "organization", }) + @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 = "/organization/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchOrganization(@Parameter(description = "Identifier of the Organization",required=true) @PathVariable("id") String id,@Parameter(description = "The Organization to be updated" ,required=true ) @Valid @RequestBody OrganizationUpdate organization) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"tradingName\" : \"tradingName\", \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"organizationChildRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"nameType\" : \"nameType\", \"organizationType\" : \"organizationType\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"existsDuring\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isHeadOffice\" : true, \"name\" : \"name\", \"isLegalEntity\" : true, \"otherName\" : [ { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"organizationIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"organizationParentRelationship\" : { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : { }}", Organization.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 OrganizationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a Organization by ID", operationId = "retrieveOrganization", description = "This operation retrieves a Organization entity. Attribute selection is enabled for all first level attributes.", tags={ "organization", }) + @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 = "/organization/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveOrganization(@Parameter(description = "Identifier of the Organization",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("{ \"tradingName\" : \"tradingName\", \"taxExemptionCertificate\" : [ { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"taxDefinition\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"taxType\" : \"taxType\" } ], \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"id\" : \"id\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"partyCharacteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"organizationChildRelationship\" : [ { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"nameType\" : \"nameType\", \"organizationType\" : \"organizationType\", \"externalReference\" : [ { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"externalReferenceType\" : \"externalReferenceType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"@baseType\" : \"@baseType\", \"existsDuring\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"isHeadOffice\" : true, \"name\" : \"name\", \"isLegalEntity\" : true, \"otherName\" : [ { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"nameType\" : \"nameType\", \"tradingName\" : \"tradingName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"organizationIdentification\" : [ { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" }, { \"issuingAuthority\" : \"issuingAuthority\", \"attachment\" : { \"@referredType\" : \"@referredType\", \"attachmentType\" : \"attachmentType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"description\" : \"description\", \"mimeType\" : \"mimeType\", \"content\" : \"content\", \"url\" : \"url\", \"size\" : { \"amount\" : 6.0274563, \"units\" : \"units\" }, \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@baseType\" : \"@baseType\", \"issuingDate\" : \"2000-01-23T04:56:07.000+00:00\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"identificationType\" : \"identificationType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"identificationId\" : \"identificationId\" } ], \"creditRating\" : [ { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 }, { \"creditAgencyName\" : \"creditAgencyName\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"creditAgencyType\" : \"creditAgencyType\", \"@type\" : \"@type\", \"ratingReference\" : \"ratingReference\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"ratingScore\" : 0 } ], \"organizationParentRelationship\" : { \"relationshipType\" : \"relationshipType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"organization\" : { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : { }}", Organization.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 OrganizationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/api/OrganizationApiController.java b/src/main/java/org/etsi/osl/tmf/pm632/api/OrganizationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..7ec60ba937d343743dfb62b35bf8064d9c470eab --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/OrganizationApiController.java @@ -0,0 +1,179 @@ +/*- + * ========================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.pm632.api; + +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.pm632.model.Organization; +import org.etsi.osl.tmf.pm632.model.OrganizationCreate; +import org.etsi.osl.tmf.pm632.model.OrganizationUpdate; +import org.etsi.osl.tmf.pm632.reposervices.OrganizationRepoService; +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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:38:47.101+03:00") + +@Controller +@RequestMapping("/party/v4/") +public class OrganizationApiController implements OrganizationApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public OrganizationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + @Autowired + OrganizationRepoService organizationRepoService; + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity> listOrganization(@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) { + + + + + try { +// Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); +// SecurityContextHolder.setContext( (SecurityContext) attr ); +// +// Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); +// log.info("authentication= " + authentication.toString()); +// +// log.info("principal ROLE_ADMIN = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) )); +// log.info("principal ROLE_NFV_DEVELOPER = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_NFV_DEVELOPER.getValue() ) )); +// log.info("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>(organizationRepoService.findAll(), HttpStatus.OK); +// }else { +// return new ResponseEntity>(HttpStatus.FORBIDDEN ); +// } + return new ResponseEntity>(organizationRepoService.findAll(), 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity retrieveOrganization(@Parameter(description = "Identifier of the Organization",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + + + try { +// Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); +// SecurityContextHolder.setContext( (SecurityContext) attr ); +// +// Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); +// log.info("authentication= " + authentication.toString()); +// +// log.info("principal ROLE_ADMIN = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) )); +// log.info("principal ROLE_NFV_DEVELOPER = " + authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_NFV_DEVELOPER.getValue() ) )); +// log.info("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< Organization >(organizationRepoService.findById(id) , HttpStatus.OK); +// }else { +// return new ResponseEntity< Organization >(HttpStatus.FORBIDDEN ); +// } +// + + return new ResponseEntity< Organization >(organizationRepoService.findById(id) , HttpStatus.OK); + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity< Organization >(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createOrganization( Principal principal, + @Parameter(description = "The Organization to be created", required = true) @Valid @RequestBody OrganizationCreate organization) { + + try { + log.info("principal= " + principal.toString()); + Organization c = organizationRepoService.addOrganization(organization); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity patchOrganization(@Parameter(description = "Identifier of the Organization",required=true) @PathVariable("id") String id,@Parameter(description = "The Organization to be updated" ,required=true ) @Valid @RequestBody OrganizationUpdate organization) { + + try { + Organization c = organizationRepoService.updateOrganization(id, organization); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity deleteOrganization(@Parameter(description = "Identifier of the Organization",required=true) @PathVariable("id") String id) { + try { + + return new ResponseEntity( organizationRepoService.deleteById( 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/pm632/api/OrganizationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/pm632/api/OrganizationApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..36740fd7a734ba66a6318813d2448184c00af76e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/OrganizationApiRouteBuilder.java @@ -0,0 +1,110 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.pm632.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.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.pm632.model.Organization; +import org.etsi.osl.tmf.pm632.reposervices.OrganizationRepoService; +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 OrganizationApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(OrganizationApiRouteBuilder.class.getName()); + + @Value("${EVENT_ORGANIZATION_CREATE}") + private String EVENT_ORGANIZATION_CREATE = ""; + + @Value("${EVENT_ORGANIZATION_CHANGED}") + private String EVENT_ORGANIZATION_CHANGED = ""; + + @Value("${CATALOG_GET_EXTERNAL_SERVICE_PARTNERS}") + private String CATALOG_GET_EXTERNAL_SERVICE_PARTNERS = ""; + + + @Value("${CATALOG_GET_PARTNER_ORGANIZATON_BY_ID}") + private String CATALOG_GET_PARTNER_ORGANIZATON_BY_ID = ""; + + + @Value("${CATALOG_UPDATE_PARTNER_ORGANIZATION}") + private String CATALOG_UPDATE_PARTNER_ORGANIZATION = ""; + + @Autowired + private ProducerTemplate template; + + @Autowired + OrganizationRepoService organizationRepoService; + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + + from( CATALOG_GET_EXTERNAL_SERVICE_PARTNERS ) + .log(LoggingLevel.INFO, log, CATALOG_GET_EXTERNAL_SERVICE_PARTNERS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( organizationRepoService, "getPartnerOrganizationsWithAPI") + //.marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + from( CATALOG_GET_PARTNER_ORGANIZATON_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_PARTNER_ORGANIZATON_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( organizationRepoService, "findByUuidJson"); + + + from( CATALOG_UPDATE_PARTNER_ORGANIZATION ) + .log(LoggingLevel.INFO, log, CATALOG_UPDATE_PARTNER_ORGANIZATION + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal() + .json(JsonLibrary.Jackson, Organization.class, true) + .bean( organizationRepoService, "updateOrganization( ${header.orgid}, ${body})") + .marshal().json( JsonLibrary.Jackson, String.class) + .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/pm632/api/OrganizationApiRouteBuilderEvents.java b/src/main/java/org/etsi/osl/tmf/pm632/api/OrganizationApiRouteBuilderEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..b36b4784480af743f6da0e8e38855f94bda7f3d1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/api/OrganizationApiRouteBuilderEvents.java @@ -0,0 +1,112 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.pm632.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.pm632.model.OrganizationAttributeValueChangeEvent; +import org.etsi.osl.tmf.pm632.model.OrganizationCreateEvent; +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 OrganizationApiRouteBuilderEvents extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(OrganizationApiRouteBuilderEvents.class.getName()); + + @Value("${EVENT_ORGANIZATION_CREATE}") + private String EVENT_ORGANIZATION_CREATE = ""; + + @Value("${EVENT_ORGANIZATION_CHANGED}") + private String EVENT_ORGANIZATION_CHANGED = ""; + + + @Autowired + private ProducerTemplate template; + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + + + } + + /** + * @param ce + * @param id + */ + public void publishEvent(Object ce, String objId) { + try { + String msgtopic = ""; + + Map map = new HashMap<>(); + map.put("objId", objId); + + if (ce instanceof OrganizationCreateEvent) { + msgtopic = EVENT_ORGANIZATION_CREATE; + ((OrganizationCreateEvent) ce).setEventType(ce.getClass().getName()); + map.put("eventid", ((OrganizationCreateEvent) ce).getEventId()); + logger.info("will send Event for type " + ((OrganizationCreateEvent) ce).getEventType()); + } else if (ce instanceof OrganizationAttributeValueChangeEvent) { + msgtopic = EVENT_ORGANIZATION_CHANGED; + + ((OrganizationAttributeValueChangeEvent) ce).setEventType(ce.getClass().getName()); + map.put("eventid", ((OrganizationAttributeValueChangeEvent) ce).getEventId()); + logger.info("will send Event for type " + ((OrganizationAttributeValueChangeEvent) ce).getEventType()); + } + + String apayload = toJsonString( ce ); + 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/pm632/repo/IndividualRepository.java b/src/main/java/org/etsi/osl/tmf/pm632/repo/IndividualRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..1e16ed9f435307b98ed881fab7e0b40c58aa0fe4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/repo/IndividualRepository.java @@ -0,0 +1,43 @@ +/*- + * ========================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.pm632.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.pm632.model.Individual; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + + +@Repository +public interface IndividualRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Iterable findByFamilyName( String name); + + List findByOrderByFamilyName(); + + Optional findByPreferredGivenName(String username); + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/repo/OrganizationRepository.java b/src/main/java/org/etsi/osl/tmf/pm632/repo/OrganizationRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..71f733ab880063de1a01ee1d9994934ef7ac3cbe --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/repo/OrganizationRepository.java @@ -0,0 +1,45 @@ +/*- + * ========================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.pm632.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.pm632.model.Organization; +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 OrganizationRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Iterable findByName( String name); + + List findByOrderByName(); + + @Query("SELECT o FROM Organization o JOIN FETCH o.partyCharacteristic char WHERE char.name LIKE 'EXTERNAL_TMFAPI_BASEURL'") + List findPartnersOfferingEXTERNAL_TMFAPI(); + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/reposervices/IndividualRepoService.java b/src/main/java/org/etsi/osl/tmf/pm632/reposervices/IndividualRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..707158f6bb8a99e2e96397267377b6a4ff57dee4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/reposervices/IndividualRepoService.java @@ -0,0 +1,221 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.pm632.reposervices; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.pm632.api.IndividualApiRouteBuilder; +import org.etsi.osl.tmf.pm632.model.Characteristic; +import org.etsi.osl.tmf.pm632.model.ContactMedium; +import org.etsi.osl.tmf.pm632.model.Individual; +import org.etsi.osl.tmf.pm632.model.IndividualAttributeValueChangeEvent; +import org.etsi.osl.tmf.pm632.model.IndividualAttributeValueChangeEventPayload; +import org.etsi.osl.tmf.pm632.model.IndividualCreate; +import org.etsi.osl.tmf.pm632.model.IndividualCreateEvent; +import org.etsi.osl.tmf.pm632.model.IndividualCreateEventPayload; +import org.etsi.osl.tmf.pm632.model.IndividualUpdate; +import org.etsi.osl.tmf.pm632.repo.IndividualRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.validation.Valid; + + +@Service +@Transactional +public class IndividualRepoService { + + @Autowired + IndividualRepository individualRepository; + + @Autowired + IndividualApiRouteBuilder individualApiRouteBuilder; + + public List findAll() { + return (List) this.individualRepository.findByOrderByFamilyName(); + } + + public Individual addIndividual(@Valid IndividualCreate individual) { + Individual c = new Individual(); + c = updateIndividualData(c, individual); + c = individualRepository.save(c); + raiseIndividualCreate( c ); + return c; + } + + public Individual updateIndividual(String id, @Valid IndividualUpdate individual) { + Individual c = this.findByUuid(id); + if ( c == null) { + return null; + } + c = this.updateIndividualData(c, individual); + c = this.individualRepository.save(c); + raiseIndividualChanged(c); + return c; + } + + private Individual findByUuid(String id) { + Optional optionalCat = this.individualRepository.findByUuid(id); + return optionalCat.orElse(null); + } + + private Individual updateIndividualData(Individual c, @Valid IndividualUpdate indvUpd) { + + if ( indvUpd.getFamilyName()!=null) { + c.setFamilyName( indvUpd.getFamilyName() ); + } + + if ( indvUpd.getFullName() !=null) { + c.setFullName( indvUpd.getFullName() ); + } + + if ( indvUpd.getGivenName() !=null) { + c.setGivenName( indvUpd.getGivenName() ); + } + + + if ( indvUpd.getPreferredGivenName() !=null) { + c.setPreferredGivenName( indvUpd.getPreferredGivenName() ); + } + + if ( indvUpd.getLocation() !=null) { + c.setLocation( indvUpd.getLocation() ); + } + + if ( indvUpd.getContactMedium() !=null) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ContactMedium cmUpd : indvUpd.getContactMedium()) { + //find by id and reload it here. + boolean idexists = false; + for (ContactMedium originalCm : c.getContactMedium()) { + if ( ( originalCm.getUuid()!=null ) && originalCm.getUuid().equals(cmUpd.getUuid() ) ) { + idexists = true; + idAddedUpdated.put( originalCm.getUuid(), true); + originalCm.updateWith( cmUpd ); + break; + } + } + if (!idexists) { + c.addContactMediumItem( cmUpd ); + idAddedUpdated.put( cmUpd.getUuid(), true); + } + } + List toRemove = new ArrayList<>(); + for (ContactMedium ss : c.getContactMedium() ) { + if (idAddedUpdated.get(ss.getUuid()) == null) { + toRemove.add(ss); + } + } + + for (ContactMedium schar : toRemove) { + c.getContactMedium().remove( schar ); + } + } + + if ( indvUpd.getPartyCharacteristic() !=null) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (Characteristic cmUpd : indvUpd.getPartyCharacteristic()) { + //find by id and reload it here. + boolean idexists = false; + for (Characteristic originalCm : c.getPartyCharacteristic()) { + if ( originalCm.getName().equals(cmUpd.getName() ) ) { + idexists = true; + idAddedUpdated.put( originalCm.getName() , true); + originalCm.updateWith( cmUpd ); + break; + } + } + if (!idexists) { + c.addPartyCharacteristicItem( new Characteristic(cmUpd) ); + idAddedUpdated.put( cmUpd.getName(), true); + } + + } + + List toRemove = new ArrayList<>(); + for (Characteristic ss : c.getPartyCharacteristic()) { + if (idAddedUpdated.get(ss.getName()) == null) { + toRemove.add(ss); + } + } + + for (Characteristic schar : toRemove) { + c.getPartyCharacteristic().remove( schar ); + } + + } + + return c; + } + + public Individual findById(String id) { + Optional c = this.individualRepository.findByUuid(id); + return c.orElse(null); + } + + public Void deleteById(String id) { + Optional c = this.individualRepository.findByUuid(id); + this.individualRepository.delete( c.get()); + return null; + } + + + private void raiseIndividualCreate(Individual c) { + + IndividualCreateEvent ce = new IndividualCreateEvent(); + IndividualCreateEventPayload event = new IndividualCreateEventPayload(); + event.setIndividual(c); + ce.setEvent(event); + individualApiRouteBuilder.publishEvent( ce, c.getId() ); + } + + + private void raiseIndividualChanged(Individual c) { + + IndividualAttributeValueChangeEvent ce = new IndividualAttributeValueChangeEvent(); + IndividualAttributeValueChangeEventPayload event = new IndividualAttributeValueChangeEventPayload(); + event.setIndividual(c); + ce.setEvent(event); + individualApiRouteBuilder.publishEvent( ce, c.getId() ); + + } + + /** + * @param username + * @return + */ + public Individual findByUsername(String username) { + Optional c = this.individualRepository.findByPreferredGivenName( username ); + return c.orElse( null ); + + +// Individual ind = new Individual(); +// ind.getPreferredGivenName() +// return null; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/pm632/reposervices/OrganizationRepoService.java b/src/main/java/org/etsi/osl/tmf/pm632/reposervices/OrganizationRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..3b8f16e7012532b99a9c74637321cf93821b33bb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/pm632/reposervices/OrganizationRepoService.java @@ -0,0 +1,404 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.pm632.reposervices; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.pm632.api.OrganizationApiRouteBuilderEvents; +import org.etsi.osl.tmf.pm632.model.Characteristic; +import org.etsi.osl.tmf.pm632.model.ContactMedium; +import org.etsi.osl.tmf.pm632.model.Organization; +import org.etsi.osl.tmf.pm632.model.OrganizationAttributeValueChangeEvent; +import org.etsi.osl.tmf.pm632.model.OrganizationAttributeValueChangeEventPayload; +import org.etsi.osl.tmf.pm632.model.OrganizationCreate; +import org.etsi.osl.tmf.pm632.model.OrganizationCreateEvent; +import org.etsi.osl.tmf.pm632.model.OrganizationCreateEventPayload; +import org.etsi.osl.tmf.pm632.model.OrganizationUpdate; +import org.etsi.osl.tmf.pm632.repo.OrganizationRepository; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +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 +@Transactional +public class OrganizationRepoService { + + @Autowired + OrganizationRepository organizationRepository; + + @Autowired + OrganizationApiRouteBuilderEvents organizationApiRouteBuilder; + + private SessionFactory sessionFactory; + + + private static final transient Log logger = LogFactory.getLog( OrganizationRepoService.class.getName()); + + @Autowired + public OrganizationRepoService(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.organizationRepository.findByOrderByName(); + } + + public Organization addOrganization(@Valid OrganizationCreate organization) { + Organization c = new Organization(); + +// /** +// * add here default characteristics for organization +// */ +// + Characteristic partyCharacteristicItem = new Characteristic(); + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_BASEURL" ) == null ) { + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_BASEURL" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + } + + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_CLIENTREGISTRATIONID" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_CLIENTREGISTRATIONID" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + + } + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_OAUTH2CLIENTID" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_OAUTH2CLIENTID" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + + } + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_OAUTH2CLIENTSECRET" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_OAUTH2CLIENTSECRET" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + + } + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_OAUTH2SCOPES" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_OAUTH2SCOPES" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + + } + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_OAUTH2TOKENURI" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_OAUTH2TOKENURI" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + + } + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_USERNAME" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_USERNAME" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + + } + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_PASSWORD" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_PASSWORD" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + } + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_SERVICE_CATALOG_URLS" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_SERVICE_CATALOG_URLS" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + } + + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_SERVICE_CATEGORY_URLS" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_SERVICE_CATEGORY_URLS" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + } + + + + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_SERVICE_SPEC" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_SERVICE_SPEC" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + } + + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_SERVICE_ORDER_URLS" ) == null ) { + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_SERVICE_ORDER_URLS" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + + } + + + if ( organization.findCharacteristic( "EXTERNAL_TMFAPI_STATUS" ) == null ) { + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName( "EXTERNAL_TMFAPI_STATUS" ); + partyCharacteristicItem.setValueType( "TEXT" ); + partyCharacteristicItem.setValue( new Any("")); + c.addPartyCharacteristicItem(partyCharacteristicItem); + + } + + c = updateOrganizationData(c, organization); + c = organizationRepository.save(c); + raiseOrganizationCreate( c ); + return c; + } + + public Organization updateOrganization(String id, @Valid OrganizationUpdate organization) { + Organization c = this.findByUuid(id); + if ( c == null) { + return null; + } + c = this.updateOrganizationData(c, organization); + c = this.organizationRepository.save(c); + raiseOrganizationChanged(c); + return c; + } + + private Organization findByUuid(String id) { + Optional optionalCat = this.organizationRepository.findByUuid(id); + return optionalCat.orElse(null); + } + + private Organization updateOrganizationData(Organization c, @Valid OrganizationUpdate orgUpd) { + + if ( orgUpd.getName()!=null) { + c.setName( orgUpd.getName() ); + } + + if ( orgUpd.getTradingName() !=null) { + c.setTradingName( orgUpd.getTradingName() ); + } + + if ( orgUpd.isIsLegalEntity() !=null) { + c.setIsLegalEntity( orgUpd.isIsLegalEntity() ); + } + + if ( orgUpd.getStatus() !=null) { + c.setStatus( orgUpd.getStatus() ); + } + + if ( orgUpd.getContactMedium() !=null) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ContactMedium cmUpd : orgUpd.getContactMedium()) { + //find by id and reload it here. + boolean idexists = false; + for (ContactMedium originalCm : c.getContactMedium()) { + if ( ( originalCm.getUuid()!=null ) && originalCm.getUuid().equals(cmUpd.getUuid() ) ) { + idexists = true; + idAddedUpdated.put( originalCm.getUuid(), true); + originalCm.updateWith( cmUpd ); + break; + } + } + if (!idexists) { + c.addContactMediumItem( cmUpd ); + } + + } + } + + if ( orgUpd.getPartyCharacteristic() !=null) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (Characteristic cmUpd : orgUpd.getPartyCharacteristic()) { + //find by id and reload it here. + boolean idexists = false; + for (Characteristic originalCm : c.getPartyCharacteristic()) { + if ( originalCm.getName().equals(cmUpd.getName() ) ) { + idexists = true; + idAddedUpdated.put( originalCm.getName() , true); + originalCm.updateWith( cmUpd ); + break; + } + } + if (!idexists) { + c.addPartyCharacteristicItem( new Characteristic(cmUpd) ); + idAddedUpdated.put( cmUpd.getName(), true); + } + + } + + List toRemove = new ArrayList<>(); + for (Characteristic ss : c.getPartyCharacteristic()) { + if (idAddedUpdated.get(ss.getName()) == null) { + toRemove.add(ss); + } + } + + for (Characteristic schar : toRemove) { + c.getPartyCharacteristic().remove( schar ); + } + + } + + return c; + } + + public Organization findById(String id) { + Optional c = this.organizationRepository.findByUuid(id); + return c.orElse(null); + } + + public Void deleteById(String id) { + Optional c = this.organizationRepository.findByUuid(id); + this.organizationRepository.delete( c.get()); + return null; + } + + + public Organization updateOrganization(String orgid, + @Valid Organization srcOrgz) { + + OrganizationUpdate organization = new OrganizationUpdate(); + + organization.setName(srcOrgz.getName()); + for (Characteristic c : srcOrgz.getPartyCharacteristic()) { + organization.addPartyCharacteristicItem( c ); + } + + for (ContactMedium c : srcOrgz.getContactMedium() ) { + organization.addContactMediumItem( c ); + } + + + return this.updateOrganization( orgid, organization); + } + + + private void raiseOrganizationCreate(Organization c) { + + OrganizationCreateEvent ce = new OrganizationCreateEvent(); + OrganizationCreateEventPayload event = new OrganizationCreateEventPayload(); + event.setOrganization(c); + ce.setEvent(event); + organizationApiRouteBuilder.publishEvent( ce, c.getId() ); + + } + + + private void raiseOrganizationChanged(Organization c) { + + OrganizationAttributeValueChangeEvent ce = new OrganizationAttributeValueChangeEvent(); + OrganizationAttributeValueChangeEventPayload event = new OrganizationAttributeValueChangeEventPayload(); + event.setOrganization(c); + ce.setEvent(event); + organizationApiRouteBuilder.publishEvent( ce, c.getId() ); + + } + + @Transactional + public String getPartnerOrganizationsWithAPI() { + + List orgz =organizationRepository.findPartnersOfferingEXTERNAL_TMFAPI(); + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + + try { + List orgzsend = new ArrayList<>(); + for (Organization o : orgz) { + logger.info( "o.getUuid()" + o.getUuid()); + logger.debug( "o.getUuid()" + o.toString() ); + Organization anorg = session.get(Organization.class, o.getUuid()) ;//this.findByUuid( o.getUuid()); + if (anorg!=null) { + orgzsend.add( anorg ); + } else { + + orgzsend.add( o ); + } + } + + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.writeValueAsString( orgzsend ); + + } catch (JsonProcessingException e) { + logger.error( "Failed to writeValueAsString getPartnerOrganizationsWithAPI." ); + e.printStackTrace(); + } finally { + tx.commit(); + session.close(); + } + + return "[]"; + } + + + @Transactional + public String findByUuidJson(String id) { + Organization o = this.findByUuid(id); + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + try { + return mapper.writeValueAsString( o ); + } catch (JsonProcessingException e) { + e.printStackTrace(); + + } + + return "{}"; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/po622/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..c29cdee8623623debac680a745563d10d06aefda --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ApiException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-30T10:29:21.184964400+02: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/po622/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/po622/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..464971816bfb55c8ebc36415f54fb45b41c7aec1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ApiOriginFilter.java @@ -0,0 +1,50 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.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 = "2020-10-30T10:29:21.184964400+02: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/po622/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/po622/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..2a77261060e420d1fb6a2c67edac94ed2d1e78b3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ApiResponseMessage.java @@ -0,0 +1,88 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-30T10:29:21.184964400+02: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/po622/api/CancelProductOrderApi.java b/src/main/java/org/etsi/osl/tmf/po622/api/CancelProductOrderApi.java new file mode 100644 index 0000000000000000000000000000000000000000..906cc7a5ad4bc6320b52c461d87f46295d5ff336 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/CancelProductOrderApi.java @@ -0,0 +1,163 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.po622.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.po622.model.CancelProductOrder; +import org.etsi.osl.tmf.po622.model.CancelProductOrderCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-30T10:29:21.184964400+02:00[Europe/Athens]") +@Tag(name = "cancelProductOrder", description = "the cancelProductOrder API") +public interface CancelProductOrderApi { + + Logger log = LoggerFactory.getLogger(CancelProductOrderApi.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 CancelProductOrder", operationId = "createCancelProductOrder", description = "This operation creates a CancelProductOrder entity.", tags={ "cancelProductOrder", }) + @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 = "/cancelProductOrder", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createCancelProductOrder(@Parameter(description = "The CancelProductOrder to be created" ,required=true ) @Valid @RequestBody CancelProductOrderCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"requestedCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"cancellationReason\" : \"cancellationReason\",\r\n \"@type\" : \"@type\",\r\n \"productOrder\" : {\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 \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"effectiveCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", CancelProductOrder.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 CancelProductOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find CancelProductOrder objects", operationId = "listCancelProductOrder", description = "This operation list or find CancelProductOrder entities" , tags={ "cancelProductOrder", }) + @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 = "/cancelProductOrder", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listCancelProductOrder(@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"requestedCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"cancellationReason\" : \"cancellationReason\",\r\n \"@type\" : \"@type\",\r\n \"productOrder\" : {\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 \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"effectiveCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}, {\r\n \"requestedCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"cancellationReason\" : \"cancellationReason\",\r\n \"@type\" : \"@type\",\r\n \"productOrder\" : {\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 \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"effectiveCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default CancelProductOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a CancelProductOrder by ID", operationId = "retrieveCancelProductOrder", description = "This operation retrieves a CancelProductOrder entity. Attribute selection is enabled for all first level attributes.", tags={ "cancelProductOrder", }) + @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 = "/cancelProductOrder/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveCancelProductOrder(@Parameter(description = "Identifier of the CancelProductOrder",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("{\r\n \"requestedCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"cancellationReason\" : \"cancellationReason\",\r\n \"@type\" : \"@type\",\r\n \"productOrder\" : {\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 \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"effectiveCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", CancelProductOrder.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 CancelProductOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/CancelProductOrderApiController.java b/src/main/java/org/etsi/osl/tmf/po622/api/CancelProductOrderApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..a1a2bfebd28ae383a183d601794df942a7639306 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/CancelProductOrderApiController.java @@ -0,0 +1,53 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; + +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 +public class CancelProductOrderApiController implements CancelProductOrderApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public CancelProductOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/po622/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..f23c431ce48983415c167acd08245bac4e9ac966 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.po622.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.po622.model.EventSubscription; +import org.etsi.osl.tmf.po622.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-30T10:29:21.184964400+02:00[Europe/Athens]") +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/po622/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..c4e0dfa75d5989fef9abcb9718ca99664c63f347 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +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("HubApiController622") +@RequestMapping("/productOrderingManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/po622/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..b97f896ab0299949e8e1ea9e4712f5a36274369a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ListenerApi.java @@ -0,0 +1,327 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.po622.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.po622.model.CancelProductOrderCreateEvent; +import org.etsi.osl.tmf.po622.model.CancelProductOrderInformationRequiredEvent; +import org.etsi.osl.tmf.po622.model.CancelProductOrderStateChangeEvent; +import org.etsi.osl.tmf.po622.model.EventSubscription; +import org.etsi.osl.tmf.po622.model.ProductOrderAttributeValueChangeEvent; +import org.etsi.osl.tmf.po622.model.ProductOrderCreateEvent; +import org.etsi.osl.tmf.po622.model.ProductOrderDeleteEvent; +import org.etsi.osl.tmf.po622.model.ProductOrderInformationRequiredEvent; +import org.etsi.osl.tmf.po622.model.ProductOrderStateChangeEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-30T10:29:21.184964400+02:00[Europe/Athens]") +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity CancelProductOrderCreateEvent", operationId = "listenToCancelProductOrderCreateEvent", description = "Example of a client listener for receiving the notification CancelProductOrderCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/cancelProductOrderCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCancelProductOrderCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CancelProductOrderCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CancelProductOrderInformationRequiredEvent", operationId = "listenToCancelProductOrderInformationRequiredEvent", description = "Example of a client listener for receiving the notification CancelProductOrderInformationRequiredEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/cancelProductOrderInformationRequiredEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCancelProductOrderInformationRequiredEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CancelProductOrderInformationRequiredEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CancelProductOrderStateChangeEvent", operationId = "listenToCancelProductOrderStateChangeEvent", description = "Example of a client listener for receiving the notification CancelProductOrderStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/cancelProductOrderStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCancelProductOrderStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CancelProductOrderStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOrderAttributeValueChangeEvent", operationId = "listenToProductOrderAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification ProductOrderAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOrderAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOrderAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOrderAttributeValueChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOrderCreateEvent", operationId = "listenToProductOrderCreateEvent", description = "Example of a client listener for receiving the notification ProductOrderCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOrderCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOrderCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOrderCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOrderDeleteEvent", operationId = "listenToProductOrderDeleteEvent", description = "Example of a client listener for receiving the notification ProductOrderDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOrderDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOrderDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOrderDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOrderInformationRequiredEvent", operationId = "listenToProductOrderInformationRequiredEvent", description = "Example of a client listener for receiving the notification ProductOrderInformationRequiredEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOrderInformationRequiredEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOrderInformationRequiredEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOrderInformationRequiredEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ProductOrderStateChangeEvent", operationId = "listenToProductOrderStateChangeEvent", description = "Example of a client listener for receiving the notification ProductOrderStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/productOrderStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToProductOrderStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ProductOrderStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + 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 new file mode 100644 index 0000000000000000000000000000000000000000..540440c66b276040ec915d53f8e9f4c8c6d96198 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +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/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/po622/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/po622/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..0ce7fbb2858a27ac2bbd2cbdaf797d0abf3cbec4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/NotFoundException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-30T10:29:21.184964400+02: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/po622/api/ProductOrderApi.java b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApi.java new file mode 100644 index 0000000000000000000000000000000000000000..b3851c5e55909c7ffb1388ce61e4d191ddbe455d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApi.java @@ -0,0 +1,220 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.po622.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-10-30T10:29:21.184964400+02:00[Europe/Athens]") +@Tag(name = "productOrder", description = "the productOrder API") +public interface ProductOrderApi { + + Logger log = LoggerFactory.getLogger(ProductOrderApi.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 ProductOrder", operationId = "createProductOrder", description = "This operation creates a ProductOrder entity.", tags={ "productOrder", }) + @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 = "/productOrder", + 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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"channel\" : [ {\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 \"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\" : [ {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"quote\" : [ {\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 \"@baseType\" : \"@baseType\",\r\n \"payment\" : [ {\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 \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"cancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\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 }, {\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 \"cancellationReason\" : \"cancellationReason\",\r\n \"orderTotalPrice\" : [ {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"productOfferingQualification\" : [ {\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 \"externalId\" : \"externalId\",\r\n \"priority\" : \"priority\",\r\n \"relatedParty\" : [ null, null ],\r\n \"notificationContact\" : \"notificationContact\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"category\" : \"category\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", ProductOrder.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 ProductOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ProductOrder", operationId = "deleteProductOrder", description = "This operation deletes a ProductOrder entity.", tags={ "productOrder", }) + @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 = "/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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ProductOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ProductOrder objects", operationId = "listProductOrder", description = "This operation list or find ProductOrder entities" , tags={ "productOrder", }) + @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 = "/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 +,@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"channel\" : [ {\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 \"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\" : [ {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"quote\" : [ {\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 \"@baseType\" : \"@baseType\",\r\n \"payment\" : [ {\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 \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"cancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\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 }, {\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 \"cancellationReason\" : \"cancellationReason\",\r\n \"orderTotalPrice\" : [ {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"productOfferingQualification\" : [ {\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 \"externalId\" : \"externalId\",\r\n \"priority\" : \"priority\",\r\n \"relatedParty\" : [ null, null ],\r\n \"notificationContact\" : \"notificationContact\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"category\" : \"category\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}, {\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"channel\" : [ {\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 \"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\" : [ {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"quote\" : [ {\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 \"@baseType\" : \"@baseType\",\r\n \"payment\" : [ {\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 \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"cancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\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 }, {\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 \"cancellationReason\" : \"cancellationReason\",\r\n \"orderTotalPrice\" : [ {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"productOfferingQualification\" : [ {\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 \"externalId\" : \"externalId\",\r\n \"priority\" : \"priority\",\r\n \"relatedParty\" : [ null, null ],\r\n \"notificationContact\" : \"notificationContact\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"category\" : \"category\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ProductOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a ProductOrder", operationId = "patchProductOrder", description = "This operation updates partially a ProductOrder entity.", tags={ "productOrder", }) + @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 = "/productOrder/{id}", + 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 +,@Parameter(description = "Identifier of the ProductOrder",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"channel\" : [ {\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 \"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\" : [ {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"quote\" : [ {\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 \"@baseType\" : \"@baseType\",\r\n \"payment\" : [ {\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 \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"cancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\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 }, {\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 \"cancellationReason\" : \"cancellationReason\",\r\n \"orderTotalPrice\" : [ {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"productOfferingQualification\" : [ {\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 \"externalId\" : \"externalId\",\r\n \"priority\" : \"priority\",\r\n \"relatedParty\" : [ null, null ],\r\n \"notificationContact\" : \"notificationContact\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"category\" : \"category\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", ProductOrder.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 ProductOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ProductOrder by ID", operationId = "retrieveProductOrder", description = "This operation retrieves a ProductOrder entity. Attribute selection is enabled for all first level attributes.", tags={ "productOrder", }) + @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 = "/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 +,@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("{\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"channel\" : [ {\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 \"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\" : [ {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\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\" : [ {\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\" : [ null, null ],\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 \"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 \"@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 \"@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 \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"priceType\" : \"priceType\",\r\n \"description\" : \"description\",\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n }, {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"productPriceAlteration\" : [ null, null ]\r\n } ],\r\n \"status\" : \"created\"\r\n },\r\n \"quantity\" : 2,\r\n \"@type\" : \"@type\",\r\n \"itemTotalPrice\" : [ null, null ],\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"productOrderItem\" : [ null, null ],\r\n \"productOrderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"itemTerm\" : [ {\r\n \"duration\" : {\r\n \"amount\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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\" : 7.0614014,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"qualification\" : [ null, null ],\r\n \"productOfferingQualificationItem\" : {\r\n \"productOfferingQualificationId\" : \"productOfferingQualificationId\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"productOfferingQualificationName\" : \"productOfferingQualificationName\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"productOfferingQualificationHref\" : \"productOfferingQualificationHref\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"action\" : \"add\",\r\n \"quoteItem\" : {\r\n \"quoteHref\" : \"quoteHref\",\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 \"quoteId\" : \"quoteId\",\r\n \"quoteName\" : \"quoteName\"\r\n },\r\n \"itemPrice\" : [ null, null ],\r\n \"payment\" : [ null, null ],\r\n \"id\" : \"id\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"quote\" : [ {\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 \"@baseType\" : \"@baseType\",\r\n \"payment\" : [ {\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 \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"cancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\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 }, {\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 \"cancellationReason\" : \"cancellationReason\",\r\n \"orderTotalPrice\" : [ {\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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"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 \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"priceAlteration\" : [ {\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 \"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 \"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 \"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 \"priority\" : 5,\r\n \"recurringChargePeriod\" : \"recurringChargePeriod\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ]\r\n } ],\r\n \"productOfferingQualification\" : [ {\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 \"externalId\" : \"externalId\",\r\n \"priority\" : \"priority\",\r\n \"relatedParty\" : [ null, null ],\r\n \"notificationContact\" : \"notificationContact\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"category\" : \"category\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", ProductOrder.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 ProductOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..bf80e2db4a7d9f04b08a42f44f00cd8854490ec4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/po622/api/ProductOrderApiController.java @@ -0,0 +1,55 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +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 +@RequestMapping("/productOrderingManagement/v4/") +public class ProductOrderApiController implements ProductOrderApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ProductOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/prm669/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/prm669/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..1e4884f6cae39be4c878df43f400b9d0c301bbd6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.prm669.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +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/prm669/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/prm669/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..3047c1021eaeb27ec3ff109d6195b47d6bdc0ec0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================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.prm669.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.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +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/prm669/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/prm669/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..a23ed3d36aefbf23c980e321d23af0c8764b6e27 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================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.prm669.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +@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/prm669/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/prm669/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..6e5134b7849dd0557274d217b6e0c3788e662dd8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.prm669.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.prm669.model.EventSubscription; +import org.etsi.osl.tmf.prm669.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/prm669/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/prm669/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..07db62e21d7386dab49f0fffb23ede66894bded3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.prm669.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +@Controller("HubApiController669") +@RequestMapping("/partyRoleManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/prm669/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/prm669/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..a08cfe79544b723d3f12bdbdac9ee8566ec4cc68 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/ListenerApi.java @@ -0,0 +1,192 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.prm669.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.prm669.model.EventSubscription; +import org.etsi.osl.tmf.prm669.model.PartyRoleAttributeValueChangeEvent; +import org.etsi.osl.tmf.prm669.model.PartyRoleCreateEvent; +import org.etsi.osl.tmf.prm669.model.PartyRoleDeleteEvent; +import org.etsi.osl.tmf.prm669.model.PartyRoleStateChangeEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity PartyRoleAttributeValueChangeEvent", operationId = "listenToPartyRoleAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification PartyRoleAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/partyRoleAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToPartyRoleAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody PartyRoleAttributeValueChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity PartyRoleCreateEvent", operationId = "listenToPartyRoleCreateEvent", description = "Example of a client listener for receiving the notification PartyRoleCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/partyRoleCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToPartyRoleCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody PartyRoleCreateEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity PartyRoleDeleteEvent", operationId = "listenToPartyRoleDeleteEvent", description = "Example of a client listener for receiving the notification PartyRoleDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/partyRoleDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToPartyRoleDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody PartyRoleDeleteEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity PartyRoleStateChangeEvent", operationId = "listenToPartyRoleStateChangeEvent", description = "Example of a client listener for receiving the notification PartyRoleStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/partyRoleStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToPartyRoleStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody PartyRoleStateChangeEvent data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/prm669/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/prm669/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..18b36f9a768a749236733429041915587f79423a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.prm669.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +@Controller("ListenerApiController669") +@RequestMapping("/partyRoleManagement/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/prm669/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/prm669/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..b8fde5a4ba1d867a7a03ac5e0801851ac6b60611 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/NotFoundException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.prm669.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +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/prm669/api/PartyRoleApi.java b/src/main/java/org/etsi/osl/tmf/prm669/api/PartyRoleApi.java new file mode 100644 index 0000000000000000000000000000000000000000..08650ef9ee43ddd3c9fd48cf869aee8d06e83a25 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/PartyRoleApi.java @@ -0,0 +1,215 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.prm669.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.prm669.model.PartyRole; +import org.etsi.osl.tmf.prm669.model.PartyRoleCreate; +import org.etsi.osl.tmf.prm669.model.PartyRoleUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +@Tag(name = "partyRole", description = "the partyRole API") +public interface PartyRoleApi { + + Logger log = LoggerFactory.getLogger(PartyRoleApi.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 PartyRole", operationId = "createPartyRole", description = "This operation creates a PartyRole entity.", tags={ "partyRole", }) + @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 = "/partyRole", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createPartyRole(@Parameter(description = "The PartyRole to be created" ,required=true ) @Valid @RequestBody PartyRoleCreate partyRole) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"creditProfile\" : [ { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"characteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"statusReason\" : \"statusReason\", \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"paymentMethod\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"engagedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : \"status\"}", PartyRole.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 PartyRoleApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a PartyRole", operationId = "deletePartyRole", description = "This operation deletes a PartyRole entity.", tags={ "partyRole", }) + @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 = "/partyRole/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deletePartyRole(@Parameter(description = "Identifier of the PartyRole",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PartyRoleApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find PartyRole objects", operationId = "listPartyRole", description = "This operation list or find PartyRole entities" , tags={ "partyRole", }) + @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 = "/partyRole", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listPartyRole(@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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"creditProfile\" : [ { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"characteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"statusReason\" : \"statusReason\", \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"paymentMethod\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"engagedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : \"status\"}, { \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"creditProfile\" : [ { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"characteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"statusReason\" : \"statusReason\", \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"paymentMethod\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"engagedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : \"status\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PartyRoleApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a PartyRole", operationId = "patchPartyRole", description = "This operation updates partially a PartyRole entity.", tags={ "partyRole", }) + @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 = "/partyRole/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchPartyRole(@Parameter(description = "Identifier of the PartyRole",required=true) @PathVariable("id") String id,@Parameter(description = "The PartyRole to be updated" ,required=true ) @Valid @RequestBody PartyRoleUpdate partyRole) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"creditProfile\" : [ { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"characteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"statusReason\" : \"statusReason\", \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"paymentMethod\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"engagedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : \"status\"}", PartyRole.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 PartyRoleApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a PartyRole by ID", operationId = "retrievePartyRole", description = "This operation retrieves a PartyRole entity. Attribute selection is enabled for all first level attributes.", tags={ "partyRole", }) + @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 = "/partyRole/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrievePartyRole(@Parameter(description = "Identifier of the PartyRole",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("{ \"contactMedium\" : [ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } }, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"mediumType\" : \"mediumType\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"preferred\" : true, \"characteristic\" : { \"country\" : \"country\", \"city\" : \"city\", \"@type\" : \"@type\", \"contactType\" : \"contactType\", \"socialNetworkId\" : \"socialNetworkId\", \"emailAddress\" : \"emailAddress\", \"phoneNumber\" : \"phoneNumber\", \"stateOrProvince\" : \"stateOrProvince\", \"@baseType\" : \"@baseType\", \"faxNumber\" : \"faxNumber\", \"postCode\" : \"postCode\", \"street1\" : \"street1\", \"street2\" : \"street2\", \"@schemaLocation\" : \"http://example.com/aeiou\" } } ], \"creditProfile\" : [ { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"creditProfileDate\" : \"2000-01-23T04:56:07.000+00:00\", \"creditScore\" : 6, \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"creditRiskRating\" : 0, \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"agreement\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedParty\" : [ { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"characteristic\" : [ { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } }, { \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"valueType\" : \"valueType\", \"name\" : \"name\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"value\" : { } } ], \"statusReason\" : \"statusReason\", \"@baseType\" : \"@baseType\", \"name\" : \"name\", \"paymentMethod\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"account\" : [ { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, { \"@referredType\" : \"@referredType\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" } ], \"engagedParty\" : { \"@referredType\" : \"@referredType\", \"role\" : \"role\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"name\" : \"name\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\" }, \"status\" : \"status\"}", PartyRole.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 PartyRoleApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/prm669/api/PartyRoleApiController.java b/src/main/java/org/etsi/osl/tmf/prm669/api/PartyRoleApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..ae27be30e47304215a33e92a7fdabe178c27031d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/PartyRoleApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.prm669.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T23:20:50.154+03:00") + +@Controller +@RequestMapping("/partyRoleManagement/v4/") +public class PartyRoleApiController implements PartyRoleApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PartyRoleApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/prm669/api/RFC3339DateFormat.java b/src/main/java/org/etsi/osl/tmf/prm669/api/RFC3339DateFormat.java new file mode 100644 index 0000000000000000000000000000000000000000..fcd2f7ced502f6171deb20a65ba72cc109c0166e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/prm669/api/RFC3339DateFormat.java @@ -0,0 +1,41 @@ +/*- + * ========================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.prm669.api; + +import java.text.FieldPosition; +import java.util.Date; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + + +public class RFC3339DateFormat extends ISO8601DateFormat { + + private static final long serialVersionUID = 1L; + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..b979eefd51f417785a043641a415e2aa4364ad57 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ApiException.java @@ -0,0 +1,33 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import lombok.Getter; + +@Getter +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+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/rcm634/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..feeb9a40f9af4d24d3a9d3fd99ff88b93c09ee75 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ApiOriginFilter.java @@ -0,0 +1,50 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.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 = "2021-05-29T22:34:44.143740800+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/rcm634/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..4eeb83b5893e053abaf5ea6d07949765715046f9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ApiResponseMessage.java @@ -0,0 +1,88 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+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/rcm634/api/ExportJobApi.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ExportJobApi.java new file mode 100644 index 0000000000000000000000000000000000000000..a29a83f92efaa239fe375fa8809fa23f63a8c029 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ExportJobApi.java @@ -0,0 +1,186 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rcm634.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rcm634.model.ExportJob; +import org.etsi.osl.tmf.rcm634.model.ExportJobCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Tag(name = "exportJob", description = "the exportJob API") +public interface ExportJobApi { + + Logger log = LoggerFactory.getLogger(ExportJobApi.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 ExportJob", operationId = "createExportJob", description = "This operation creates a ExportJob entity.", tags={ "exportJob", }) + @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 = "/exportJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createExportJob(@Parameter(description = "The ExportJob to be created" ,required=true ) @Valid @RequestBody ExportJobCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"@type\" : \"@type\",\r\n \"query\" : \"query\",\r\n \"errorLog\" : \"errorLog\",\r\n \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"url\" : \"url\",\r\n \"path\" : \"path\",\r\n \"@baseType\" : \"@baseType\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"contentType\" : \"contentType\",\r\n \"status\" : \"Not Started\"\r\n}", ExportJob.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 ExportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ExportJob", operationId = "deleteExportJob", description = "This operation deletes a ExportJob entity.", tags={ "exportJob", }) + @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 = "/exportJob/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteExportJob(@Parameter(description = "Identifier of the ExportJob",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ExportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ExportJob objects", operationId = "listExportJob", description = "This operation list or find ExportJob entities" , tags={ "exportJob", }) + @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 = "/exportJob", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listExportJob(@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"@type\" : \"@type\",\r\n \"query\" : \"query\",\r\n \"errorLog\" : \"errorLog\",\r\n \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"url\" : \"url\",\r\n \"path\" : \"path\",\r\n \"@baseType\" : \"@baseType\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"contentType\" : \"contentType\",\r\n \"status\" : \"Not Started\"\r\n}, {\r\n \"@type\" : \"@type\",\r\n \"query\" : \"query\",\r\n \"errorLog\" : \"errorLog\",\r\n \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"url\" : \"url\",\r\n \"path\" : \"path\",\r\n \"@baseType\" : \"@baseType\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"contentType\" : \"contentType\",\r\n \"status\" : \"Not Started\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ExportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ExportJob by ID", operationId = "retrieveExportJob", description = "This operation retrieves a ExportJob entity. Attribute selection is enabled for all first level attributes.", tags={ "exportJob", }) + @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 = "/exportJob/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveExportJob(@Parameter(description = "Identifier of the ExportJob",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("{\r\n \"@type\" : \"@type\",\r\n \"query\" : \"query\",\r\n \"errorLog\" : \"errorLog\",\r\n \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"url\" : \"url\",\r\n \"path\" : \"path\",\r\n \"@baseType\" : \"@baseType\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"contentType\" : \"contentType\",\r\n \"status\" : \"Not Started\"\r\n}", ExportJob.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 ExportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ExportJobApiController.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ExportJobApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..23e542e6a2ca71fed64fb736a04908bac3457508 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ExportJobApiController.java @@ -0,0 +1,53 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Controller +public class ExportJobApiController implements ExportJobApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ExportJobApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..d43c15c33e9e36d93d82cee8b54acd78c57e1a0f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rcm634.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rcm634.model.EventSubscription; +import org.etsi.osl.tmf.rcm634.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..6173bb20f2f2530f2ab4e1c41567d4dcbb048ca3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") + +@Controller("HubApiController634") +@RequestMapping("/resourceCatalogManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ImportJobApi.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ImportJobApi.java new file mode 100644 index 0000000000000000000000000000000000000000..9c1c60dbe90023d29ad450954b9d305e77436ecd --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ImportJobApi.java @@ -0,0 +1,186 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rcm634.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rcm634.model.ImportJob; +import org.etsi.osl.tmf.rcm634.model.ImportJobCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Tag(name = "importJob", description = "the importJob API") +public interface ImportJobApi { + + Logger log = LoggerFactory.getLogger(ImportJobApi.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 ImportJob", operationId = "createImportJob", description = "This operation creates a ImportJob entity.", tags={ "importJob", }) + @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 = "/importJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createImportJob(@Parameter(description = "The ImportJob to be created" ,required=true ) @Valid @RequestBody ImportJobCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"path\" : \"path\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"errorLog\" : \"errorLog\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"contentType\" : \"contentType\",\r\n \"url\" : \"url\",\r\n \"status\" : \"Not Started\"\r\n}", ImportJob.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 ImportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ImportJob", operationId = "deleteImportJob", description = "This operation deletes a ImportJob entity.", tags={ "importJob", }) + @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 = "/importJob/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteImportJob(@Parameter(description = "Identifier of the ImportJob",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ImportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ImportJob objects", operationId = "listImportJob", description = "This operation list or find ImportJob entities" , tags={ "importJob", }) + @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 = "/importJob", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listImportJob(@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"path\" : \"path\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"errorLog\" : \"errorLog\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"contentType\" : \"contentType\",\r\n \"url\" : \"url\",\r\n \"status\" : \"Not Started\"\r\n}, {\r\n \"path\" : \"path\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"errorLog\" : \"errorLog\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"contentType\" : \"contentType\",\r\n \"url\" : \"url\",\r\n \"status\" : \"Not Started\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ImportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ImportJob by ID", operationId = "retrieveImportJob", description = "This operation retrieves a ImportJob entity. Attribute selection is enabled for all first level attributes.", tags={ "importJob", }) + @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 = "/importJob/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveImportJob(@Parameter(description = "Identifier of the ImportJob",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("{\r\n \"path\" : \"path\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"errorLog\" : \"errorLog\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"contentType\" : \"contentType\",\r\n \"url\" : \"url\",\r\n \"status\" : \"Not Started\"\r\n}", ImportJob.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 ImportJobApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ImportJobApiController.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ImportJobApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..49c9a129c3a04179a1d6d1183f92148b56453ac6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ImportJobApiController.java @@ -0,0 +1,53 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Controller +public class ImportJobApiController implements ImportJobApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ImportJobApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..2c3573ad702a17cc86cd15c301fe3547c0e8f185 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ListenerApi.java @@ -0,0 +1,591 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rcm634.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rcm634.model.EventSubscription; +import org.etsi.osl.tmf.rcm634.model.ExportJobCreateEvent; +import org.etsi.osl.tmf.rcm634.model.ExportJobStateChangeEvent; +import org.etsi.osl.tmf.rcm634.model.ImportJobCreateEvent; +import org.etsi.osl.tmf.rcm634.model.ImportJobStateChangeEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateChangeEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateCreateEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateDeleteEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogChangeEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogCreateEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogDeleteEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryChangeEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryCreateEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryDeleteEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationChangeEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreateEvent; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationDeleteEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity ExportJobCreateEvent", operationId = "listenToExportJobCreateEvent", description = "Example of a client listener for receiving the notification ExportJobCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/exportJobCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToExportJobCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ExportJobCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ExportJobStateChangeEvent", operationId = "listenToExportJobStateChangeEvent", description = "Example of a client listener for receiving the notification ExportJobStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/exportJobStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToExportJobStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ExportJobStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ImportJobCreateEvent", operationId = "listenToImportJobCreateEvent", description = "Example of a client listener for receiving the notification ImportJobCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/importJobCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToImportJobCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ImportJobCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ImportJobStateChangeEvent", operationId = "listenToImportJobStateChangeEvent", description = "Example of a client listener for receiving the notification ImportJobStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/importJobStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToImportJobStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ImportJobStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCandidateChangeEvent", operationId = "listenToResourceCandidateChangeEvent", description = "Example of a client listener for receiving the notification ResourceCandidateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCandidateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCandidateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCandidateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCandidateCreateEvent", operationId = "listenToResourceCandidateCreateEvent", description = "Example of a client listener for receiving the notification ResourceCandidateCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCandidateCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCandidateCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCandidateCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCandidateDeleteEvent", operationId = "listenToResourceCandidateDeleteEvent", description = "Example of a client listener for receiving the notification ResourceCandidateDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCandidateDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCandidateDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCandidateDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCatalogChangeEvent", operationId = "listenToResourceCatalogChangeEvent", description = "Example of a client listener for receiving the notification ResourceCatalogChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCatalogChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCatalogChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCatalogChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCatalogCreateEvent", operationId = "listenToResourceCatalogCreateEvent", description = "Example of a client listener for receiving the notification ResourceCatalogCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCatalogCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCatalogCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCatalogCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCatalogDeleteEvent", operationId = "listenToResourceCatalogDeleteEvent", description = "Example of a client listener for receiving the notification ResourceCatalogDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCatalogDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCatalogDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCatalogDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCategoryChangeEvent", operationId = "listenToResourceCategoryChangeEvent", description = "Example of a client listener for receiving the notification ResourceCategoryChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCategoryChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCategoryChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCategoryChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCategoryCreateEvent", operationId = "listenToResourceCategoryCreateEvent", description = "Example of a client listener for receiving the notification ResourceCategoryCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCategoryCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCategoryCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCategoryCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCategoryDeleteEvent", operationId = "listenToResourceCategoryDeleteEvent", description = "Example of a client listener for receiving the notification ResourceCategoryDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCategoryDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCategoryDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCategoryDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceSpecificationChangeEvent", operationId = "listenToResourceSpecificationChangeEvent", description = "Example of a client listener for receiving the notification ResourceSpecificationChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceSpecificationChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceSpecificationChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceSpecificationChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceSpecificationCreateEvent", operationId = "listenToResourceSpecificationCreateEvent", description = "Example of a client listener for receiving the notification ResourceSpecificationCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceSpecificationCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceSpecificationCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceSpecificationCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceSpecificationDeleteEvent", operationId = "listenToResourceSpecificationDeleteEvent", description = "Example of a client listener for receiving the notification ResourceSpecificationDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceSpecificationDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceSpecificationDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceSpecificationDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..554505e4f04c47543568d2a3d419b02b7a72cbf2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") + +@Controller("ListenerApiController") +@RequestMapping("/resourceCatalogManagement/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..e30c7bcb07b4dcde21ff8f70d6d1c97db88108f1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/NotFoundException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+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/rcm634/api/ResourceCandidateApi.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCandidateApi.java new file mode 100644 index 0000000000000000000000000000000000000000..543ff7fe251f912668fe4c47e0469e63dbba92df --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCandidateApi.java @@ -0,0 +1,220 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rcm634.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Tag(name = "resourceCandidate", description = "the resourceCandidate API") +public interface ResourceCandidateApi { + + Logger log = LoggerFactory.getLogger(ResourceCandidateApi.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 ResourceCandidate", operationId = "createResourceCandidate", description = "This operation creates a ResourceCandidate entity.", tags={ "resourceCandidate", }) + @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 = "/resourceCandidate", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createResourceCandidate(@Parameter(description = "The ResourceCandidate to be created" ,required=true ) @Valid @RequestBody ResourceCandidateCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceCandidate.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 ResourceCandidateApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ResourceCandidate", operationId = "deleteResourceCandidate", description = "This operation deletes a ResourceCandidate entity.", tags={ "resourceCandidate", }) + @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 = "/resourceCandidate/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteResourceCandidate(@Parameter(description = "Identifier of the ResourceCandidate",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceCandidateApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ResourceCandidate objects", operationId = "listResourceCandidate", description = "This operation list or find ResourceCandidate entities" , tags={ "resourceCandidate", }) + @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 = "/resourceCandidate", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listResourceCandidate(@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}, {\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceCandidateApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a ResourceCandidate", operationId = "patchResourceCandidate", description = "This operation updates partially a ResourceCandidate entity.", tags={ "resourceCandidate", }) + @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 = "/resourceCandidate/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchResourceCandidate(@Parameter(description = "The ResourceCandidate to be updated" ,required=true ) @Valid @RequestBody ResourceCandidateUpdate body +,@Parameter(description = "Identifier of the ResourceCandidate",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceCandidate.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 ResourceCandidateApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ResourceCandidate by ID", operationId = "retrieveResourceCandidate", description = "This operation retrieves a ResourceCandidate entity. Attribute selection is enabled for all first level attributes.", tags={ "resourceCandidate", }) + @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 = "/resourceCandidate/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveResourceCandidate(@Parameter(description = "Identifier of the ResourceCandidate",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("{\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceCandidate.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 ResourceCandidateApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCandidateApiController.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCandidateApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..c7f3bf58020eeeebf6df0a4b3794c45fcec7389b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCandidateApiController.java @@ -0,0 +1,99 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import java.util.List; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateUpdate; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCandidateRepoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Controller +@RequestMapping("/resourceCatalogManagement/v4/") +public class ResourceCandidateApiController implements ResourceCandidateApi { + + + @Autowired + ResourceCandidateRepoService candidateRepoService; + + + @Override + public ResponseEntity createResourceCandidate(@Valid ResourceCandidateCreate body) { + + try { + + ResourceCandidate c = candidateRepoService.addResourceCandidate(body); + + return new ResponseEntity(c, 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 deleteResourceCandidate(String id) { + try { + + return new ResponseEntity( candidateRepoService.deleteById( 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> listResourceCandidate(@Valid String fields, @Valid Integer offset, + @Valid Integer limit) { + + try { + return new ResponseEntity>( candidateRepoService.findAll() , 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 patchResourceCandidate(@Valid ResourceCandidateUpdate body, String id) { + ResourceCandidate c = candidateRepoService.updateCandidate( id, body ); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @Override + public ResponseEntity retrieveResourceCandidate(String id, @Valid String fields) { + try { + + return new ResponseEntity( candidateRepoService.findById( 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/rcm634/api/ResourceCatalogApi.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCatalogApi.java new file mode 100644 index 0000000000000000000000000000000000000000..fa30f8fe7e4d7f48985f5e92fdd32022fb4e1c2d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCatalogApi.java @@ -0,0 +1,220 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rcm634.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalog; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Tag(name = "resourceCatalog", description = "the resourceCatalog API") +public interface ResourceCatalogApi { + + Logger log = LoggerFactory.getLogger(ResourceCatalogApi.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 ResourceCatalog", operationId = "createResourceCatalog", description = "This operation creates a ResourceCatalog entity.", tags={ "resourceCatalog", }) + @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 = "/resourceCatalog", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createResourceCatalog(@Parameter(description = "The ResourceCatalog to be created" ,required=true ) @Valid @RequestBody ResourceCatalogCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceCatalog.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 ResourceCatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ResourceCatalog", operationId = "deleteResourceCatalog", description = "This operation deletes a ResourceCatalog entity.", tags={ "resourceCatalog", }) + @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 = "/resourceCatalog/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteResourceCatalog(@Parameter(description = "Identifier of the ResourceCatalog",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceCatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ResourceCatalog objects", operationId = "listResourceCatalog", description = "This operation list or find ResourceCatalog entities" , tags={ "resourceCatalog", }) + @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 = "/resourceCatalog", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listResourceCatalog(@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}, {\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceCatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a ResourceCatalog", operationId = "patchResourceCatalog", description = "This operation updates partially a ResourceCatalog entity.", tags={ "resourceCatalog", }) + @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 = "/resourceCatalog/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchResourceCatalog(@Parameter(description = "The ResourceCatalog to be updated" ,required=true ) @Valid @RequestBody ResourceCatalogUpdate body +,@Parameter(description = "Identifier of the ResourceCatalog",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceCatalog.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 ResourceCatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ResourceCatalog by ID", operationId = "retrieveResourceCatalog", description = "This operation retrieves a ResourceCatalog entity. Attribute selection is enabled for all first level attributes.", tags={ "resourceCatalog", }) + @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 = "/resourceCatalog/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveResourceCatalog(@Parameter(description = "Identifier of the ResourceCatalog",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("{\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceCatalog.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 ResourceCatalogApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCatalogApiController.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCatalogApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..f4a1a5604fdf1d6b657ca2622eea3aa7b39d4ded --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCatalogApiController.java @@ -0,0 +1,108 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import java.util.List; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalog; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogUpdate; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCatalogRepoService; +import org.springframework.beans.factory.annotation.Autowired; +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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Controller +@RequestMapping("/resourceCatalogManagement/v4/") +public class ResourceCatalogApiController implements ResourceCatalogApi { + + + @Autowired + ResourceCatalogRepoService catalogRepoService ; + + + + @Override + public ResponseEntity createResourceCatalog( + @Parameter(description = "The Resource Catalog to be created" ,required=true ) @Valid @RequestBody ResourceCatalogCreate resourceCatalog) { + try { + + ResourceCatalog c = catalogRepoService.addCatalog( resourceCatalog ); + + return new ResponseEntity(c, 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 deleteResourceCatalog(@Parameter(description = "Identifier of the ResourceCatalog",required=true) @PathVariable("id") String id) { + try { + + return new ResponseEntity( catalogRepoService.deleteById( 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> listResourceCatalog(@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) { + + try { + return new ResponseEntity>( catalogRepoService.findAll() , 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 patchResourceCatalog(@Valid ResourceCatalogUpdate body, String id) { + ResourceCatalog c = catalogRepoService.updateCatalog( id, body ); + + return new ResponseEntity(c, HttpStatus.OK); + } + + + + @Override + public ResponseEntity retrieveResourceCatalog(@Parameter(description = "Identifier of the ResourceCatalog",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + try { + + return new ResponseEntity( catalogRepoService.findById( 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/rcm634/api/ResourceCategoryApi.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCategoryApi.java new file mode 100644 index 0000000000000000000000000000000000000000..930daeefaf2a0d8ff2f665b6a47062940b4210b0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCategoryApi.java @@ -0,0 +1,220 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rcm634.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rcm634.model.ResourceCategory; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Tag(name = "resourceCategory", description = "the resourceCategory API") +public interface ResourceCategoryApi { + + Logger log = LoggerFactory.getLogger(ResourceCategoryApi.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 ResourceCategory", operationId = "createResourceCategory", description = "This operation creates a ResourceCategory entity.", tags={ "resourceCategory", }) + @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 = "/resourceCategory", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createResourceCategory(@Parameter(description = "The ResourceCategory to be created" ,required=true ) @Valid @RequestBody ResourceCategoryCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"isRoot\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceCandidate\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"parentId\" : \"parentId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceCategory.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 ResourceCategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ResourceCategory", operationId = "deleteResourceCategory", description = "This operation deletes a ResourceCategory entity.", tags={ "resourceCategory", }) + @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 = "/resourceCategory/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteResourceCategory(@Parameter(description = "Identifier of the ResourceCategory",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceCategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ResourceCategory objects", operationId = "listResourceCategory", description = "This operation list or find ResourceCategory entities" , tags={ "resourceCategory", }) + @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 = "/resourceCategory", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listResourceCategory(@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"isRoot\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceCandidate\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"parentId\" : \"parentId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}, {\r\n \"isRoot\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceCandidate\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"parentId\" : \"parentId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceCategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a ResourceCategory", operationId = "patchResourceCategory", description = "This operation updates partially a ResourceCategory entity.", tags={ "resourceCategory", }) + @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 = "/resourceCategory/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchResourceCategory(@Parameter(description = "The ResourceCategory to be updated" ,required=true ) @Valid @RequestBody ResourceCategoryUpdate body +,@Parameter(description = "Identifier of the ResourceCategory",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"isRoot\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceCandidate\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"parentId\" : \"parentId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceCategory.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 ResourceCategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ResourceCategory by ID", operationId = "retrieveResourceCategory", description = "This operation retrieves a ResourceCategory entity. Attribute selection is enabled for all first level attributes.", tags={ "resourceCategory", }) + @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 = "/resourceCategory/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveResourceCategory(@Parameter(description = "Identifier of the ResourceCategory",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("{\r\n \"isRoot\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\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 \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceCandidate\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"parentId\" : \"parentId\",\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : [ {\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 \"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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceCategory.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 ResourceCategoryApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCategoryApiController.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCategoryApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..811a6c31070eedc322b78afca9e2bffe45dc78be --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceCategoryApiController.java @@ -0,0 +1,112 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import java.util.List; +import org.etsi.osl.tmf.rcm634.model.ResourceCategory; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryUpdate; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCategoryRepoService; +import org.springframework.beans.factory.annotation.Autowired; +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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Controller +@RequestMapping("/resourceCatalogManagement/v4/") +public class ResourceCategoryApiController implements ResourceCategoryApi { + + @Autowired + ResourceCategoryRepoService categoryRepoService; + + @Override + public ResponseEntity createResourceCategory( + @Parameter(description = "The ServiceCategory to be created", required = true) @Valid @RequestBody ResourceCategoryCreate resCategory) { + + try { + + ResourceCategory c = categoryRepoService.addCategory(resCategory); + + return new ResponseEntity(c, 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 deleteResourceCategory( + @Parameter(description = "Identifier of the Resource Category", required = true) @PathVariable("id") String id) { + try { + if (categoryRepoService.deleteById(id)) { + return new ResponseEntity(HttpStatus.OK); + + } else { + return new ResponseEntity(HttpStatus.NOT_MODIFIED); + } + + } 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> listResourceCategory(@Valid String fields, @Valid Integer offset, + @Valid Integer limit) { + try { + return new ResponseEntity>(categoryRepoService.findAll(), 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 patchResourceCategory(@Valid ResourceCategoryUpdate resourceCategory, String id) { + ResourceCategory c = categoryRepoService.updateCategory(id, resourceCategory); + + return new ResponseEntity(c, HttpStatus.OK); + } + + + @Override + public ResponseEntity retrieveResourceCategory(String id, @Valid String fields) { + try { + + return new ResponseEntity( categoryRepoService.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/rcm634/api/ResourceSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..dc9bd6f4c00ce2f6c159f0f68091f51140440543 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApi.java @@ -0,0 +1,306 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rcm634.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationUpdate; +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; +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.multipart.MultipartFile; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-05-29T22:34:44.143740800+03:00[Europe/Athens]") +@Tag(name = "resourceSpecification", description = "the resourceSpecification API") +public interface ResourceSpecificationApi { + + Logger log = LoggerFactory.getLogger(ResourceSpecificationApi.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 ResourceSpecification", operationId = "createResourceSpecification", description = "This operation creates a ResourceSpecification entity.", tags={ "resourceSpecification", }) + @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 = "/resourceSpecification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + + default ResponseEntity createResourceSpecification(@Parameter(description = "The ResourceSpecification to be created" ,required=true ) @Valid @RequestBody JsonNode jsonNode + ) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"featureSpecification\" : [ {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n }, {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n } ],\r\n \"resourceSpecRelationship\" : [ {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n }, {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n } ],\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"targetResourceSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceSpecification.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 ResourceSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + +// default ResponseEntity createResourceSpecification(@Parameter(description = "The ResourceSpecification to be created" ,required=true ) @Valid @RequestBody ResourceSpecificationCreate body +//) { +// if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { +// if (getAcceptHeader().get().contains("application/json")) { +// try { +// return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"featureSpecification\" : [ {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n }, {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n } ],\r\n \"resourceSpecRelationship\" : [ {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n }, {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n } ],\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"targetResourceSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceSpecification.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 ResourceSpecificationApi interface so no example is generated"); +// } +// return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); +// } + + + @Operation(summary = "Deletes a ResourceSpecification", operationId = "deleteResourceSpecification", description = "This operation deletes a ResourceSpecification entity.", tags={ "resourceSpecification", }) + @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 = "/resourceSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteResourceSpecification(@Parameter(description = "Identifier of the ResourceSpecification",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ResourceSpecification objects", operationId = "listResourceSpecification", description = "This operation list or find ResourceSpecification entities" , tags={ "resourceSpecification", }) + @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 = "/resourceSpecification", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listResourceSpecification(@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"featureSpecification\" : [ {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n }, {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n } ],\r\n \"resourceSpecRelationship\" : [ {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n }, {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n } ],\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"targetResourceSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}, {\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"featureSpecification\" : [ {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n }, {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n } ],\r\n \"resourceSpecRelationship\" : [ {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n }, {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n } ],\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"targetResourceSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a ResourceSpecification", operationId = "patchResourceSpecification", description = "This operation updates partially a ResourceSpecification entity.", tags={ "resourceSpecification", }) + @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 = "/resourceSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchResourceSpecification(@Parameter(description = "The ResourceSpecification to be updated" ,required=true ) @Valid @RequestBody ResourceSpecificationUpdate body +,@Parameter(description = "Identifier of the ResourceSpecification",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"featureSpecification\" : [ {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n }, {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n } ],\r\n \"resourceSpecRelationship\" : [ {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n }, {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n } ],\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"targetResourceSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceSpecification.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 ResourceSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ResourceSpecification by ID", operationId = "retrieveResourceSpecification", description = "This operation retrieves a ResourceSpecification entity. Attribute selection is enabled for all first level attributes.", tags={ "resourceSpecification", }) + @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 = "/resourceSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveResourceSpecification(@Parameter(description = "Identifier of the ResourceSpecification",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("{\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\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 \"version\" : \"version\",\r\n \"resourceSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 2,\r\n \"resourceSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 3,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"valueFrom\" : 9\r\n } ],\r\n \"minCardinality\" : 7,\r\n \"regex\" : \"regex\",\r\n \"resourceSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"featureSpecification\" : [ {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n }, {\r\n \"isBundle\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"featureSpecRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"isEnabled\" : true,\r\n \"name\" : \"name\",\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\" : \"href\",\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\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\",\r\n \"featureSpecCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"featureSpecCharacteristicValue\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"featureSpecCharRelationship\" : [ {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n }, {\r\n \"resourceSpecificationHref\" : \"resourceSpecificationHref\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"characteristicId\" : \"characteristicId\",\r\n \"featureId\" : \"featureId\",\r\n \"resourceSpecificationId\" : \"resourceSpecificationId\"\r\n } ],\r\n \"configurable\" : true\r\n } ]\r\n } ],\r\n \"resourceSpecRelationship\" : [ {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n }, {\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@type\" : \"@type\",\r\n \"defaultQuantity\" : 2,\r\n \"characteristic\" : [ null, null ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"minimumQuantity\" : 7,\r\n \"maximumQuantity\" : 4\r\n } ],\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"content\" : \"content\",\r\n \"url\" : \"url\",\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\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"targetResourceSchema\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ResourceSpecification.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 ResourceSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Adds an attachment to a 'ResourceSpecification'", operationId = "addAttachmentToResourceSpec", description = "This operation adds an attachment to a ResourceSpecification", tags={ "resourceSpecification", }) + @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 = "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 = "/resourceSpecification/{id}/attachment", + produces = { "application/json" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + default ResponseEntity addAttachmentToLogicalResourceSpec( + @Parameter(description = "Identifier of the ResourceSpecification",required=true) @PathVariable("id") String id, + //@Parameter(description = "The Attachment object to be added" ,required=false ) @Valid @ModelAttribute("attachment") String attachment, + @Parameter(description = "The Attachment file to be added" ,required=false, name = "afile" ) @Valid MultipartFile file, + HttpServletRequest request){ + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Get an attachment from a 'ResourceSpecification'", operationId = "getAttachment", + description = "This operation gets an attachment", tags={ "resourceSpecification", }) + @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 = "/resourceSpecification/{id}/attachment/{attid}", + produces = MediaType.ALL_VALUE, + method = RequestMethod.GET) + ResponseEntity getAttachment( + @Parameter(description = "Identifier of the ResourceSpecification",required=true) @PathVariable("id") String id, + @Parameter(description = "Identifier of the Attachment",required=true) @PathVariable("attid") String attid); + + + + @Operation(summary = "Get an attachment from a 'ResourceSpecification' with filename", operationId = "getAttachmentWithFilename", + description = "This operation gets an attachment", tags={ "resourceSpecification", }) + @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 = "/resourceSpecification/{id}/attachment/{attid}/{afilename}", + produces = MediaType.ALL_VALUE , + method = RequestMethod.GET) + ResponseEntity getAttachmentWithFilename( + @Parameter(description = "Identifier of the ResourceSpecification",required=true) @PathVariable("id") String id, + @Parameter(description = "Identifier of the Attachment",required=true) @PathVariable("attid") String attid, + @Parameter(description = "Identifier of the Filename",required=true) @PathVariable("afilename") String afilename); + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..0320df58d986f06c71b2de8ddca74417ab206f99 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApiController.java @@ -0,0 +1,279 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.rcm634.api; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.io.IOUtils; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceFunctionSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.CacheControl; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +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.multipart.MultipartFile; +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:06:08.595+03:00") + +@Controller +@RequestMapping("/resourceCatalogManagement/v4/") +public class ResourceSpecificationApiController implements ResourceSpecificationApi { + + private static final Logger log = LoggerFactory.getLogger(ResourceSpecificationApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + +// private PolymorphicTypeValidator getPTV() { +// return BasicPolymorphicTypeValidator.builder().allowIfBaseType(ResourceSpecification.class) +// .build(); +// } + + + @org.springframework.beans.factory.annotation.Autowired + public ResourceSpecificationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + // objectMapper.activateDefaultTyping(getPTV(), ObjectMapper.DefaultTyping.EVERYTHING); + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable( objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + + @Autowired + ResourceSpecificationRepoService resourceSpecificationRepoService; + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createResourceSpecification(JsonNode jsonNode) { + try { + + log.info( jsonNode.asText() ); + + JsonNode an = jsonNode.path("@type"); + + if ( an != null ) { + + log.info( an.asText() ); + if ( an.asText().equals("PhysicalResourceSpecification")) { + @Valid + PhysicalResourceSpecificationCreate serviceSpecification = objectMapper.treeToValue( jsonNode, PhysicalResourceSpecificationCreate.class); + ResourceSpecification c = resourceSpecificationRepoService.addPhysicalResourceSpecification(serviceSpecification ); + return new ResponseEntity(c, HttpStatus.OK); + + } else if ( an.asText().equals("ResourceFunctionSpecification")) { + @Valid + ResourceFunctionSpecificationCreate serviceSpecification = objectMapper.treeToValue( jsonNode, ResourceFunctionSpecificationCreate.class); + ResourceSpecification c = resourceSpecificationRepoService.addResourceFunctionSpecification(serviceSpecification ); + return new ResponseEntity(c, HttpStatus.OK); + + } + + + + } + + ResourceSpecificationCreate serviceSpecification = objectMapper.treeToValue( jsonNode, ResourceSpecificationCreate.class); + ResourceSpecification c = resourceSpecificationRepoService.addLogicalResourceSpecification(serviceSpecification); + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity deleteResourceSpecification( + @Parameter(description = "Identifier of the ResourceSpecification", required = true) @PathVariable("id") String id) { + try { + + return new ResponseEntity(resourceSpecificationRepoService.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> listResourceSpecification( + @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) { + + try { + if ((fields == null) ) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>(resourceSpecificationRepoService.findAll(myfields), + HttpStatus.OK); + } else { + + return new ResponseEntity>(resourceSpecificationRepoService.findAll(fields), + 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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity patchResourceSpecification(@Valid ResourceSpecificationUpdate serviceSpecification, + String id) { + + ResourceSpecification c = resourceSpecificationRepoService.updateResourceSpecification(id, serviceSpecification); + + return new ResponseEntity(c, HttpStatus.OK); + } + + + + @Override + public ResponseEntity retrieveResourceSpecification( + @Parameter(description = "Identifier of the ResourceSpecification", required = true) @PathVariable("id") String id, + @Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + try { + + return new ResponseEntity( resourceSpecificationRepoService.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); + } + + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity addAttachmentToLogicalResourceSpec( + String id, + //@Parameter(description = "The Attachment object to be added" ,required=false ) @Valid @ModelAttribute("attachment") String attachment, + @Parameter(description = "The Attachment file to be added" ,required=false, name = "afile" ) @Valid MultipartFile afile, + HttpServletRequest request){ + + try { + + //log.info("addAttachmentToLogicalResourceSpec attachment=" + attachment); + log.info("addAttachmentToLogicalResourceSpec file=" + afile); + + //Attachment att = objectMapper.readValue(attachment, Attachment.class); + + ResourceSpecification c = (ResourceSpecification) resourceSpecificationRepoService.addAttachmentToResourceSpec( id, afile, request.getRequestURI() ); + + return new ResponseEntity(c, 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 getAttachment(String id, String attid) { + try { + Attachment att; + if ( attid.equals("logo")) { + att = resourceSpecificationRepoService.getAttachmentLogo( id, attid ); + } else { + att = resourceSpecificationRepoService.getAttachment( attid ); + } + + if ( att == null ) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + + File file = new File( att.getContent() ); + Path path = Paths.get(file.getAbsolutePath()); + //ByteArrayResource resource = new ByteArrayResource(Files.readAllBytes(path)); + HttpHeaders headers = new HttpHeaders(); + InputStream in = new FileInputStream( file ); + + byte[] media = IOUtils.toByteArray(in); + headers.setCacheControl(CacheControl.noCache().getHeaderValue()); + headers.setContentType( MediaType. parseMediaType( att.getMimeType()) ); + + if ( att.getMimeType().contains("zip") || att.getMimeType().contains("gz")) { + headers.add( "Content-Disposition", "attachment; filename=" + file.getName());//remove this returns directly the object + } + + ResponseEntity responseEntity = new ResponseEntity<>(media, headers, HttpStatus.OK); + return responseEntity; + + +// return ResponseEntity.ok() +// .header("Content-Disposition", "attachment; filename=" + file.getName()) +// .contentLength(file.length()) +// .contentType( MediaType. parseMediaType( att.getMimeType()) )//MediaType.parseMediaType("application/gzip")) +// .body(resource); + + + } catch (Exception e) { + log.error("Couldn't serialize response ByteArrayResource", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @Override + public ResponseEntity getAttachmentWithFilename(String id, String attid, String afilename) { + return getAttachment(id, attid); + } + +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..59e04eaa6022e9d37affddd650e6be50dc08545f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/api/ResourceSpecificationApiRouteBuilder.java @@ -0,0 +1,91 @@ +package org.etsi.osl.tmf.rcm634.api; + +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.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +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 ResourceSpecificationApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog( ResourceSpecificationApiRouteBuilder.class.getName()); + + @Value("${CATALOG_ADD_RESOURCESPEC}") + private String CATALOG_ADD_RESOURCESPEC = ""; + + @Value("${CATALOG_UPD_RESOURCESPEC}") + private String CATALOG_UPD_RESOURCESPEC = ""; + + @Value("${CATALOG_UPDADD_RESOURCESPEC}") + private String CATALOG_UPDADD_RESOURCESPEC = ""; + + @Value("${CATALOG_GET_RESOURCESPEC_BY_ID}") + private String CATALOG_GET_RESOURCESPEC_BY_ID = ""; + + + @Value("${CATALOG_GET_RESOURCESPEC_BY_ΝAME_CATEGORY}") + private String CATALOG_GET_RESOURCESPEC_BY_ΝAME_CATEGORY = ""; + + @Autowired + private ProducerTemplate template; + + @Autowired + ResourceSpecificationRepoService resourceSpecificationRepoService; + + @Override + public void configure() throws Exception { + + from( CATALOG_ADD_RESOURCESPEC ) + .log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCESPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal() + .json( JsonLibrary.Jackson, ResourceSpecificationCreate .class, true) + .bean( resourceSpecificationRepoService, "addResourceSpecification(${body})") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_UPD_RESOURCESPEC ) + .log(LoggingLevel.INFO, log, CATALOG_UPD_RESOURCESPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ResourceSpecificationUpdate.class, true) + .bean( resourceSpecificationRepoService, "updateResourceSpecification(${header.resourceSpecId}, ${body} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_UPDADD_RESOURCESPEC ) + .log(LoggingLevel.INFO, log, CATALOG_UPDADD_RESOURCESPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ResourceSpecificationCreate.class, true) + .bean( resourceSpecificationRepoService, "addOrupdateResourceSpecificationByNameCategoryVersion(${header.aname}, ${header.acategory}, ${header.aversion}, ${body} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_GET_RESOURCESPEC_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_RESOURCESPEC_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( resourceSpecificationRepoService, "findByUuidEager") + .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!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( resourceSpecificationRepoService, "findByNameAndCategoryAndVersionEager(${header.aname}, ${header.acategory}, ${header.aversion} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceCandidateRepository.java b/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceCandidateRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..461936de74495def859f2d2681d74bb157490a34 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceCandidateRepository.java @@ -0,0 +1,39 @@ +/*- + * ========================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.rcm634.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidate; +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 ResourceCandidateRepository extends CrudRepository , PagingAndSortingRepository { + + + Optional findByUuid(String id); + + @Query("SELECT sc FROM ResourceCandidate sc JOIN FETCH sc.resourceSpecificationObj spec WHERE spec.uuid = ?1") + Optional findByResourceSpecUuid(String id); + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceCatalogRepository.java b/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceCatalogRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..4deaee41b991a1df2efb24076a9fce68e952eed9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceCatalogRepository.java @@ -0,0 +1,39 @@ +/*- + * ========================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.rcm634.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalog; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface ResourceCatalogRepository extends CrudRepository , PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Optional findByName(String aName); + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceCategoriesRepository.java b/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceCategoriesRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..ebce8cf572383c3134c37ffe293cc173910aa77e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceCategoriesRepository.java @@ -0,0 +1,39 @@ +/*- + * ========================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.rcm634.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.rcm634.model.ResourceCategory; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface ResourceCategoriesRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Optional findByName(String aName); + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceSpecificationRepository.java b/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceSpecificationRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..456b890768270f1806cade84f393def6d17cd299 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/repo/ResourceSpecificationRepository.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.rcm634.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +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 ResourceSpecificationRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + @Query("SELECT sc FROM LogicalRspec sc") + List findAllLogical(); + + + List findByName(String aname ); + + List findByNameAndVersion(String aname, String aversion); + + List findByNameAndCategory(String aname, String acategory); + + + List findByNameAndCategoryAndVersion(String aname, String acategory, String aversion); + + @Query("SELECT sc FROM PhysicalRspec sc") + List findAllPhysical(); + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceCandidateRepoService.java b/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceCandidateRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..c508efd17f2a4fb709653758a34221f9d6bbe158 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceCandidateRepoService.java @@ -0,0 +1,176 @@ +/*- + * ========================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.rcm634.reposervices; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceCategory; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryRef; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.repo.ResourceCandidateRepository; +import org.etsi.osl.tmf.rcm634.repo.ResourceSpecificationRepository; +import org.etsi.osl.tmf.scm633.model.ServiceCandidate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.validation.Valid; + +@Service +public class ResourceCandidateRepoService { + + + @Autowired + ResourceCandidateRepository candidateRepo; + + @Autowired + ResourceCategoryRepoService categsRepoService; + + @Autowired + ResourceSpecificationRepository resourceSpecificationRepo; + + public ResourceCandidate addCatalog( ResourceCandidate c) { + + return this.candidateRepo.save( c ); + } + + public ResourceCandidate addResourceCandidate(@Valid ResourceCandidateCreate resCand) { + + + ResourceCandidate sc = new ResourceCandidate() ; +// if ( resCand.getResourceSpecification() != null) { +// Optional optsc = this.candidateRepo.findByResourceSpecUuid(resCand.getResourceSpecification().getId()); +// if (optsc.isPresent() ) { +// sc = optsc.get();//add to an existing candidate +// } +// } + + sc = updateResourceCandidateDataFromAPI( sc, resCand); + + return this.candidateRepo.save( sc ); + } + + public List findAll() { + return (List) this.candidateRepo.findAll(); + } + + public ResourceCandidate findById(String id) { + Optional optionalCat = this.candidateRepo.findByUuid( id ); + return optionalCat + .orElse(null); + } + + public Void deleteById(String id) { + Optional optionalCat = this.candidateRepo.findByUuid( id ); + if ( !optionalCat.isEmpty() ) { + this.candidateRepo.delete( optionalCat.get()); + + } + return null; + + } + + @Transactional + public ResourceCandidate updateCandidate(String id, @Valid ResourceCandidateUpdate serviceCandidate) { + Optional scopt = this.candidateRepo.findByUuid(id); + if ( scopt == null ) { + return null; + } + ResourceCandidate sc = scopt.get(); + + sc = updateResourceCandidateDataFromAPI( sc, serviceCandidate); + + return this.candidateRepo.save( sc ); + } + + + @Transactional + public ResourceCandidate updateResourceCandidateDataFromAPI(ResourceCandidate sc, @Valid ResourceCandidateUpdate resourceCandidateUpd) { + + ResourceSpecification specObj = null; + + if ( resourceCandidateUpd.getResourceSpecification()!=null) { + Optional optionalCat = this.resourceSpecificationRepo.findByUuid( resourceCandidateUpd.getResourceSpecification().getId() ); + specObj = optionalCat.orElse(null); + } + + if ( specObj != null ) { + sc.setName( specObj.getName() ); + sc.setDescription( specObj.getDescription() ); + sc.setLifecycleStatusEnum ( ELifecycle.getEnum( specObj.getLifecycleStatus() ) ); + sc.setVersion( specObj.getVersion() ); + } else { + sc.setName( resourceCandidateUpd.getName() ); + sc.setDescription( resourceCandidateUpd.getDescription() ); + sc.setLifecycleStatusEnum( ELifecycle.LAUNCHED ); + sc.setVersion( resourceCandidateUpd.getVersion()); + } + + sc.setLastUpdate( OffsetDateTime.now(ZoneOffset.UTC) ); + if ( resourceCandidateUpd.getLifecycleStatus() == null ) { + sc.setLifecycleStatusEnum( ELifecycle.LAUNCHED ); + } else { + sc.setLifecycleStatusEnum ( ELifecycle.getEnum( resourceCandidateUpd.getLifecycleStatus() ) ); + } + TimePeriod tp = new TimePeriod(); + + if ( sc.getValidFor() != null ){ + tp.setStartDateTime( sc.getValidFor().getStartDateTime() ); + tp.setEndDateTime( sc.getValidFor().getEndDateTime() ); + } + sc.setValidFor( tp ); + + if ( specObj != null){ + sc.setResourceSpecificationObj( specObj ); + } + + //save first to continue + ResourceCandidate savedCand = this.candidateRepo.save( sc ); + + + if ( resourceCandidateUpd.getCategory() !=null ){ + for (ResourceCategoryRef sCategD : resourceCandidateUpd.getCategory()) { + ResourceCategory catObj = this.categsRepoService.findByIdEager(sCategD.getId()); + + if ( catObj!=null){ + catObj.getResourceCandidateObj().add(savedCand); //add candidate ref to category + catObj = this.categsRepoService.categsRepo.save(catObj); + + } + } + } + + + return savedCand; + } + + public Optional findByUuid(String id) { + // TODO Auto-generated method stub + return null; + } + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceCatalogRepoService.java b/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceCatalogRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..422a7bd8523787e091c9bee0619bfd3209c7851d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceCatalogRepoService.java @@ -0,0 +1,183 @@ +/*- + * ========================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.rcm634.reposervices; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalog; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceCategory; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryRef; +import org.etsi.osl.tmf.rcm634.repo.ResourceCatalogRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import jakarta.validation.Valid; + +@Service +public class ResourceCatalogRepoService { + + @Autowired + ResourceCatalogRepository catalogRepo; + + @Autowired + ResourceCategoryRepoService categRepoService; + + @Autowired + ResourceSpecificationRepoService resourceSpecRepoService; + + @Autowired + ResourceCandidateRepoService candidateRepoService; + + public ResourceCatalog addCatalog(ResourceCatalog c) { + + return this.catalogRepo.save(c); + } + + public ResourceCatalog addCatalog(@Valid ResourceCatalogCreate serviceCat) { + + ResourceCatalog sc = new ResourceCatalog(); + + sc = updateCatalogDataFromAPICall(sc, serviceCat); + return this.catalogRepo.save(sc); + } + + public List findAll() { + return (List) this.catalogRepo.findAll(); + } + + public ResourceCatalog findById(String id) { + Optional optionalCat = this.catalogRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + public Void deleteById(String id) { + Optional optionalCat = this.catalogRepo.findByUuid(id); + this.catalogRepo.delete(optionalCat.get()); + return null; + + } + + public ResourceCatalog updateCatalog(String id, ResourceCatalogUpdate serviceCatalog) { + + Optional optSC = catalogRepo.findByUuid(id); + if (optSC == null) { + return null; + } + ResourceCatalog sc = optSC.get(); + sc = updateCatalogDataFromAPICall(sc, serviceCatalog); + return this.catalogRepo.save(sc); + } + + public ResourceCatalog updateCatalog(ResourceCatalog serviceCatalog) { + + return this.catalogRepo.save(serviceCatalog); + } + + public ResourceCatalog updateCatalogDataFromAPICall(ResourceCatalog rc, ResourceCatalogUpdate resCatalog) { + + if (resCatalog.getName()!=null){ + rc.setName(resCatalog.getName()); + } + + if (resCatalog.getDescription()!=null){ + rc.setDescription(resCatalog.getDescription()); + } + if (resCatalog.getLifecycleStatus() != null) { + rc.setLifecycleStatusEnum(ELifecycle.getEnum(resCatalog.getLifecycleStatus())); + } + if (resCatalog.getVersion() != null) { + rc.setVersion(resCatalog.getVersion()); + } + rc.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + TimePeriod tp = new TimePeriod(); + if (resCatalog.getValidFor() != null) { + tp.setStartDateTime(resCatalog.getValidFor().getStartDateTime()); + tp.setEndDateTime(resCatalog.getValidFor().getEndDateTime()); + rc.setValidFor(tp); + } + + + // add any new category + if (resCatalog.getCategory() != null) { + rc.getCategoryObj().clear(); + for (ResourceCategoryRef scref : resCatalog.getCategory()) { + ResourceCategory servcat = this.categRepoService.findByUuid(scref.getId()); + rc.addCategory(servcat); + } + } + + return rc; + + } + + +/*--------------------------------------------------------------------------------------------------------------- + @PostConstruct + public void initRepo() { + if (this.findAll().size() == 0) { + ResourceCatalogCreate sc = new ResourceCatalogCreate(); + sc.setName("Catalog"); + sc.setDescription("Primary Resource Catalog"); + sc.setVersion("1.0"); + ResourceCatalog scatalog = this.addCatalog(sc); + + ResourceCategoryCreate scatCreate = new ResourceCategoryCreate(); + scatCreate.setName("Generic Resources"); + scatCreate.setDescription("Generic Resources of this catalog"); + scatCreate.setVersion("1.0"); + scatCreate.setIsRoot(true); + ResourceCategory scategory = this.categRepoService.addCategory(scatCreate); + + scatalog.getCategoryObj().add(scategory); + this.catalogRepo.save(scatalog); + + ResourceSpecification resSpecificationObj = this.resourceSpecRepoService.initRepo(); + + + ResourceCandidateCreate scand = new ResourceCandidateCreate(); + scand.setName( resSpecificationObj.getName()); + ResourceSpecificationRef resSpecificationRef = new ResourceSpecificationRef(); + resSpecificationRef.setId(resSpecificationObj.getId()); + resSpecificationRef.setName(resSpecificationObj.getName()); + scand.resourceSpecification(resSpecificationRef); + + ResourceCategoryRef categoryItem = new ResourceCategoryRef(); + categoryItem.setId(scategory.getId()); + scand.addCategoryItem(categoryItem); + + this.candidateRepoService.addResourceCandidate(scand); + } + } +---------------------------------------------------------------------------------------------------------------*/ + + + public ResourceCatalog findByName(String aName) { + Optional optionalCat = this.catalogRepo.findByName( aName ); + return optionalCat.orElse(null); + } + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceCategoryRepoService.java b/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceCategoryRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..421cb1299daa5804d4d704cc31beab3c96ab9a58 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceCategoryRepoService.java @@ -0,0 +1,293 @@ +/*- + * ========================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.rcm634.reposervices; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateRef; +import org.etsi.osl.tmf.rcm634.model.ResourceCategory; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryRef; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryUpdate; +import org.etsi.osl.tmf.rcm634.repo.ResourceCandidateRepository; +import org.etsi.osl.tmf.rcm634.repo.ResourceCatalogRepository; +import org.etsi.osl.tmf.rcm634.repo.ResourceCategoriesRepository; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class ResourceCategoryRepoService { + + + @Autowired + ResourceCategoriesRepository categsRepo; + + + @Autowired + ResourceCandidateRepository candidateRepo; + + + @Autowired + ResourceCatalogRepository catalogRepo; + + + private SessionFactory sessionFactory; + + /** + * from https://stackoverflow.com/questions/25063995/spring-boot-handle-to-hibernate-sessionfactory + * @param factory + */ + @Autowired + public ResourceCategoryRepoService(EntityManagerFactory factory) { + if(factory.unwrap(SessionFactory.class) == null){ + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + + public ResourceCategory addCategory(ResourceCategory c) { + + return this.categsRepo.save( c ); + } + + public ResourceCategory addCategory(@Valid ResourceCategoryCreate resCategory) { + + + ResourceCategory sc = new ResourceCategory() ; + sc = updateCategoryDataFromAPICall(sc, resCategory); + return this.categsRepo.save( sc ); + + } + + public List findAll() { + return (List) this.categsRepo.findAll(); + } + + public ResourceCategory findByUuid(String id) { + Optional optionalCat = this.categsRepo.findByUuid( id ); + return optionalCat + .orElse(null); + } + + + public ResourceCategory findByIdEager(String id) { +// Optional optionalCat = this.categsRepo.findByIdEager( id ); +// return optionalCat +// .orElse(null); + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + ResourceCategory dd = null; + try { + dd = (ResourceCategory) session.get(ResourceCategory.class, id); + if ( dd != null ) { + Hibernate.initialize( dd.getCategoryObj() ); + Hibernate.initialize( dd.getResourceCandidateObj() ); + for (ResourceCandidate rc : dd.getResourceCandidateObj()) { + Hibernate.initialize(rc ); + Hibernate.initialize(rc.getCategoryObj() ); + + } + } else { + return this.findByUuid(id); + } + + tx.commit(); + } finally { + session.close(); + } + return dd; + } + + + + + + public boolean deleteById(String id) { + Optional optionalCat = this.categsRepo.findByUuid( id ); + + if ( optionalCat.get().getCategoryObj().size()>0 ) { + return false; //has children + } + + if ( optionalCat.get().getParentId() != null ) { + ResourceCategory parentCat = (this.categsRepo.findByUuid( optionalCat.get().getParentId() )).get(); + + //remove from parent category + for (ResourceCategory ss : parentCat.getCategoryObj()) { + if ( ss.getId() == optionalCat.get().getId() ) { + parentCat.getCategoryObj().remove(ss); + break; + } + } + parentCat = this.categsRepo.save(parentCat); + } + + + this.categsRepo.delete( optionalCat.get()); + return true; + + } + + public ResourceCategory updateCategory(String id, @Valid ResourceCategoryUpdate serviceCategory) { + Optional optionalCat = this.categsRepo.findByUuid( id ); + if ( optionalCat == null ) { + return null; + } + + ResourceCategory sc = optionalCat.get(); + sc = updateCategoryDataFromAPICall(sc, serviceCategory); + return this.categsRepo.save( sc ); + } + + public ResourceCategory updateCategoryDataFromAPICall( ResourceCategory sc, ResourceCategoryUpdate resCatUpd ) + { + if (resCatUpd.getName()!=null){ + sc.setName( resCatUpd.getName() ); + } + if ( resCatUpd.getDescription() != null){ + sc.setDescription( resCatUpd.getDescription()); + } + + if ( resCatUpd.isIsRoot() != null ){ + sc.setIsRoot( resCatUpd.isIsRoot()); + } + if ( resCatUpd.getLifecycleStatus() != null ) { + sc.setLifecycleStatusEnum ( ELifecycle.getEnum( resCatUpd.getLifecycleStatus() ) ); + } + + if ( resCatUpd.getParentId() != null ){ + sc.setParentId( resCatUpd.getParentId()); + } + + if ( resCatUpd.getVersion() != null ) { + sc.setVersion( resCatUpd.getVersion() ); + } + sc.setLastUpdate( OffsetDateTime.now(ZoneOffset.UTC) ); + TimePeriod tp = new TimePeriod(); + if ( resCatUpd.getValidFor() != null ) { + tp.setStartDateTime( resCatUpd.getValidFor().getStartDateTime() ); + tp.setEndDateTime( resCatUpd.getValidFor().getEndDateTime() ); + sc.setValidFor( tp ); + } + + if ( resCatUpd.getCategory() !=null ) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ResourceCategoryRef ref : resCatUpd.getCategory() ) { + //find by id and reload it here. + boolean idexists = false; + for (ResourceCategory originalSCat : sc.getCategoryObj()) { + if ( originalSCat.getId().equals( ref.getId())) { + idexists = true; + idAddedUpdated.put( originalSCat.getId(), true); + break; + } + } + if (!idexists) { + Optional catToAdd = this.categsRepo.findByUuid( ref.getId() ); + if ( catToAdd.isPresent() ) { + ResourceCategory scatadd = catToAdd.get(); + sc.getCategoryObj().add( scatadd ); + idAddedUpdated.put( ref.getId(), true); + + scatadd.setParentId( sc.getUuid()); + scatadd = this.categsRepo.save( scatadd ); + } + } + } + List toRemove = new ArrayList<>(); + for (ResourceCategory ss : sc.getCategoryObj()) { + if ( idAddedUpdated.get( ss.getId() ) == null ) { + toRemove.add(ss); + } + } + + for (ResourceCategory ar : toRemove) { + sc.getCategoryObj().remove(ar); + } + } + + if ( resCatUpd.getResourceCandidate() !=null ) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ResourceCandidateRef ref : resCatUpd.getResourceCandidate() ) { + //find by id and reload it here. + boolean idexists = false; + for (ResourceCandidate originalSCat : sc.getResourceCandidateObj()) { + if ( originalSCat.getId().equals( ref.getId())) { + idexists = true; + idAddedUpdated.put( originalSCat.getId(), true); + break; + } + } + if (!idexists) { + Optional catToAdd = this.candidateRepo.findByUuid( ref.getId() ); + if ( catToAdd.isPresent() ) { + ResourceCandidate scatadd = catToAdd.get(); + sc.getResourceCandidateObj().add( scatadd ); + idAddedUpdated.put( ref.getId(), true); + + } + } + } + List toRemove = new ArrayList<>(); + for (ResourceCandidate ss : sc.getResourceCandidateObj()) { + if ( idAddedUpdated.get( ss.getId() ) == null ) { + toRemove.add(ss); + } + } + + for (ResourceCandidate ar : toRemove) { + sc.getResourceCandidateObj().remove(ar); + } + } + + + + return sc; + } + + + public ResourceCategory findByName(String aName) { + Optional optionalCat = this.categsRepo.findByName( aName ); + return optionalCat + .orElse(null); + } + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceSpecificationRepoService.java b/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceSpecificationRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..69214b4098061e1c66b4ae5cab7789b6c76c014a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rcm634/reposervices/ResourceSpecificationRepoService.java @@ -0,0 +1,757 @@ +/*- + * ========================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.rcm634.reposervices; + +import java.io.File; +import java.io.IOException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.Attachment; +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.pcm620.reposervices.AttachmentRepoService; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceFunctionSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceFunctionSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristic; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.repo.ResourceSpecificationRepository; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.util.AttachmentUtil; +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.core.io.ClassPathResource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class ResourceSpecificationRepoService { + private static final transient Log logger = LogFactory.getLog(ResourceSpecificationRepoService.class.getName()); + + @Autowired + ObjectMapper objectMapper; + + @Autowired + ResourceSpecificationRepository resourceSpecificationRepo; + + @Autowired + AttachmentRepoService attachmentRepoService; + + + @Autowired + ResourceCandidateRepoService resCandidateRepoService; + + + private SessionFactory sessionFactory; + + private static final String METADATADIR = System.getProperty("user.home") + File.separator + ".attachments" + + File.separator + "metadata" + File.separator; + + @Autowired + public ResourceSpecificationRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public ResourceSpecification addResourceSpec(ResourceSpecification reSpec) { + return this.resourceSpecificationRepo.save(reSpec); + } + + + + @Transactional + public ResourceSpecification addResourceSpecification(@Valid ResourceSpecificationCreate resourceSpecification) { + + ResourceSpecification reSpec ; + if (resourceSpecification.getType() !=null && ( resourceSpecification.getType().equals( "PhysicalResourceSpecification" ) || + resourceSpecification.getType().equals( "PhysicalResourceSpecificationCreate" ) )) { + reSpec = new PhysicalResourceSpecification(); + }else { + reSpec = new LogicalResourceSpecification(); + } + + return addResourceSpecificationGeneric(reSpec, resourceSpecification); + } + + public LogicalResourceSpecification addLogicalResourceSpecification(@Valid ResourceSpecificationCreate logicalResourceSpec) { + LogicalResourceSpecification reSpec = new LogicalResourceSpecification(); + + return (LogicalResourceSpecification) addResourceSpecificationGeneric(reSpec, logicalResourceSpec); + } + + + public LogicalResourceSpecification addResourceFunctionSpecification(@Valid ResourceFunctionSpecificationCreate serviceSpecification) { + ResourceFunctionSpecification reSpec = new ResourceFunctionSpecification(); + + return (ResourceFunctionSpecification) addResourceSpecificationGeneric(reSpec, serviceSpecification); + } + + + + public PhysicalResourceSpecification addPhysicalResourceSpecification(@Valid PhysicalResourceSpecificationCreate pResourceSpec) { + PhysicalResourceSpecification reSpec = new PhysicalResourceSpecification(); + + return (PhysicalResourceSpecification) addResourceSpecificationGeneric(reSpec, pResourceSpec); + } + + private ResourceSpecification addResourceSpecificationGeneric(ResourceSpecification reSpec, @Valid ResourceSpecificationUpdate resourceSpecification) { + + reSpec = this.updateResourceSpecDataFromAPIcall(reSpec, resourceSpecification); + reSpec = this.resourceSpecificationRepo.save(reSpec); + reSpec.fixResourceCharRelationhsipIDs(); + + /* + * automatically create resource candidate + */ + + ResourceCandidateCreate rCandidate = new ResourceCandidateCreate(); + ResourceSpecificationRef rSpecRef = new ResourceSpecificationRef(); + rCandidate.setResourceSpecification(rSpecRef ); + rSpecRef.setId( reSpec.getId() ); + ResourceCandidate resCand = resCandidateRepoService.addResourceCandidate(rCandidate); + reSpec.setResourceCandidateObjId( resCand.getUuid() ); + + return this.resourceSpecificationRepo.save(reSpec); + } + + + public List findAll(@Valid String fields) { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { + + String sql = "SELECT " + + "s.uuid as uuid," + + "s.id as id," + + "s.name as name," + + "s.description as description," + + "s.category as category," + + "s.version as version," + + "s.type as type"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM ResSpec s"; + + + sql += " ORDER BY s.name"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + 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() { + return (List) this.resourceSpecificationRepo.findAll(); + } + + public List findAllLogical() { + return (List) this.resourceSpecificationRepo.findAllLogical(); + } + + public List findAllPhysical() { + return (List) this.resourceSpecificationRepo.findAllPhysical(); + } + + public ResourceSpecification findByUuid(String id) { + Optional optionalCat = this.resourceSpecificationRepo.findByUuid( id ); + return optionalCat + .orElse(null); + } + + @Transactional + public ResourceSpecification findByUuidEager(String id) { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); // instead of begin transaction, is it possible to continue? + try { + ResourceSpecification dd = null; + try { + dd = session.get(ResourceSpecification.class, id); + if (dd == null) { + return this.findByUuid(id);// last resort + } + Hibernate.initialize(dd.getAttachment()); + Hibernate.initialize(dd.getRelatedParty()); + Hibernate.initialize(dd.getFeatureSpecification()); + Hibernate.initialize(dd.getResourceSpecCharacteristic()); + for (ResourceSpecificationCharacteristic schar : dd.getResourceSpecCharacteristic()) { + Hibernate.initialize(schar.getResourceSpecCharacteristicValue()); + Hibernate.initialize(schar.getResourceSpecCharRelationship()); + + } + Hibernate.initialize(dd.getResourceSpecRelationship()); + + tx.commit(); + } finally { + session.close(); + } + return dd; + + } catch (Exception e) { + e.printStackTrace(); + } + + session.close(); + return null; + + + } + + @Transactional + public ResourceSpecification findByNameAndCategoryEager(String aname, String acategory) { + + List optionalCat = this.resourceSpecificationRepo.findByNameAndCategory(aname, acategory); + + if ( optionalCat.size() >0 ) { + return findByUuidEager( optionalCat.get(0).getUuid() ); + } + + return null; + } + + @Transactional + public ResourceSpecification findByNameAndCategoryAndVersionEager(String aname, String acategory, String aversion) { + + List optionalCat = this.resourceSpecificationRepo.findByNameAndCategoryAndVersion(aname, acategory, aversion); + + if ( optionalCat.size() >0 ) { + return findByUuidEager( optionalCat.get(0).getUuid() ); + } + + return null; + } + + + @Transactional + public ResourceSpecification addOrupdateResourceSpecificationByNameCategoryVersion(String aname, String acategory, String aversion, ResourceSpecificationCreate aesourceCreate) { + + List rspecs = this.resourceSpecificationRepo.findByNameAndCategoryAndVersion(aname, acategory, aversion); + ResourceSpecification result = null; + + + if ( rspecs.size() >0 ) { + //perform update to the first one + String resID = rspecs.get(0).getUuid(); + result = this.updateResourceSpecification(resID, aesourceCreate); + } else { + result = this.addResourceSpecification(aesourceCreate); + } + + 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; + } + + + public Void deleteByUuid(String id) { + Optional optionalCat = this.resourceSpecificationRepo.findByUuid(id); + ResourceSpecification s = optionalCat.get(); + if (s == null) { + return null; + } + + this.resCandidateRepoService.deleteById( s.getResourceCandidateObjId() ); + + this.resourceSpecificationRepo.delete( s ); + return null; + } + + + public ResourceSpecification updateResourceSpecification(String id, + @Valid ResourceSpecificationUpdate serviceResourceSpecification) { + + Optional s = this.resourceSpecificationRepo.findByUuid(id); + if ( s.get() == null ) { + return null; + } + ResourceSpecification resourceSpec = s.get(); + resourceSpec = this.updateResourceSpecDataFromAPIcall(resourceSpec, serviceResourceSpecification); + + resourceSpec = this.resourceSpecificationRepo.save( resourceSpec ); + resourceSpec.fixResourceCharRelationhsipIDs(); + resourceSpec = this.resourceSpecificationRepo.save( resourceSpec ); + + + //save the equivalent candidate + ResourceCandidate resCandidateObj = resCandidateRepoService.findById( resourceSpec.getResourceCandidateObjId() ); + if ( resCandidateObj!=null) { + ResourceCandidateUpdate resCandidateUpd = new ResourceCandidateUpdate(); + resCandidateUpd.setName( resourceSpec.getName() ); + resCandidateUpd.setDescription( resourceSpec.getDescription() ); + resCandidateUpd.setLifecycleStatus( resourceSpec.getLifecycleStatus() ); + resCandidateUpd.setVersion( resourceSpec.getVersion() ); + resCandidateRepoService.updateCandidate( resCandidateObj.getId(), resCandidateUpd); + } else { + ResourceCandidateCreate rCandidate = new ResourceCandidateCreate(); + ResourceSpecificationRef rSpecRef = new ResourceSpecificationRef(); + rCandidate.setResourceSpecification(rSpecRef); + rSpecRef.setId( resourceSpec.getId()); + resCandidateObj = resCandidateRepoService.addResourceCandidate(rCandidate); + resourceSpec.setResourceCandidateObjId(resCandidateObj.getUuid()); + } + + + return this.resourceSpecificationRepo.save( resourceSpec ); + + } + + public LogicalResourceSpecification updateLogicalResourceSpecSpecification(String id, + @Valid ResourceSpecificationUpdate logicalResourceSpec) { + return (LogicalResourceSpecification) this.updateResourceSpecification(id, logicalResourceSpec); + } + + public PhysicalResourceSpecification updatePhysicalResourceSpecSpecification(String id, + @Valid ResourceSpecificationUpdate physicalResourceSpec) { + return (PhysicalResourceSpecification) this.updateResourceSpecification(id, physicalResourceSpec); + } + + + + private ResourceSpecification updateResourceSpecDataFromAPIcall( + ResourceSpecification resourceSpec, + ResourceSpecificationUpdate resSpecUpd ) + { + if ( resSpecUpd.getName()!=null ) { + resourceSpec.setName(resSpecUpd.getName()); + } + + if ( resSpecUpd.getDescription()!= null ) { + resourceSpec.setDescription( resSpecUpd.getDescription() ); + } + if ( resSpecUpd.isIsBundle() != null ) { + resourceSpec.setIsBundle( resSpecUpd.isIsBundle() ); + } + if ( resSpecUpd.getCategory()!= null ) { + resourceSpec.setCategory( resSpecUpd.getCategory() ); + } + + resourceSpec.setLastUpdate( OffsetDateTime.now(ZoneOffset.UTC) ); + + if (resourceSpec instanceof PhysicalResourceSpecification){ + ((PhysicalResourceSpecification) resourceSpec) + .model(( (PhysicalResourceSpecificationUpdate) resSpecUpd ).getModel() ) + .part( ( (PhysicalResourceSpecificationUpdate) resSpecUpd ).getPart()) + .sku( ( (PhysicalResourceSpecificationUpdate) resSpecUpd ).getSku()) + .vendor(( (PhysicalResourceSpecificationUpdate) resSpecUpd ).getVendor() ); + } + + + if ( resSpecUpd.getLifecycleStatus() != null ) { + resourceSpec.setLifecycleStatusEnum ( ELifecycle.getEnum( resSpecUpd.getLifecycleStatus() ) ); + } + if ( resSpecUpd.getVersion() != null ) { + resourceSpec.setVersion( resSpecUpd.getVersion()); + } + + + /** + * Update Attachment list + */ + if (resSpecUpd.getAttachment() != null ){ + //reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (AttachmentRefOrValue ar : resSpecUpd.getAttachment()) { + //find attachmet by id and reload it here. + //we need the attachment model from resource spec models + boolean idexists = false; + for (AttachmentRefOrValue orinalAtt : resourceSpec.getAttachment()) { + if ( orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put( orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + resourceSpec.getAttachment().add(ar); + idAddedUpdated.put( ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (AttachmentRefOrValue ss : resourceSpec.getAttachment()) { + if ( idAddedUpdated.get( ss.getId() ) == null ) { + toRemove.add(ss); + } + } + + for (AttachmentRefOrValue ar : toRemove) { + resourceSpec.getAttachment().remove(ar); + } + + + + } + + + + /** + * Update ResourceSpecificationCharacteristic list + * We need to compare by name, since IDs will not exist + */ + if (resSpecUpd.getResourceSpecificationCharacteristic() != null ){ + //reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (ResourceSpecificationCharacteristic charUpd : resSpecUpd.getResourceSpecificationCharacteristic()) { + + boolean nameExists = false; + for (ResourceSpecificationCharacteristic originalSpecChar : resourceSpec.getResourceSpecCharacteristic()) { + if ( originalSpecChar.getName()!=null && charUpd.getName()!=null && originalSpecChar.getName().equals(charUpd.getName())) { + nameExists = true; + idAddedUpdated.put( originalSpecChar.getName(), true); + originalSpecChar.updateWith( charUpd ); + break; + } + } + + if (!nameExists) { + resourceSpec.getResourceSpecCharacteristic().add( new ResourceSpecificationCharacteristic( charUpd )); + if ( charUpd.getName() == null ) { + charUpd.setName( UUID.randomUUID().toString() ); + } + idAddedUpdated.put( charUpd.getName(), true); + } + + } + + List toRemove = new ArrayList<>(); + for (ResourceSpecificationCharacteristic ss : resourceSpec.getResourceSpecCharacteristic()) { + if ( idAddedUpdated.get( ss.getName() ) == null ) { + toRemove.add(ss); + } + } + + for (ResourceSpecificationCharacteristic pecCharacteristic : toRemove) { + resourceSpec.getResourceSpecCharacteristic().remove(pecCharacteristic); + } + + + } + + + /** + * Update ResourceSpecRelationship list + */ + + if (resSpecUpd.getResourceSpecificationRelationship() != null ){ + resourceSpec.getResourceSpecRelationship().clear(); + resourceSpec.getResourceSpecRelationship().addAll( resSpecUpd.getResourceSpecificationRelationship() ); + } + + /** + * Update RelatedParty list + */ + if (resSpecUpd.getRelatedParty() != null ){ + resourceSpec.getRelatedParty().clear(); + resourceSpec.getRelatedParty().addAll( resSpecUpd.getRelatedParty() ); + } + + + + + TimePeriod tp = new TimePeriod(); + if ( resSpecUpd.getValidFor() != null ){ + tp.setStartDateTime( resSpecUpd.getValidFor().getStartDateTime() ); + tp.setEndDateTime( resSpecUpd.getValidFor().getEndDateTime() ); + } + resourceSpec.setValidFor( tp ); + + return resourceSpec; + } + + public ResourceSpecification initRepo() { + + ResourceSpecificationCreate spec = new ResourceSpecificationCreate(); + spec.setName("Example Logical Resource"); + spec.setVersion("1.0.0"); + + return this.addLogicalResourceSpecification(spec); + } + + /** + * @param id + * @param attachment + * @param afile + * @return + */ + public ResourceSpecification addAttachmentToResourceSpec(String id, + @Valid MultipartFile afile, + String urlpath) { + Optional s = this.resourceSpecificationRepo.findByUuid(id); + if ( s.get() == null ) { + return null; + } + + + + ResourceSpecification spec = s.get(); + Attachment att = new Attachment(); + att = this.attachmentRepoService.addAttachment(att); + att.setMimeType(afile.getContentType()); + + String tempDir = METADATADIR + spec.getId() + "/attachments/" + att.getId() + File.separator; + + + try { + Files.createDirectories(Paths.get(tempDir)); + String aFileNamePosted = afile.getOriginalFilename() ;// AttachmentUtil.getFileName(image.getHeaders()); + logger.info("aFileNamePosted = " + aFileNamePosted); + // If there is an icon name + if (!aFileNamePosted.equals("")) { + // Save the icon File + String targetfile = AttachmentUtil.saveFile(afile, tempDir + aFileNamePosted); + logger.info("afile saved to = " + targetfile); + att.setContent(targetfile); + att.setMimeType( afile.getContentType() ); + att.setName(aFileNamePosted); + // Save the file destination + urlpath = urlpath.replace("tmf-api/", ""); + +// if ( spec instanceof LogicalResourceSpecification ) { +// att.setUrl( urlpath + "/logicalResourceSpec/" + spec.getId() + "/attachment/" + att.getId() + "/"+ aFileNamePosted); +// }if ( spec instanceof PhysicalResourceSpecification ) { +// att.setUrl( urlpath + "/physicalResourceSpec/" + spec.getId() + "/attachment/" + att.getId() + "/"+ aFileNamePosted); +// }else { +// att.setUrl( urlpath + "/resourceSpecification/" + spec.getId() + "/attachment/" + att.getId() + "/"+ aFileNamePosted); +// } + + att.setUrl( urlpath + "/" + att.getId() + "/" + + aFileNamePosted); + + + att = this.attachmentRepoService.updateAttachment( att ); + } + } catch (IOException e) { + e.printStackTrace(); + return null; + } + + + AttachmentRefOrValue attref = new AttachmentRefOrValue(); + attref.setId(att.getId()); + attref.setDescription(att.getDescription()); + attref.setUrl(att.getUrl()); + attref.setName(att.getName()); + + spec.addAttachmentItem(attref); + this.resourceSpecificationRepo.save(spec); + return spec; + } + + public Attachment getAttachmentLogo(String id, String attid) { + ResourceSpecification spec = this.findByUuid( id ); + for (AttachmentRefOrValue att : spec.getAttachment()) { + if ( att.getName().contains("logo")) { + return this.attachmentRepoService.findByUuid( att.getId() ); + } + } + + return null; + } + + public Attachment getAttachment(String attid) { + return this.attachmentRepoService.findByUuid( attid ); + } + + + private PhysicalResourceSpecificationCreate readFromLocalPhysicalResourceSpec(String rname) { + PhysicalResourceSpecificationCreate rc; + try { + + rc = objectMapper.readValue(new ClassPathResource( "/resourceSpecifications/"+rname ).getInputStream(), PhysicalResourceSpecificationCreate.class); + + return rc; + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } + + public ResourceSpecificationCreate readFromLocalLogicalResourceSpec(String rname) { + ResourceSpecificationCreate rc; + try { + + rc = objectMapper.readValue(new ClassPathResource( "/resourceSpecifications/"+rname ).getInputStream(), ResourceSpecificationCreate.class); + + return rc; + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } + + + public ResourceSpecification clonePhysicalResourceSpec() { + return this.clonePhysicalResourceSpec(null); + } + + + public ResourceSpecification clonePhysicalResourceSpec(String specName) { + + ResourceSpecification resourceSpecificationObj = clonePhysicalResourceSpec( specName , "testResourceSpec.json" ); + return resourceSpecificationObj; + } + + public ResourceSpecification clonePhysicalResourceSpec(String specName, String fileName) { + + PhysicalResourceSpecificationCreate resourceSpecificationObj = readFromLocalPhysicalResourceSpec( fileName ); + resourceSpecificationObj.setName(specName); + ResourceSpecification rSpec = this.addPhysicalResourceSpecification(resourceSpecificationObj); + return rSpec; + } + + public ResourceSpecification cloneLogicalResourceSpec() { + return this.cloneLogicalResourceSpec(null); + } + + + public ResourceSpecification cloneLogicalResourceSpec(String specName) { + ResourceSpecification resourceSpecificationObj = cloneLogicalResourceSpec(specName, "testResourceSpec.json"); + return resourceSpecificationObj; + } + + public ResourceSpecification cloneLogicalResourceSpec(String specName, String fileName) { + + ResourceSpecificationCreate resourceSpecificationObj = readFromLocalLogicalResourceSpec( fileName ); + resourceSpecificationObj.setName(specName); + ResourceSpecification rSpec = this.addLogicalResourceSpecification(resourceSpecificationObj); + return rSpec; + } + + public ResourceSpecification findByNameAndVersion(String aname, String aversion) { + + List optionalCat = this.resourceSpecificationRepo.findByNameAndVersion(aname, + aversion); + if ( ( optionalCat !=null) && ( optionalCat.size()>0) ) { + return optionalCat.get(0); + } else { + return null; + } + } + + public ResourceSpecification findByName(String aname) { + List optionalCat = this.resourceSpecificationRepo.findByName(aname); + if ( ( optionalCat !=null) && ( optionalCat.size()>0) ) { + return optionalCat.get(0); + } else { + return null; + } + } + + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/ri639/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..2159957039e587bdcfe406c00d5d6b4103788f76 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ApiException.java @@ -0,0 +1,10 @@ +package org.etsi.osl.tmf.ri639.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-07-08T09:52:18.013684600+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/ri639/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..942f2f0919dbdc45841d4946993874d6530181ad --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ApiOriginFilter.java @@ -0,0 +1,31 @@ +package org.etsi.osl.tmf.ri639.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 = "2021-07-08T09:52:18.013684600+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/ri639/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..47a946a859828745f71a46eb50c44f0c6b887289 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +package org.etsi.osl.tmf.ri639.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-07-08T09:52:18.013684600+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/ri639/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/ri639/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..f9d01b06f8d84ab7f37feafdfd2acd339a3de07a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/HubApi.java @@ -0,0 +1,100 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.ri639.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.ri639.model.EventSubscription; +import org.etsi.osl.tmf.ri639.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-07-08T09:52:18.013684600+03:00[Europe/Athens]") +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ri639/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/ri639/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..d2762656bf42780e00c19bd395eddaf072912561 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/HubApiController.java @@ -0,0 +1,37 @@ +package org.etsi.osl.tmf.ri639.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-07-08T09:52:18.013684600+03:00[Europe/Athens]") + +@Controller("HubApiController639") +@RequestMapping("/resourceInventoryManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ri639/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..f94ce1100a91b31468cfe8e1e3d52d44bc4ab49d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ListenerApi.java @@ -0,0 +1,176 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.ri639.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.ri639.model.EventSubscription; +import org.etsi.osl.tmf.ri639.model.ResourceAttributeValueChangeEvent; +import org.etsi.osl.tmf.ri639.model.ResourceCreateEvent; +import org.etsi.osl.tmf.ri639.model.ResourceDeleteEvent; +import org.etsi.osl.tmf.ri639.model.ResourceStateChangeEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-07-08T09:52:18.013684600+03:00[Europe/Athens]") +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity ResourceAttributeValueChangeEvent", operationId = "listenToResourceAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification ResourceAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceAttributeValueChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceCreateEvent", operationId = "listenToResourceCreateEvent", description = "Example of a client listener for receiving the notification ResourceCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceDeleteEvent", operationId = "listenToResourceDeleteEvent", description = "Example of a client listener for receiving the notification ResourceDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceStateChangeEvent", operationId = "listenToResourceStateChangeEvent", description = "Example of a client listener for receiving the notification ResourceStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ri639/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..209fda8490b75ebeb00cfd5edb7055f2736655c6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ListenerApiController.java @@ -0,0 +1,34 @@ +package org.etsi.osl.tmf.ri639.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-07-08T09:52:18.013684600+03:00[Europe/Athens]") +@Controller +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ri639/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/ri639/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..0a2e14ab59645b8f2a4cf0b2af9ff593bf742896 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/NotFoundException.java @@ -0,0 +1,10 @@ +package org.etsi.osl.tmf.ri639.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-07-08T09:52:18.013684600+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/ri639/api/ResourceApi.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApi.java new file mode 100644 index 0000000000000000000000000000000000000000..36c9a4653a3d7f0b469c3e696f72d51794ad0905 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApi.java @@ -0,0 +1,207 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.ri639.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-07-08T09:52:18.013684600+03:00[Europe/Athens]") +@Tag(name = "resource", description = "the resource API") +public interface ResourceApi { + + Logger log = LoggerFactory.getLogger(ResourceApi.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("{\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}", 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 ResourceApi 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()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find Resource objects", operationId = "listResource", description = "This operation list or find 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("[ {\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}, {\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} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ResourceApi 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("{\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}", 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 ResourceApi 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("{\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}", 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 ResourceApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiController.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..81c07b5e9488097a7628596fd374b3a6961848ba --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiController.java @@ -0,0 +1,128 @@ +package org.etsi.osl.tmf.ri639.api; + +import java.security.Principal; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.ri639.model.Resource; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceUpdate; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.etsi.osl.tmf.util.AddUserAsOwnerToRelatedParties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import org.etsi.osl.model.nfv.UserRoleType; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-07-08T09:52:18.013684600+03:00[Europe/Athens]") +@Controller +@RequestMapping("/resourceInventoryManagement/v4/") +public class ResourceApiController implements ResourceApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + + @Autowired + ResourceRepoService resourceRepoService; + + @org.springframework.beans.factory.annotation.Autowired + public ResourceApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + + + @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 c = resourceRepoService.addResource(resource); + + return new ResponseEntity(c, HttpStatus.OK); + } else { + + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity deleteResource(String id) { + try { + + 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); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity> listResource(Principal principal, @Valid String fields, @Valid Integer offset, + @Valid Integer limit, + Map allParams) { + try { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + + + + if ( authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) ) ) { + return new ResponseEntity>( resourceRepoService.findAll( fields, allParams), HttpStatus.OK); + + }else { + return new ResponseEntity>( resourceRepoService.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); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity patchResource(Principal principal, @Valid ResourceUpdate resource, String id) { + Resource c = resourceRepoService.updateResource(id, resource, true); + + return new ResponseEntity< Resource >(c, HttpStatus.OK); + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity retrieveResource(Principal principal, String id, @Valid String fields) { + try { + + 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/ri639/api/ResourceApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..fc6252fb05e6d79fbf958ccdbd8348d8fa1114b9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiRouteBuilder.java @@ -0,0 +1,122 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.ri639.api; + +import java.io.IOException; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.camel.LoggingLevel; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.dataformat.JsonLibrary; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceUpdate; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Configuration +//@RefreshScope +@Component +public class ResourceApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ResourceApiRouteBuilder.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 = ""; + + + + @Value("${CATALOG_RESOURCES_OF_PARTNERS}") + private String CATALOG_RESOURCES_OF_PARTNERS = ""; + + + @Autowired + private ProducerTemplate template; + + @Autowired + ResourceRepoService 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_GET_RESOURCE_BY_ID ) + .log(LoggingLevel.INFO, 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!") + .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!") + .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!") + .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/ri639/api/ResourceApiRouteBuilderEvents.java b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiRouteBuilderEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..df57d1f2d01fd2425780e2fe192ce8f28e741af1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/api/ResourceApiRouteBuilderEvents.java @@ -0,0 +1,109 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.ri639.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 ResourceApiRouteBuilderEvents extends RouteBuilder { + + private static final transient Log logger = + LogFactory.getLog(ResourceApiRouteBuilderEvents.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/ri639/repo/ResourceRepository.java b/src/main/java/org/etsi/osl/tmf/ri639/repo/ResourceRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..86de40b616595331c3252e07f46fd6035fa73c08 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/repo/ResourceRepository.java @@ -0,0 +1,60 @@ +/*- + * ========================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.ri639.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 +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/ri639/reposervices/ResourceRepoService.java b/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..9e79d472e5903d40fea50714d745f4762057ae2b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ri639/reposervices/ResourceRepoService.java @@ -0,0 +1,598 @@ +/*- + * ========================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.ri639.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.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.ri639.api.ResourceApiRouteBuilderEvents; +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.ri639.repo.ResourceRepository; +import org.etsi.osl.tmf.sim638.model.Service; +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; + + + +@org.springframework.stereotype.Service +public class ResourceRepoService { + + private static final transient Log logger = + LogFactory.getLog(ResourceRepoService.class.getName()); + + @Autowired + ObjectMapper objectMapper; + + @Autowired + ResourceRepository resourceRepo; + + @Autowired + ResourceSpecificationRepoService resourceSpecRepoService; + + private SessionFactory sessionFactory; + + @Autowired + ResourceApiRouteBuilderEvents resourceApiRouteBuilder; + + @Autowired + public ResourceRepoService(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.resourceRepo.findAll(); + } + + public List findAll(@Valid String fields, Map allParams) + throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + + try { + String sql = "SELECT " + "srv.uuid as uuid," + "srv.startOperatingDate as startOperatingDate," + + "srv.name as name," + "srv.category as category," + + "srv.resourceStatus as resourceStatus," + "srv.type as type"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", srv." + f + " as " + f; + } + + } + // sql += " FROM RIResource RILogicalRes RIPhysicalRes srv "; + sql += " FROM RIResource srv "; + + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + + sql += " ORDER BY srv.startOperatingDate DESC"; + + List mapaEntity = + session.createQuery(sql).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 rpList = (ArrayList) 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 name, UserPartRoleType requester) { + + return (List) this.resourceRepo.findByRolename(name); + } + + + 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()); + // resCreate.setResourceSpecification( thespecRef ); + 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; + } + + + + @Transactional + public Resource findByUuid(String id) { + Optional optionalCat = this.resourceRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + @Transactional + public Resource updateResource(String id, @Valid ResourceUpdate resourceUpd, + boolean triggerServiceActionQueue) { + Resource resource = this.getResourceEager(id); + + if (resource == null) { + + logger.error("Resource cannot be found in registry, UUID: " + id); + return null; + } + + logger.info("Will update Resource: " + resource.getName()); + // logger.info("Will update service details: " + s.toString() ); + + // ObjectMapper mapper = new ObjectMapper(); + // String originaServiceAsJson = null; + // try { + // originaServiceAsJson = mapper.writeValueAsString( resource ); + // } catch (JsonProcessingException e) { + // logger.error("cannot umarshall service: " + resource.getName() ); + // e.printStackTrace(); + // } + + + if (resourceUpd.getResourceRelationship() != null) { + // resource.getResourceRelationship().addAll( resourceUpd.getResourceRelationship() ); + // new LinkedHashSet( list ) + 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()); + } + + + /** + * the following need to be modified for deleting items from lists. + */ + + 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( "RI639-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( "RI639-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; + } + + public String getResourceEagerAsString(String id) throws JsonProcessingException { + Resource s = this.getResourceEager(id); + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new Hibernate5JakartaModule()); + String res = mapper.writeValueAsString(s); + + return res; + } + + public Resource getResourceEager(String id) { + 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);// last resort + } + + 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; + } + + + @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()); + + } + + @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()); + + } + + + + @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()); + + } + + @Transactional + public List findAllActiveResourcesToTerminate() { + + List result = new ArrayList<>(); + List resourcs = this.resourceRepo.findActiveToTerminate(); + for (Resource r : resourcs) { + result.add(r.getId()); + } + + return result; + } + + /** + * @return UUIDs of Services and put them in a List + */ + @Transactional + public List findAllActiveAndReservedResourcesOfPartners() { + + List result = new ArrayList<>(); + List srvs = this.resourceRepo.findActiveAndReservedResourcesOfPartners(); + for (Resource r : srvs) { + result.add(r.getId()); + } + + return result; + } + + public Void deleteByUuid(String id) { + Optional optionalCat = this.resourceRepo.findByUuid(id); + Resource s = optionalCat.get(); + if (s == null) { + return null; + } + + + this.resourceRepo.delete(s); + return null; + } + + + @Transactional + public Resource addOrUpdateResourceByNameCategoryVersion(String aName, String aCategory, + String aVersion, ResourceCreate aesourceCreate) { + + 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, aesourceCreate, false); + + + + } else { + result = this.addResource(aesourceCreate); + } + + 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/ro652/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/ro652/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..332f73597018f9dbe1f2ba8e765b42fa676c8eba --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/ApiException.java @@ -0,0 +1,10 @@ +package org.etsi.osl.tmf.ro652.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+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/ro652/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/ro652/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..a368e1d544c6f634795621e6ea90c0f74f2399b9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/ApiOriginFilter.java @@ -0,0 +1,31 @@ +package org.etsi.osl.tmf.ro652.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 = "2022-09-28T23:39:08.914219800+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/ro652/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/ro652/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..b3279a63d5b440dc8f0631eff2e772ab089ca47e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +package org.etsi.osl.tmf.ro652.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+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/ro652/api/CancelResourceOrderApi.java b/src/main/java/org/etsi/osl/tmf/ro652/api/CancelResourceOrderApi.java new file mode 100644 index 0000000000000000000000000000000000000000..876396c8b87bd1449db43d29d5e193b32c74a6f2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/CancelResourceOrderApi.java @@ -0,0 +1,144 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.ro652.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.ro652.model.CancelResourceOrder; +import org.etsi.osl.tmf.ro652.model.CancelResourceOrderCreate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+03:00[Europe/Athens]") +@Tag(name = "cancelResourceOrder", description = "the cancelResourceOrder API") +public interface CancelResourceOrderApi { + + Logger log = LoggerFactory.getLogger(CancelResourceOrderApi.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 CancelResourceOrder", operationId = "createCancelResourceOrder", description = "This operation creates a CancelResourceOrder entity.", tags={ "cancelResourceOrder", }) + @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 = "/cancelResourceOrder", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createCancelResourceOrder(@Parameter(description = "The CancelResourceOrder to be created" ,required=true ) @Valid @RequestBody CancelResourceOrderCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"requestedCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"resourceOrder\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"cancellationReason\" : \"cancellationReason\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"effectiveCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", CancelResourceOrder.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 CancelResourceOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find CancelResourceOrder objects", operationId = "listCancelResourceOrder", description = "This operation list or find CancelResourceOrder entities" , tags={ "cancelResourceOrder", }) + @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 = "/cancelResourceOrder", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listCancelResourceOrder(@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"requestedCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"resourceOrder\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"cancellationReason\" : \"cancellationReason\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"effectiveCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}, {\r\n \"requestedCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"resourceOrder\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"cancellationReason\" : \"cancellationReason\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"effectiveCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default CancelResourceOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a CancelResourceOrder by ID", operationId = "retrieveCancelResourceOrder", description = "This operation retrieves a CancelResourceOrder entity. Attribute selection is enabled for all first level attributes.", tags={ "cancelResourceOrder", }) + @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 = "/cancelResourceOrder/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveCancelResourceOrder(@Parameter(description = "Identifier of the CancelResourceOrder",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("{\r\n \"requestedCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"resourceOrder\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"cancellationReason\" : \"cancellationReason\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"acknowledged\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"effectiveCancellationDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", CancelResourceOrder.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 CancelResourceOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ro652/api/CancelResourceOrderApiController.java b/src/main/java/org/etsi/osl/tmf/ro652/api/CancelResourceOrderApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..6c01d6b27e025868380919f391a2ce6c52060d63 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/CancelResourceOrderApiController.java @@ -0,0 +1,34 @@ +package org.etsi.osl.tmf.ro652.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+03:00[Europe/Athens]") +@Controller +public class CancelResourceOrderApiController implements CancelResourceOrderApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public CancelResourceOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ro652/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/ro652/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..651ec4d5e390dd015810cae1200c83f33f0a3d78 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/HubApi.java @@ -0,0 +1,100 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.ro652.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.ro652.model.EventSubscription; +import org.etsi.osl.tmf.ro652.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+03:00[Europe/Athens]") +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ro652/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/ro652/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..cbba1379c624bc4c0428f84af194d9fc0cb1ac04 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/HubApiController.java @@ -0,0 +1,37 @@ +package org.etsi.osl.tmf.ro652.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+03:00[Europe/Athens]") + +@Controller("HubApiController652") +@RequestMapping("/resourceOrderingManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ro652/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/ro652/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..f6e1bde15110f335711e7c9e5092075272366eb2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/ListenerApi.java @@ -0,0 +1,308 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.ro652.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.ro652.model.CancelResourceOrderCreateEvent; +import org.etsi.osl.tmf.ro652.model.CancelResourceOrderInformationRequiredEvent; +import org.etsi.osl.tmf.ro652.model.CancelResourceOrderStateChangeEvent; +import org.etsi.osl.tmf.ro652.model.EventSubscription; +import org.etsi.osl.tmf.ro652.model.ResourceOrderAttributeValueChangeEvent; +import org.etsi.osl.tmf.ro652.model.ResourceOrderCreateEvent; +import org.etsi.osl.tmf.ro652.model.ResourceOrderDeleteEvent; +import org.etsi.osl.tmf.ro652.model.ResourceOrderInformationRequiredEvent; +import org.etsi.osl.tmf.ro652.model.ResourceOrderStateChangeEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+03:00[Europe/Athens]") +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity CancelResourceOrderCreateEvent", operationId = "listenToCancelResourceOrderCreateEvent", description = "Example of a client listener for receiving the notification CancelResourceOrderCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/cancelResourceOrderCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCancelResourceOrderCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CancelResourceOrderCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CancelResourceOrderInformationRequiredEvent", operationId = "listenToCancelResourceOrderInformationRequiredEvent", description = "Example of a client listener for receiving the notification CancelResourceOrderInformationRequiredEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/cancelResourceOrderInformationRequiredEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCancelResourceOrderInformationRequiredEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CancelResourceOrderInformationRequiredEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity CancelResourceOrderStateChangeEvent", operationId = "listenToCancelResourceOrderStateChangeEvent", description = "Example of a client listener for receiving the notification CancelResourceOrderStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/cancelResourceOrderStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToCancelResourceOrderStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody CancelResourceOrderStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceOrderAttributeValueChangeEvent", operationId = "listenToResourceOrderAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification ResourceOrderAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceOrderAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceOrderAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceOrderAttributeValueChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceOrderCreateEvent", operationId = "listenToResourceOrderCreateEvent", description = "Example of a client listener for receiving the notification ResourceOrderCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceOrderCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceOrderCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceOrderCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceOrderDeleteEvent", operationId = "listenToResourceOrderDeleteEvent", description = "Example of a client listener for receiving the notification ResourceOrderDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceOrderDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceOrderDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceOrderDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceOrderInformationRequiredEvent", operationId = "listenToResourceOrderInformationRequiredEvent", description = "Example of a client listener for receiving the notification ResourceOrderInformationRequiredEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceOrderInformationRequiredEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceOrderInformationRequiredEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceOrderInformationRequiredEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ResourceOrderStateChangeEvent", operationId = "listenToResourceOrderStateChangeEvent", description = "Example of a client listener for receiving the notification ResourceOrderStateChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/resourceOrderStateChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToResourceOrderStateChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ResourceOrderStateChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ro652/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/ro652/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..6bca170038b915db4a4aad7a676edd8831e61a54 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/ListenerApiController.java @@ -0,0 +1,37 @@ +package org.etsi.osl.tmf.ro652.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+03:00[Europe/Athens]") + +@Controller("ListenerApiController652") +@RequestMapping("/resourceOrderingManagement/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ro652/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/ro652/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..f7e193f2531492c0927a6e0f9f221a257b15165a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/NotFoundException.java @@ -0,0 +1,10 @@ +package org.etsi.osl.tmf.ro652.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+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/ro652/api/ResourceOrderApi.java b/src/main/java/org/etsi/osl/tmf/ro652/api/ResourceOrderApi.java new file mode 100644 index 0000000000000000000000000000000000000000..f871ca5cf01d91636f3e1edeec45c570bbbe241d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/ResourceOrderApi.java @@ -0,0 +1,207 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.ro652.api; + +import java.io.IOException; +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.ro652.model.ResourceOrder; +import org.etsi.osl.tmf.ro652.model.ResourceOrderCreate; +import org.etsi.osl.tmf.ro652.model.ResourceOrderUpdate; +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; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+03:00[Europe/Athens]") +@Tag(name = "resourceOrder", description = "the resourceOrder API") +public interface ResourceOrderApi { + + Logger log = LoggerFactory.getLogger(ResourceOrderApi.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 ResourceOrder", operationId = "createResourceOrder", description = "This operation creates a ResourceOrder entity." , tags = { + "resourceOrder", }) + @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 = "/resourceOrder", produces = { "application/json;charset=utf-8" }, consumes = { + "application/json;charset=utf-8" }, method = RequestMethod.POST) + default ResponseEntity createResourceOrder( + Principal principal, + @Parameter(description = "The ResourceOrder to be created", required = true) @Valid @RequestBody ResourceOrderCreate roCreate) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "{\r\n \"orderType\" : \"orderType\",\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"orderItem\" : [ {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"externalId\" : \"externalId\",\r\n \"priority\" : 0,\r\n \"relatedParty\" : [ null, null ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"externalReference\" : [ {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", + ResourceOrder.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 ResourceOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Deletes a ResourceOrder", operationId = "deleteResourceOrder", description = "This operation deletes a ResourceOrder entity.", tags = { + "resourceOrder", }) + @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 = "/resourceOrder/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.DELETE) + default ResponseEntity deleteResourceOrder( + @Parameter(description = "Identifier of the ResourceOrder", required = true) @PathVariable("id") String id) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ResourceOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "List or find ResourceOrder objects", operationId = "listResourceOrder", description = "This operation list or find ResourceOrder entities" , tags = { + "resourceOrder", }) + @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 = "/resourceOrder", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity> listResourceOrder( + @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) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "[ {\r\n \"orderType\" : \"orderType\",\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"orderItem\" : [ {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"externalId\" : \"externalId\",\r\n \"priority\" : 0,\r\n \"relatedParty\" : [ null, null ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"externalReference\" : [ {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}, {\r\n \"orderType\" : \"orderType\",\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"orderItem\" : [ {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"externalId\" : \"externalId\",\r\n \"priority\" : 0,\r\n \"relatedParty\" : [ null, null ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"externalReference\" : [ {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\"\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); + } + } + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ResourceOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Updates partially a ResourceOrder", operationId = "patchResourceOrder", description = "This operation updates partially a ResourceOrder entity." , tags = { + "resourceOrder", }) + @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 = "/resourceOrder/{id}", produces = { "application/json;charset=utf-8" }, consumes = { + "application/json;charset=utf-8" }, method = RequestMethod.PATCH) + default ResponseEntity patchResourceOrder( + @Parameter(description = "The ResourceOrder to be updated", required = true) @Valid @RequestBody ResourceOrderUpdate body, + @Parameter(description = "Identifier of the ResourceOrder", required = true) @PathVariable("id") String id) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "{\r\n \"orderType\" : \"orderType\",\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"orderItem\" : [ {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"externalId\" : \"externalId\",\r\n \"priority\" : 0,\r\n \"relatedParty\" : [ null, null ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"externalReference\" : [ {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", + ResourceOrder.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 ResourceOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Retrieves a ResourceOrder by ID", operationId = "retrieveResourceOrder", description = "This operation retrieves a ResourceOrder entity. Attribute selection is enabled for all first level attributes." , tags = { + "resourceOrder", }) + @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 = "/resourceOrder/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity retrieveResourceOrder( + @Parameter(description = "Identifier of the ResourceOrder", 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( + "{\r\n \"orderType\" : \"orderType\",\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 \"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 \"text\" : \"text\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"orderItem\" : [ {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"quantity\" : 6,\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 \"resourceSpecification\" : {\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 \"version\" : \"version\"\r\n },\r\n \"description\" : \"description\",\r\n \"resourceCharacteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\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 \"@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 \"@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 \"@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 \"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 \"resourceStatus\" : \"standby\",\r\n \"usageState\" : \"idle\",\r\n \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\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 \"attachmentType\" : \"attachmentType\",\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 \"description\" : \"description\",\r\n \"mimeType\" : \"mimeType\",\r\n \"url\" : \"url\",\r\n \"isRef\" : true,\r\n \"size\" : {\r\n \"amount\" : 1.4658129,\r\n \"units\" : \"units\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\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\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceRelationshipCharacteristic\" : [ null, null ]\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 },\r\n \"@type\" : \"@type\",\r\n \"action\" : \"action\",\r\n \"appointment\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"orderItemRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"orderItem\" : {\r\n \"itemId\" : \"itemId\",\r\n \"resourceOrderHref\" : \"resourceOrderHref\",\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"resourceOrderId\" : \"resourceOrderId\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"externalId\" : \"externalId\",\r\n \"priority\" : 0,\r\n \"relatedParty\" : [ null, null ],\r\n \"requestedStartDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"externalReference\" : [ {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"owner\" : \"owner\",\r\n \"@baseType\" : \"@baseType\",\r\n \"entityType\" : \"entityType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"expectedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"category\" : \"category\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"orderDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"startDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"requestedCompletionDate\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", + ResourceOrder.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 ResourceOrderApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/ro652/api/ResourceOrderApiController.java b/src/main/java/org/etsi/osl/tmf/ro652/api/ResourceOrderApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..3c1c64e1e85b8fd00034d017a1d754863fa3ad73 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/api/ResourceOrderApiController.java @@ -0,0 +1,115 @@ +package org.etsi.osl.tmf.ro652.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.ro652.model.ResourceOrder; +import org.etsi.osl.tmf.ro652.model.ResourceOrderCreate; +import org.etsi.osl.tmf.ro652.reposervices.ResourceOrderRepoService; +import org.etsi.osl.tmf.util.AddUserAsOwnerToRelatedParties; +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.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.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-09-28T23:39:08.914219800+03:00[Europe/Athens]") +@Controller +@RequestMapping("/resourceOrderingManagement/v4/") +public class ResourceOrderApiController implements ResourceOrderApi { + + private static final Logger log = LoggerFactory.getLogger( ResourceOrderApiController.class); + + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + + @Autowired + ResourceOrderRepoService resourceOrderRepoService; + + @org.springframework.beans.factory.annotation.Autowired + public ResourceOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity createResourceOrder(Principal principal, @Valid ResourceOrderCreate roCreate) { + + + 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); + + roCreate.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser( + principal.getName(), + //user.getId()+"", + principal.getName(), + UserPartRoleType.REQUESTER, + extInfo, + roCreate.getRelatedParty())); + } + else if ( principal instanceof UsernamePasswordAuthenticationToken ) { + roCreate.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser( + principal.getName(), + //user.getId()+"", + principal.getName(), + UserPartRoleType.REQUESTER, + extInfo, + roCreate.getRelatedParty())); + } + + + }finally { + + } + + ResourceOrder c = resourceOrderRepoService.addResourceOrder( roCreate ); + + return new ResponseEntity(c, 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/ro652/reposervices/ResourceOrderMapper.java b/src/main/java/org/etsi/osl/tmf/ro652/reposervices/ResourceOrderMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..3a2c562bf01c733c21d4855fca5ac2add14d6ddb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/reposervices/ResourceOrderMapper.java @@ -0,0 +1,16 @@ +package org.etsi.osl.tmf.ro652.reposervices; + +import org.etsi.osl.tmf.ri639.model.Resource; +import org.etsi.osl.tmf.ri639.model.ResourceRefOrValue; +import org.mapstruct.Mapper; +import org.mapstruct.NullValueCheckStrategy; +import org.mapstruct.NullValueMappingStrategy; + +@Mapper( + nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT, + nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS ) +public interface ResourceOrderMapper { + + ResourceRefOrValue fromResource(Resource res); + +} diff --git a/src/main/java/org/etsi/osl/tmf/ro652/reposervices/ResourceOrderRepoService.java b/src/main/java/org/etsi/osl/tmf/ro652/reposervices/ResourceOrderRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..03b2c6cd277b9d220be5acdff6da7c7de8a18f79 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/ro652/reposervices/ResourceOrderRepoService.java @@ -0,0 +1,336 @@ +/*- + * ========================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.ro652.reposervices; + +import java.io.UnsupportedEncodingException; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.common.model.EValueType; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristic; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristicValue; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.ri639.model.Characteristic; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceRefOrValue; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.etsi.osl.tmf.ro652.model.ResourceOrder; +import org.etsi.osl.tmf.ro652.model.ResourceOrderCreate; +import org.etsi.osl.tmf.ro652.model.ResourceOrderItem; +import org.etsi.osl.tmf.ro652.model.ResourceOrderStateType; +import org.etsi.osl.tmf.ro652.model.ResourceOrderUpdate; +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.validation.Valid; + +@Service +public class ResourceOrderRepoService { + + private static final transient Log logger = LogFactory.getLog(ResourceOrderRepoService.class.getName()); + + @Autowired + ObjectMapper objectMapper; + + @Autowired + ResourceSpecificationRepoService resourceSpecRepoService; + + @Autowired + ResourceRepoService resourceRepoService; + + + /** + * + * This findAll is optimized on fields. + * @param fields + * @param allParams + * @return + * @throws UnsupportedEncodingException + */ + @Transactional + public List findAll(@Valid String fields, Map allParams) + throws UnsupportedEncodingException { + + return new ArrayList<>(); + + } + + public List findAll() { + return new ArrayList<>(); + } + + public List findAllParams(Map allParams) { + + return new ArrayList<>(); + + } + + public String findAllParamsJsonOrderIDs(Map allParams) throws JsonProcessingException { + + return "[]"; + } + + public ResourceOrder addResourceOrder(@Valid ResourceOrderCreate rOrderCreate) { + ResourceOrder ro = new ResourceOrder(); + ro.orderDate(OffsetDateTime.now(ZoneOffset.UTC)) + .category(rOrderCreate.getCategory()) + .description(rOrderCreate.getDescription()) + .externalId(rOrderCreate.getExternalId()) + .priority(rOrderCreate.getPriority()) + .requestedCompletionDate(rOrderCreate.getRequestedCompletionDate()) + .requestedStartDate(rOrderCreate.getRequestedStartDate() ) + .startDate( rOrderCreate.getRequestedStartDate() ) + .expectedCompletionDate( rOrderCreate.getRequestedCompletionDate() ); //this is by default + if (rOrderCreate.getNote() != null) { + ro.getNote().addAll(rOrderCreate.getNote()); + } + if (rOrderCreate.getRelatedParty() != null) { + ro.getRelatedParty().addAll(rOrderCreate.getRelatedParty()); + } + + + boolean allAcknowledged = true; + if (rOrderCreate.getOrderItem() != null) { + ro.getOrderItem().addAll(rOrderCreate.getOrderItem()); + for (ResourceOrderItem soi : ro.getOrderItem()) { + //as of 18/8/2021 in service item we do not copy all service spec characteristics. + //The characteristics of the spec, since they are not user configurable will + //be just exist in the service instance + //copySpecCharacteristicsToServiceCharacteristic( soi.getService().getServiceSpecification().getId(), soi.getService().getServiceCharacteristic() ); + + if ( soi.getState()!=null && !soi.getState().equals( ResourceOrderStateType.ACKNOWLEDGED )) { + allAcknowledged = false; + } + + //at this stage we have no ResOrchestrator.. we will do this by simple code + ResourceRefOrValue r = createResource( soi, rOrderCreate.getRelatedParty() ); + soi.resource( r ); + + } + + + + } + + + + +// so = this.serviceOrderRepo.save(so); +// so = this.fixServiceOrderItemsDependencies(so); + + Note noteItem = new Note(); + noteItem.setText("Resource Order " + ResourceOrderStateType.INITIAL); + noteItem.setAuthor("RO652API-addResourceOrder"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + ro.addNoteItem(noteItem); + + return ro; + } + + + + private ResourceRefOrValue createResource(ResourceOrderItem soi, @Valid List list) { + + @Valid + ResourceCreate resCreate = new ResourceCreate(); + var specRef = soi.getResource().getResourceSpecification(); + if ( specRef == null ) { + specRef = soi.getResourceSpecification(); + } + + + var spec = resourceSpecRepoService.findByUuid( specRef.getId() ); + if ( spec == null) { + spec = resourceSpecRepoService.findByName( specRef.getName() ); + if ( spec == null) { + return new ResourceRefOrValue(); + } + } + + if ( soi.getResource().getName() !=null ) { + resCreate.setName( soi.getResource().getName() ); + } else { + resCreate.setName( spec.getName() ); + + } + + + resCreate.setDescription("A Resource called " +resCreate.getName() + " based on resource spec" + spec.getName()); + resCreate.setCategory( spec.getCategory() ); + if ( spec.getType().toLowerCase().contains( "physical" ) ) { + resCreate.setAtType("PhysicalResource"); + } else { + resCreate.setAtType("LogicalResource"); + } + + + ResourceSpecificationRef thespecRef = new ResourceSpecificationRef(); + thespecRef.setId( spec.getId()); + thespecRef.setName( spec.getName() ); + resCreate.setResourceSpecification( thespecRef ); + + + for (ResourceSpecificationCharacteristic c : spec.getResourceSpecCharacteristic()) { + for (Characteristic orderCharacteristic : soi.getResource().getResourceCharacteristic()) { + String specCharacteristicToSearch = c.getName(); + if ( orderCharacteristic.getName().equals( specCharacteristicToSearch )) { //copy only characteristics that are related from the order + resCreate.addResourceCharacteristicItem( addResourceCharacteristicItem(c, orderCharacteristic) ); + break; + } + } + } + + + if ( resCreate.getResourceCharacteristic() == null) { + resCreate.setResourceCharacteristic( new ArrayList<>() ); + } + + copyRemainingSpecCharacteristicsToResourceCharacteristic(spec , resCreate.getResourceCharacteristic() ); //copy to resource the rest of the characteristics that do not exists yet from the above search + + if ( resCreate.getResourceRelationship() == null) { + resCreate.setResourceRelationship( new ArrayList<>() ); + } + resCreate.getResourceRelationship().addAll( soi.getResource().getResourceRelationship() ); + + if ( resCreate.getAttachment() == null) { + resCreate.setAttachment( new ArrayList<>() ); + } + resCreate.getAttachment().addAll( soi.getResource().getAttachment() ); + + var newresource = resourceRepoService.addResource( resCreate ); + + ResourceOrderMapper mapper = Mappers.getMapper(ResourceOrderMapper.class); + var result = mapper.fromResource( newresource ); + return result; + } + + private void copyRemainingSpecCharacteristicsToResourceCharacteristic(ResourceSpecification spec, + @Valid List destResCharacteristic) { + for (ResourceSpecificationCharacteristic sourceCharacteristic : spec.getResourceSpecCharacteristic()) { + if ( sourceCharacteristic.getValueType() != null ) { + boolean charfound = false; + for (Characteristic destchar : destResCharacteristic) { + if ( destchar.getName().equals(sourceCharacteristic.getName())) { + charfound = true; + break; + } + } + + if (!charfound) { + + Characteristic newChar = new Characteristic(); + newChar.setName( sourceCharacteristic.getName() ); + newChar.setValueType( sourceCharacteristic.getValueType() ); + + if ( sourceCharacteristic.getValueType() != null && sourceCharacteristic.getValueType().equals( EValueType.ARRAY.getValue() ) || + sourceCharacteristic.getValueType() != null && sourceCharacteristic.getValueType().equals( EValueType.SET.getValue() ) ) { + String valString = ""; + for (ResourceSpecificationCharacteristicValue specchar : sourceCharacteristic.getResourceSpecCharacteristicValue()) { + if ( ( specchar.isIsDefault()!= null) && specchar.isIsDefault() ) { + if ( !valString.equals("")) { + valString = valString + ","; + } + valString = valString + "{\"value\":\"" + specchar.getValue().getValue() + "\",\"alias\":\"" + specchar.getValue().getAlias() + "\"}"; + } + + } + + newChar.setValue( new Any( "[" + valString + "]", "") ); + + + } else { + for (ResourceSpecificationCharacteristicValue specchar : sourceCharacteristic.getResourceSpecCharacteristicValue()) { + if ( ( specchar.isIsDefault()!= null) && specchar.isIsDefault() ) { + newChar.setValue( new Any( + specchar.getValue().getValue(), + specchar.getValue().getAlias()) ); + break; + }else { + if (specchar.isIsDefault()== null){ + + logger.info("specchar is null value: " + sourceCharacteristic.getName() ); + } + } + + } + } + + //sourceCharacteristic.getServiceSpecCharacteristicValue() + + if ( newChar.getValue() !=null) { + destResCharacteristic.add(newChar ); + } else { + newChar.setValue( new Any( + "", + "") ); + destResCharacteristic.add(newChar ); + } + + } + + } + + + } + + } + + private Characteristic addResourceCharacteristicItem(ResourceSpecificationCharacteristic c, Characteristic orderCharacteristic) { + Characteristic resCharacteristicItem = new Characteristic(); + resCharacteristicItem.setName( c.getName() ); + resCharacteristicItem.setValueType( c.getValueType() ); + + Any val = new Any(); + val.setValue( orderCharacteristic.getValue().getValue() ); + val.setAlias( orderCharacteristic.getValue().getAlias() ); + + resCharacteristicItem.setValue( val ); + + return resCharacteristicItem; + } + + + @Transactional + public ResourceOrder updateResourceOrder(String id, @Valid ResourceOrderUpdate resourceOrderUpd) { + return null; + + } + + + + + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..5972e1ce4d00a6cbe4965901971d46e6abcc5e85 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ApiException.java @@ -0,0 +1,10 @@ +package org.etsi.osl.tmf.rpm685.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+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/rpm685/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..8ab47553d0d8324191c0d540039534b6cc7fb752 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ApiOriginFilter.java @@ -0,0 +1,31 @@ +package org.etsi.osl.tmf.rpm685.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 = "2022-10-05T08:56:49.602231700+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/rpm685/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..6aa0f03f7ddfadc847430499f3795857435753a1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +package org.etsi.osl.tmf.rpm685.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+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/rpm685/api/AvailabilityCheckApi.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/AvailabilityCheckApi.java new file mode 100644 index 0000000000000000000000000000000000000000..6acc47e4ab43bd044032b936190c53ac8dfb2548 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/AvailabilityCheckApi.java @@ -0,0 +1,77 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rpm685.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.AvailabilityCheck; +import org.etsi.osl.tmf.rpm685.model.AvailabilityCheckCreate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Tag(name = "availabilityCheck", description = "the availabilityCheck API") +public interface AvailabilityCheckApi { + + Logger log = LoggerFactory.getLogger(AvailabilityCheckApi.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 'AvailabilityCheck'", operationId = "createAvailabilityCheck", description = "This operation executes task to retrieve available Resource entities or to check resource pool has available Resource capacity.", tags={ "availabilityCheck", }) + @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 = "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 = "/availabilityCheck", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createAvailabilityCheck(@Parameter(description = "The Availability Check to be created" ,required=true ) @Valid @RequestBody AvailabilityCheckCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n}", AvailabilityCheck.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 AvailabilityCheckApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/AvailabilityCheckApiController.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/AvailabilityCheckApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..61647887e5dd5631b77329927f8f6233c185a693 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/AvailabilityCheckApiController.java @@ -0,0 +1,73 @@ +package org.etsi.osl.tmf.rpm685.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.AvailabilityCheck; +import org.etsi.osl.tmf.rpm685.model.AvailabilityCheckCreate; +import org.etsi.osl.tmf.rpm685.reposervices.ResourcePoolRepoService; +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.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Controller("AvailabilityCheckApiController685") +@RequestMapping("/resourcePoolManagement/v1/") +public class AvailabilityCheckApiController implements AvailabilityCheckApi { + + private static final Logger log = LoggerFactory.getLogger(AvailabilityCheckApiController.class); + + + @Autowired + ResourcePoolRepoService resourcePoolRepoService; + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public AvailabilityCheckApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createAvailabilityCheck(@Valid AvailabilityCheckCreate body) { + try { + if (SecurityContextHolder.getContext().getAuthentication() != null) { + + + AvailabilityCheck c = resourcePoolRepoService.availabilityCheck( body ); + + return new ResponseEntity(c, HttpStatus.OK); + } else { + + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + + } 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/rpm685/api/ExtractApi.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ExtractApi.java new file mode 100644 index 0000000000000000000000000000000000000000..12ed506d080f6793ff5903a7f2af9ceb63da36a2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ExtractApi.java @@ -0,0 +1,77 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rpm685.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.ExtractCreate; +import org.etsi.osl.tmf.rpm685.model.ResourcePool; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Tag(name = "extract", description = "the extract API") +public interface ExtractApi { + + Logger log = LoggerFactory.getLogger(ExtractApi.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 an 'Extract' action and modifies a pool", operationId = "createExtract", description = "In this operation, TASK is executed to extract the capacity of the resource from the resource pool to another pool.", tags={ "extract", }) + @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 = "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 = "/extract", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createExtract(@Parameter(description = "The Extract to be performed" ,required=true ) @Valid @RequestBody ExtractCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n}", ResourcePool.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 ExtractApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/ExtractApiController.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ExtractApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..9b3b25b02dcdf2848d4cb25115c0b711e993dae3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ExtractApiController.java @@ -0,0 +1,76 @@ +package org.etsi.osl.tmf.rpm685.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.ExtractCreate; +import org.etsi.osl.tmf.rpm685.model.ResourcePool; +import org.etsi.osl.tmf.rpm685.reposervices.ResourcePoolRepoService; +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.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Controller("ExtractApiController685") +@RequestMapping("/resourcePoolManagement/v1/") +public class ExtractApiController implements ExtractApi { + + private static final Logger log = LoggerFactory.getLogger( ExtractApiController.class ); + + @Autowired + ResourcePoolRepoService resourcePoolRepoService; + + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ExtractApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createExtract(@Valid ExtractCreate body) { + try { + if (SecurityContextHolder.getContext().getAuthentication() != null) { + + + ResourcePool c = resourcePoolRepoService.extract( body ); + if ( c != null ) { + return new ResponseEntity(c, HttpStatus.OK); + } else { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + + } else { + + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + + } 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/rpm685/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..72b8576e109935aa5fd243f4585b5859cbde2d86 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/HubApi.java @@ -0,0 +1,100 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rpm685.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.EventSubscription; +import org.etsi.osl.tmf.rpm685.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..f2cde3e2c1ab8520fea4d2971728e3b2fa71dad8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/HubApiController.java @@ -0,0 +1,36 @@ +package org.etsi.osl.tmf.rpm685.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Controller("HubApiController685") +@RequestMapping("/resourcePoolManagement/v1/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..84e3d9740067d31690dcd46fc48b2c3406c0be78 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/NotFoundException.java @@ -0,0 +1,10 @@ +package org.etsi.osl.tmf.rpm685.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+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/rpm685/api/PushApi.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/PushApi.java new file mode 100644 index 0000000000000000000000000000000000000000..ceb3c2728c69217f3a4fd94f0be745fdeedbd2e8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/PushApi.java @@ -0,0 +1,77 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rpm685.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.PushCreate; +import org.etsi.osl.tmf.rpm685.model.ResourcePool; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Tag(name = "push", description = "the push API") +public interface PushApi { + + Logger log = LoggerFactory.getLogger(PushApi.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 'Push' action and modifies a Pool", operationId = "createPush", description = "This operation runs TASK, which adds the capacity of the new resource to the resource pool.", tags={ "push", }) + @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 = "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 = "/push", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createPush(@Parameter(description = "The Push to be performed" ,required=true ) @Valid @RequestBody PushCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n}", ResourcePool.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 PushApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/PushApiController.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/PushApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..fe6de31d0de99a2bc36a848c94e88f80b5ef33ad --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/PushApiController.java @@ -0,0 +1,76 @@ +package org.etsi.osl.tmf.rpm685.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.PushCreate; +import org.etsi.osl.tmf.rpm685.model.ResourcePool; +import org.etsi.osl.tmf.rpm685.reposervices.ResourcePoolRepoService; +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.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Controller("PushApiController685") +@RequestMapping("/resourcePoolManagement/v1/") +public class PushApiController implements PushApi { + + + private static final Logger log = LoggerFactory.getLogger( PushApiController.class ); + + @Autowired + ResourcePoolRepoService resourcePoolRepoService; + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PushApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createPush(@Valid PushCreate body) { + try { + if (SecurityContextHolder.getContext().getAuthentication() != null) { + + + ResourcePool c = resourcePoolRepoService.push( body ); + if ( c != null ) { + return new ResponseEntity(c, HttpStatus.OK); + } else { + return new ResponseEntity(HttpStatus.NOT_FOUND); + + } + } else { + + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + + } 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/rpm685/api/ReservationApi.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ReservationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..42cdd3287a33c5f183e7d2a8a56b867175d314af --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ReservationApi.java @@ -0,0 +1,204 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rpm685.api; + +import java.io.IOException; +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.Reservation; +import org.etsi.osl.tmf.rpm685.model.ReservationCreate; +import org.etsi.osl.tmf.rpm685.model.ReservationUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Tag(name = "reservation", description = "the reservation API") +public interface ReservationApi { + + Logger log = LoggerFactory.getLogger(ReservationApi.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 'Reservation'", operationId = "createReservation", description = "", tags={ "reservation", }) + @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 = "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 = "/reservation", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createReservation(Principal principal,@Parameter(description = "The Reservation to be created" ,required=true ) @Valid @RequestBody ReservationCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"reservationState\" : \"reservationState\",\r\n \"@type\" : \"@type\",\r\n \"reservationItem\" : [ {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n }, {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n } ],\r\n \"productOfferingRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"bundledProductOffering\" : [ \"{}\", \"{}\" ],\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"description\" : \"description\",\r\n \"requestedPeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"daysOfWeek\" : \"daysOfWeek\"\r\n },\r\n \"relatedParty\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"channelRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"valid_for\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", Reservation.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 ReservationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find 'Reservation' objects", operationId = "listReservation", description = "" , tags={ "reservation", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/reservation", + produces = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> listReservation(Principal principal,@Parameter(description = "Comma separated properties to display 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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"reservationState\" : \"reservationState\",\r\n \"@type\" : \"@type\",\r\n \"reservationItem\" : [ {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n }, {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n } ],\r\n \"productOfferingRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"bundledProductOffering\" : [ \"{}\", \"{}\" ],\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"description\" : \"description\",\r\n \"requestedPeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"daysOfWeek\" : \"daysOfWeek\"\r\n },\r\n \"relatedParty\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"channelRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"valid_for\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}, {\r\n \"reservationState\" : \"reservationState\",\r\n \"@type\" : \"@type\",\r\n \"reservationItem\" : [ {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n }, {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n } ],\r\n \"productOfferingRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"bundledProductOffering\" : [ \"{}\", \"{}\" ],\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"description\" : \"description\",\r\n \"requestedPeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"daysOfWeek\" : \"daysOfWeek\"\r\n },\r\n \"relatedParty\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"channelRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"valid_for\" : \"2000-01-23T04:56:07.000+00:00\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ReservationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a 'Reservation' by Id", operationId = "patchReservation", description = "", tags={ "reservation", }) + @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 = "/reservation/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.PATCH) + default ResponseEntity patchReservation(Principal principal,@Parameter(description = "The Reservation to be updated" ,required=true ) @Valid @RequestBody ReservationUpdate body +,@Parameter(description = "Identifier of the Reservation",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\r\n \"reservationState\" : \"reservationState\",\r\n \"@type\" : \"@type\",\r\n \"reservationItem\" : [ {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n }, {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n } ],\r\n \"productOfferingRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"bundledProductOffering\" : [ \"{}\", \"{}\" ],\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"description\" : \"description\",\r\n \"requestedPeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"daysOfWeek\" : \"daysOfWeek\"\r\n },\r\n \"relatedParty\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"channelRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"valid_for\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}", Reservation.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 ReservationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a 'Reservation' by Id", operationId = "retrieveReservation", description = "" , tags={ "reservation", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/reservation/{id}", + produces = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity< Reservation> retrieveReservation(Principal principal,@Parameter(description = "Identifier of the Reservation",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"reservationState\" : \"reservationState\",\r\n \"@type\" : \"@type\",\r\n \"reservationItem\" : [ {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n }, {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n } ],\r\n \"productOfferingRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"bundledProductOffering\" : [ \"{}\", \"{}\" ],\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"description\" : \"description\",\r\n \"requestedPeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"daysOfWeek\" : \"daysOfWeek\"\r\n },\r\n \"relatedParty\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"channelRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"valid_for\" : \"2000-01-23T04:56:07.000+00:00\"\r\n}, {\r\n \"reservationState\" : \"reservationState\",\r\n \"@type\" : \"@type\",\r\n \"reservationItem\" : [ {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n }, {\r\n \"quantity\" : 0,\r\n \"@baseType\" : \"@baseType\",\r\n \"appliedCapacityAmount\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"resource\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"resourceRelationship\" : [ \"{}\", \"{}\" ],\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"state\" : \"state\",\r\n \"place\" : [ null, null ],\r\n \"type\" : \"type\",\r\n \"relatedParty\" : [ null, null ],\r\n \"characteristic\" : [ \"{}\", \"{}\" ]\r\n } ],\r\n \"@type\" : \"{}\",\r\n \"appliedDemandAmount\" : \"appliedDemandAmount\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"subReservationState\" : \"subReservationState\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourceCapacity\" : {\r\n \"applicableTimePeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"dayOfWeek\" : \"dayOfWeek\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"capacityDemandAmount\" : \"capacityDemandAmount\",\r\n \"place\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"resourcePool\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n }\r\n }\r\n } ],\r\n \"productOfferingRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"bundledProductOffering\" : [ \"{}\", \"{}\" ],\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"description\" : \"description\",\r\n \"requestedPeriod\" : {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"@baseType\" : \"@baseType\",\r\n \"validFor\" : \"validFor\",\r\n \"@type\" : \"@type\",\r\n \"fromToDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"daysOfWeek\" : \"daysOfWeek\"\r\n },\r\n \"relatedParty\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"channelRef\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\"\r\n },\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"valid_for\" : \"2000-01-23T04:56:07.000+00:00\"\r\n} ]", Reservation.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 ReservationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + + @Operation(summary = "Deletes a 'Reservation' by Id", operationId = "deleteReservation", description = "", tags = { + "resourcePool", }) + @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 = "/reservation/{id}", produces = { "application/json" }, method = RequestMethod.DELETE) + default ResponseEntity deleteReservation( + Principal principal, + @Parameter(description = "Identifier of the Reservation", required = true) @PathVariable("id") String id) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ReservationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/ReservationApiController.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ReservationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..88473bfc1035231f88a27d19552df9f3d98e4833 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ReservationApiController.java @@ -0,0 +1,126 @@ +package org.etsi.osl.tmf.rpm685.api; + +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.Reservation; +import org.etsi.osl.tmf.rpm685.model.ReservationCreate; +import org.etsi.osl.tmf.rpm685.model.ReservationUpdate; +import org.etsi.osl.tmf.rpm685.reposervices.ResourceReservationRepoService; +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.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Controller("ReservationApiController685") +@RequestMapping("/resourcePoolManagement/v1/") +public class ReservationApiController implements ReservationApi { + + + private static final Logger log = LoggerFactory.getLogger(ReservationApiController.class); + + @Autowired + ResourceReservationRepoService resourceReservationRepoService; + + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ReservationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createReservation(Principal principal, @Valid ReservationCreate body) { + try { + if (SecurityContextHolder.getContext().getAuthentication() != null) { + + + Reservation c = resourceReservationRepoService.addReservation( body ); + + return new ResponseEntity(c, HttpStatus.OK); + } else { + + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity> listReservation(Principal principal, @Valid String fields, + @Valid Integer offset, @Valid Integer limit) { + try { + return new ResponseEntity>( resourceReservationRepoService.findAll(), 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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity patchReservation(Principal principal, @Valid ReservationUpdate body, String id) { + + Reservation c = resourceReservationRepoService.updateReservation(id, body ); + + // TODO Auto-generated method stub + return new ResponseEntity(c, HttpStatus.OK); + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity retrieveReservation(Principal principal, String id) { + try { + + return new ResponseEntity( resourceReservationRepoService.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 + public ResponseEntity deleteReservation(Principal principal, String id) { + try { + + return new ResponseEntity( resourceReservationRepoService.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); + } + } + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/ReservationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ReservationApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..8289e2f058b05d3fb9aba64e6c9919adf4f6c6ab --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ReservationApiRouteBuilder.java @@ -0,0 +1,59 @@ +package org.etsi.osl.tmf.rpm685.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.rpm685.model.AvailabilityCheckCreate; +import org.etsi.osl.tmf.rpm685.model.ReservationCreate; +import org.etsi.osl.tmf.rpm685.reposervices.ResourcePoolRepoService; +import org.etsi.osl.tmf.rpm685.reposervices.ResourceReservationRepoService; +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 ReservationApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog( ReservationApiRouteBuilder.class.getName()); + + @Autowired + ResourcePoolRepoService resourcePoolRepoService; + + @Autowired + ResourceReservationRepoService resourceReservationRepoService; + + @Value("${RESERVATION_CREATE}") + private String RESERVATION_CREATE = ""; + + @Value("${RESERVATION_AVAILABILITY_CHECK}") + private String RESERVATION_AVAILABILITY_CHECK = ""; + + + @Override + public void configure() throws Exception { + + from( RESERVATION_CREATE ) + .log(LoggingLevel.INFO, log, RESERVATION_CREATE + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ReservationCreate.class, true) + .bean( resourceReservationRepoService, "addReservation(${body})") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + + from( RESERVATION_AVAILABILITY_CHECK ) + .log(LoggingLevel.INFO, log, RESERVATION_AVAILABILITY_CHECK + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, AvailabilityCheckCreate.class, true) + .bean( resourcePoolRepoService, "availabilityCheck(${body} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + } +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/ResourcePoolApi.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ResourcePoolApi.java new file mode 100644 index 0000000000000000000000000000000000000000..1ba85377a2962de34e3deedba04bd3c61a61ae41 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ResourcePoolApi.java @@ -0,0 +1,181 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.rpm685.api; + +import java.io.IOException; +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.ResourcePool; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolCreate; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolUpdate; +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; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Tag(name = "resourcePool", description = "the resourcePool API") +public interface ResourcePoolApi { + + Logger log = LoggerFactory.getLogger(ResourcePoolApi.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 'ResourcePool'", operationId = "createResourcePool", description = "" , tags = { + "resourcePool", }) + @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 = "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 = "/resourcePool", produces = { "application/json" }, consumes = { + "application/json" }, method = RequestMethod.POST) + default ResponseEntity createResourcePool( + Principal principal, + @Parameter(description = "The Resource Pool to be created", required = true) @Valid @RequestBody ResourcePoolCreate body) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "{\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n}", + ResourcePool.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 ResourcePoolApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Deletes a 'ResourcePool' by Id", operationId = "deleteResourcePool", description = "", tags = { + "resourcePool", }) + @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 = "/resourcePool/{id}", produces = { "application/json" }, method = RequestMethod.DELETE) + default ResponseEntity deleteResourcePool( + Principal principal, + @Parameter(description = "Identifier of the Resource Pool", required = true) @PathVariable("id") String id) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ResourcePoolApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Updates partially a 'ResourcePool' by Id", operationId = "patchResourcePool", description = "" , tags = { + "resourcePool", }) + @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 = "/resourcePool/{id}", produces = { "application/json" }, consumes = { + "application/json" }, method = RequestMethod.PATCH) + default ResponseEntity patchResourcePool( + Principal principal, + @Parameter(description = "The Resource Pool to be updated", required = true) @Valid @RequestBody ResourcePoolUpdate body, + @Parameter(description = "Identifier of the Resource Pool", required = true) @PathVariable("id") String id) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "{\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"href\" : \"href\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"@schemaLocation\",\r\n \"relatedParty\" : \"relatedParty\",\r\n \"resourceCollection\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n }, {\r\n \"@referredType\" : \"@referredType\",\r\n \"name\" : \"name\",\r\n \"href\" : \"href\",\r\n \"objectId\" : \"objectId\"\r\n } ]\r\n}", + ResourcePool.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 ResourcePoolApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "List or find ResourcePool objects", operationId = "listResourcePool", description = "This operation list or find ResourcePool entities" , tags = { + "resourcePool", }) + @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 = "/resourcePool", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity> listResourcePool(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) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Retrieves a ResourcePool by ID", operationId = "retrieveResourcePool", description = "This operation retrieves a ResourcePool entity. Attribute selection is enabled for all first level attributes." , tags = { + "resourcePool", }) + @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 = "/resourcePool/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity retrieveResourcePool(Principal principal, + @Parameter(description = "Identifier of the ResourcePool", required = true) @PathVariable("id") String id, + @Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/api/ResourcePoolApiController.java b/src/main/java/org/etsi/osl/tmf/rpm685/api/ResourcePoolApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..cf601573d0fb73e027770440fde213309a52d709 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/api/ResourcePoolApiController.java @@ -0,0 +1,133 @@ +package org.etsi.osl.tmf.rpm685.api; + +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.rpm685.model.ResourcePool; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolCreate; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolUpdate; +import org.etsi.osl.tmf.rpm685.reposervices.ResourcePoolRepoService; +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.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2022-10-05T08:56:49.602231700+03:00[Europe/Athens]") +@Controller("ResourcePoolApiController685") +@RequestMapping("/resourcePoolManagement/v1/") +public class ResourcePoolApiController implements ResourcePoolApi { + + private static final Logger log = LoggerFactory.getLogger(ResourcePoolApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + + @Autowired + ResourcePoolRepoService resourcePoolRepoService; + + @org.springframework.beans.factory.annotation.Autowired + public ResourcePoolApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createResourcePool(Principal principal, @Valid ResourcePoolCreate body) { + try { + if (SecurityContextHolder.getContext().getAuthentication() != null) { + + + ResourcePool c = resourcePoolRepoService.addResourcePool( body ); + + return new ResponseEntity(c, HttpStatus.OK); + } else { + + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity deleteResourcePool( + Principal principal,String id) { + + + try { + + return new ResponseEntity( resourcePoolRepoService.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); + } + + + } + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity patchResourcePool( + Principal principal,@Valid ResourcePoolUpdate body, String id) { + + ResourcePool c = resourcePoolRepoService.updateResourcePool(id, body ); + + // TODO Auto-generated method stub + return new ResponseEntity(c, HttpStatus.OK); + } + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity retrieveResourcePool(Principal principal, String id, @Valid String fields) { + try { + + return new ResponseEntity( resourcePoolRepoService.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); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity> listResourcePool(Principal principal, @Valid String fields, + @Valid Integer offset, @Valid Integer limit) { + try { + return new ResponseEntity>(resourcePoolRepoService.findAll(), 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/rpm685/repo/ResourcePoolRepository.java b/src/main/java/org/etsi/osl/tmf/rpm685/repo/ResourcePoolRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..f3ab1ec6a6ebf2daaedcfa511acdd4203d5fcaaa --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/repo/ResourcePoolRepository.java @@ -0,0 +1,26 @@ +package org.etsi.osl.tmf.rpm685.repo; + +import java.util.Optional; +import java.util.Set; +import org.etsi.osl.tmf.rpm685.model.ResourcePool; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; +import jakarta.validation.constraints.NotNull; + + +@Repository +public interface ResourcePoolRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Optional findByName(String aName); + + @Query("SELECT rp FROM ResourcePool rp " + + "JOIN FETCH rp.capacity cap " + + "JOIN FETCH cap.resources res " + + "WHERE res.id = ?1") + Set findByResourceId(@NotNull String resourceRefId); +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/repo/ResourceReservationRepository.java b/src/main/java/org/etsi/osl/tmf/rpm685/repo/ResourceReservationRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..c86d2f8fa1f21512b00f81f27b52918160427094 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/repo/ResourceReservationRepository.java @@ -0,0 +1,90 @@ +package org.etsi.osl.tmf.rpm685.repo; + +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import org.etsi.osl.tmf.rpm685.model.Reservation; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import jakarta.validation.Valid; + + +/** + * @author ctranoris + * + */ +public interface ResourceReservationRepository extends CrudRepository, PagingAndSortingRepository { + + Optional findByUuid(String id); + + + @Query("SELECT reserv FROM Reservation reserv " + + "JOIN FETCH reserv.reservationItem ri " + + "JOIN FETCH ri.appliedCapacityAmount apcm " + + "JOIN FETCH apcm.resources resrc " + + "JOIN FETCH apcm.resourceCapacityDemand resCapacityDem " + + "JOIN FETCH resCapacityDem.applicableTimePeriod timePeriod " + + "WHERE resrc.id = ?1") + List findAll2(String id); + +// @Query("SELECT reserv FROM Reservation reserv " +// + "JOIN FETCH reserv.reservationItem ri " +// + "JOIN FETCH ri.appliedCapacityAmount apcm " +// + "JOIN FETCH apcm.resources resrc " +// + "JOIN FETCH apcm.resourceCapacityDemand resCapacityDem " +// + "JOIN FETCH resCapacityDem.applicableTimePeriod timePeriod " +// + "WHERE resrc.id = ?1 AND " +// + "timePeriod.fromDateTime<=?2 AND " +// + "timePeriod.endDateTime>=?2") +// Set findResourceReservationsThatIncludeFromDateTime(String resourceId, +// @Valid OffsetDateTime requestedfromDateTime); +// +// @Query("SELECT reserv FROM Reservation reserv " +// + "JOIN FETCH reserv.reservationItem ri " +// + "JOIN FETCH ri.appliedCapacityAmount apcm " +// + "JOIN FETCH apcm.resources resrc " +// + "JOIN FETCH apcm.resourceCapacityDemand resCapacityDem " +// + "JOIN FETCH resCapacityDem.applicableTimePeriod timePeriod " +// + "WHERE resrc.id = ?1 AND " +// + "timePeriod.fromDateTime<=?2 AND " +// + "timePeriod.endDateTime>=?2") +// Set findResourceReservationsThatIncludeEndDateTime(String resourceId, +// @Valid OffsetDateTime requestedendDateTime); +// +// +// @Query("SELECT reserv FROM Reservation reserv " +// + "JOIN FETCH reserv.reservationItem ri " +// + "JOIN FETCH ri.appliedCapacityAmount apcm " +// + "JOIN FETCH apcm.resources resrc " +// + "JOIN FETCH apcm.resourceCapacityDemand resCapacityDem " +// + "JOIN FETCH resCapacityDem.applicableTimePeriod timePeriod " +// + "WHERE resrc.id = ?1 AND " +// + "timePeriod.fromDateTime>=?2 AND timePeriod.endDateTime>=?2 AND " +// + "timePeriod.fromDateTime<=?3 AND timePeriod.endDateTime<=?3 ") +// Set findResourceReservationsThatIncludeDates(String resourceId, +// @Valid OffsetDateTime requestedfromDateTime, +// @Valid OffsetDateTime requestedendDateTime); + + + + @Query("SELECT reserv FROM Reservation reserv " + + "JOIN FETCH reserv.reservationItem ri " + + "JOIN FETCH ri.appliedCapacityAmount apcm " + + "JOIN FETCH apcm.resources resrc " + + "JOIN FETCH apcm.resourceCapacityDemand resCapacityDem " + + "JOIN FETCH resCapacityDem.applicableTimePeriod timePeriod " + + "WHERE resrc.id = ?1 AND (" + + "(timePeriod.fromDateTime<=?2 AND timePeriod.endDateTime>=?2) OR " + + "(timePeriod.fromDateTime<=?3 AND timePeriod.endDateTime>=?3) OR " + + "(timePeriod.fromDateTime>=?2 AND timePeriod.endDateTime>=?2 AND " + + "timePeriod.fromDateTime<=?3 AND timePeriod.endDateTime<=?3) " + + ") ") + Set findResourceReservationsForDates(String resourceId, + @Valid OffsetDateTime requestedfromDateTime, + @Valid OffsetDateTime requestedendDateTime); + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/reposervices/ResourcePoolRepoService.java b/src/main/java/org/etsi/osl/tmf/rpm685/reposervices/ResourcePoolRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..dcaf26a820ada69dd683b0142ee756b6b0541aff --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/reposervices/ResourcePoolRepoService.java @@ -0,0 +1,259 @@ +package org.etsi.osl.tmf.rpm685.reposervices; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.service.ResourceRef; +import org.etsi.osl.tmf.rpm685.model.AvailabilityCheck; +import org.etsi.osl.tmf.rpm685.model.AvailabilityCheckCreate; +import org.etsi.osl.tmf.rpm685.model.ExtractCreate; +import org.etsi.osl.tmf.rpm685.model.PushCreate; +import org.etsi.osl.tmf.rpm685.model.Reservation; +import org.etsi.osl.tmf.rpm685.model.ReservationStateType; +import org.etsi.osl.tmf.rpm685.model.ResourcePool; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolCreate; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolMapper; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolUpdate; +import org.etsi.osl.tmf.rpm685.repo.ResourcePoolRepository; +import org.etsi.osl.tmf.rpm685.repo.ResourceReservationRepository; +import org.mapstruct.factory.Mappers; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; + +/** + * @author ctranoris + * + */ +@org.springframework.stereotype.Service +public class ResourcePoolRepoService { + + private static final transient Log logger = LogFactory.getLog(ResourcePoolRepoService.class.getName()); + + @Autowired + ResourcePoolRepository resourcePoolRepo; + + + @Autowired + ResourceReservationRepository resourceReservationRepository; + + + public ResourcePool addResourcePool(@Valid ResourcePoolCreate body) { + logger.info("Will add Resource Pool: " + body.getName()); + + ResourcePool rp = new ResourcePool(); + ResourcePoolMapper mapper = Mappers.getMapper(ResourcePoolMapper.class); + rp = mapper.fromResourcePoolDTO(body); + + rp = this.resourcePoolRepo.save(rp); + return rp; + } + + @Transactional + public ResourcePool updateResourcePool(String id, @Valid ResourcePoolUpdate body) { + ResourcePool rp = this.findByUuid(id); + + ResourcePoolMapper mapper = Mappers.getMapper(ResourcePoolMapper.class); + rp = mapper.updateResourcePool(rp, body); + rp = this.resourcePoolRepo.save(rp); + return rp; + } + + public ResourcePool findByUuid(String id) { + Optional optionalCat = this.resourcePoolRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + public List findAll() { + return (List) this.resourcePoolRepo.findAll(); + } + + @Transactional + public AvailabilityCheck availabilityCheck(@Valid AvailabilityCheckCreate acReq) { + AvailabilityCheck ac = new AvailabilityCheck(); + if ( acReq.getResourceCapacityDemand() == null ) { + return ac; + } + ResourcePool rp = this.findByUuid( acReq.getResourceCapacityDemand().getResourcePool().getId() ); + if (rp == null) { + ac.setAvailableResources( new ArrayList<>()); + return ac; + } + + //dummy for now return any form the Set + ac.setAvailableResources( new ArrayList<>() ); + + if ( acReq.getResourceCapacityDemand().getResources() != null && acReq.getResourceCapacityDemand().getResources().size()>0) { + for (ResourceRef rRef : acReq.getResourceCapacityDemand().getResources()) { + + Reservation aReservation = reserveResource( rRef.getId(), + acReq.getResourceCapacityDemand().getApplicableTimePeriod().getFromDateTime(), + acReq.getResourceCapacityDemand().getApplicableTimePeriod().getEndDateTime() + ); + if ( aReservation!=null && + aReservation.getReservationState().equals( ReservationStateType.COMPLETED.toString() )) { + ac.getAvailableResources().add( rRef ); + } + } + } else { //search availability of each resource in the pool + + for (ResourceRef rRef : rp.getCapacity().getResources() ) { + + Reservation aReservation = reserveResource( rRef.getId(), + acReq.getResourceCapacityDemand().getApplicableTimePeriod().getFromDateTime(), + acReq.getResourceCapacityDemand().getApplicableTimePeriod().getEndDateTime() + ); + if ( aReservation!=null && + aReservation.getReservationState().equals( ReservationStateType.COMPLETED.toString() )) { + ac.getAvailableResources().add( rRef ); + } + } + + } + + + return ac; + } + + /** + * @param push + * @return + */ + public ResourcePool push(@Valid PushCreate push) { + var resourcePool = findByUuid(push.getResourcePool().getId()); + if (resourcePool == null) { + return null; + } + + ResourcePoolUpdate ru = new ResourcePoolUpdate(); + ru.setCapacity(resourcePool.getCapacity()); + ru.getCapacity() + .setCapacityAmount(ru.getCapacity().getCapacityAmount() + push.getCapacity().getCapacityAmount()); + ru.getCapacity().getResources().addAll(resourcePool.getCapacity().getResources()); + ru.getCapacity().getResources().addAll(push.getCapacity().getResources()); + + return updateResourcePool(resourcePool.getId(), ru); + } + + public ResourcePool extract(@Valid ExtractCreate extr) { + var resourcePool = findByUuid( extr.getResourcePool().getId()); + if (resourcePool == null) { + return null; + } + + ResourcePoolUpdate ru = new ResourcePoolUpdate(); + ru.setCapacity( resourcePool.getCapacity() ); + ru.getCapacity().setCapacityAmount( ru.getCapacity().getCapacityAmount() - extr.getCapacity().getCapacityAmount()); + ru.getCapacity().getResources().addAll( resourcePool.getCapacity().getResources() ); + List toremove = new ArrayList<>(); + for (ResourceRef refExt : extr.getCapacity().getResources()) { + for (ResourceRef refPool : ru.getCapacity().getResources()) { + if ( refExt.getId().equals(refPool.getId() ) ) { + toremove.add(refPool); + } + + } + } + + for (ResourceRef resourceRef : toremove) { + ru.getCapacity().getResources().remove(resourceRef); + } + + + return updateResourcePool(resourcePool.getId(), ru); + } + + @Transactional + public Set findResourceRefinPools(@NotNull String resourceRefId) { + return this.resourcePoolRepo.findByResourceId( resourceRefId ) ; + + } + + public Void deleteByUuid(String id) { + Optional optionalCat = this.resourcePoolRepo.findByUuid(id); + ResourcePool s = optionalCat.get(); + if (s == null) { + return null; + } + + this.resourcePoolRepo.delete( s ); + return null; + } + + /** + * @param resourceId + * @param fromDateTime + * @param endDateTime + * @return a nre reservation if it is OK with dates otherwise returns one that is rejected + */ + @Transactional + public Reservation reserveResource(@NotNull String resourceId, @Valid OffsetDateTime fromDateTime, + @Valid OffsetDateTime endDateTime) { + + //find any reservations of that resource in the specific period + //we must not find any reservation that its fromDateTime is between requestedFromDateTime and requested EndDateTime + //we must not find any reservation that its endDateTime is is between requestedFromDateTime and requested EndDateTime + //find any reservations that include the fromDateTime + + + + List result1 = this.findAllReservations(); + List result11 = this.resourceReservationRepository.findAll2( resourceId ); +// Set result2 = this.resourceReservationRepository +// .findResourceReservationsThatIncludeFromDateTime(resourceId, fromDateTime); +// Set result3 = this.resourceReservationRepository +// .findResourceReservationsThatIncludeEndDateTime(resourceId, endDateTime); +// Set result4 = this.resourceReservationRepository +// .findResourceReservationsThatIncludeDates(resourceId, fromDateTime, endDateTime); +// Set result5 = this.resourceReservationRepository +// .findResourceReservationsThatIncludeDates(resourceId, fromDateTime, endDateTime); + Set result = this.resourceReservationRepository + .findResourceReservationsForDates(resourceId, fromDateTime, endDateTime); + + logger.info("reqFrom %s, reqEnd %s".formatted(fromDateTime, endDateTime)); +// if ( result1.size() >0 ) { +// @Valid +// ApplicableTimePeriod period = result1.stream().findFirst().get() +// .getReservationItem().stream().findFirst(). get() +// .getAppliedCapacityAmount().getResourceCapacityDemand().getApplicableTimePeriod(); +// +// logger.info("reservationFROM %s, reservationEND %s".formatted( +// period.getFromDateTime() , +// period.getEndDateTime())); +// } + + logger.info("result1 %s".formatted(result1.size())); + logger.info("result11 %s".formatted(result11.size())); +// logger.info("result2 %s".formatted(result2.size())); +// logger.info("result3 %s".formatted(result3.size())); +// logger.info("result4 %s".formatted(result4.size())); +// logger.info("result5 %s".formatted(result5.size())); + logger.info("result %s".formatted(result.size())); + + + //if result is 0 then create a new reservation for that specific dates + + Reservation aReservation = new Reservation(); + //if ( result2.size() == 0 && result3.size() == 0 && result4.size() == 0 && result5.size() == 0) { + if ( result.size() == 0) { + aReservation.setReservationState( ReservationStateType.COMPLETED.toString()); + } else { + aReservation.setReservationState( ReservationStateType.REJECTED.toString()); + } + + + + return aReservation; + } + + @Transactional + public List findAllReservations() { + return (List) this.resourceReservationRepository.findAll(); + } +} diff --git a/src/main/java/org/etsi/osl/tmf/rpm685/reposervices/ResourceReservationRepoService.java b/src/main/java/org/etsi/osl/tmf/rpm685/reposervices/ResourceReservationRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..8886971ef6c2e963fc0dff23ad6e4315e33ed04e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/rpm685/reposervices/ResourceReservationRepoService.java @@ -0,0 +1,155 @@ +package org.etsi.osl.tmf.rpm685.reposervices; + +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.service.ResourceRef; +import org.etsi.osl.tmf.rpm685.model.ApplicableTimePeriod; +import org.etsi.osl.tmf.rpm685.model.AppliedCapacityAmount; +import org.etsi.osl.tmf.rpm685.model.AvailabilityCheck; +import org.etsi.osl.tmf.rpm685.model.AvailabilityCheckCreate; +import org.etsi.osl.tmf.rpm685.model.Reservation; +import org.etsi.osl.tmf.rpm685.model.ReservationCreate; +import org.etsi.osl.tmf.rpm685.model.ReservationItem; +import org.etsi.osl.tmf.rpm685.model.ReservationMapper; +import org.etsi.osl.tmf.rpm685.model.ReservationStateType; +import org.etsi.osl.tmf.rpm685.model.ReservationUpdate; +import org.etsi.osl.tmf.rpm685.model.ResourceCapacityDemand; +import org.etsi.osl.tmf.rpm685.repo.ResourceReservationRepository; +import org.mapstruct.factory.Mappers; +import org.springframework.beans.factory.annotation.Autowired; +import jakarta.validation.Valid; + +/** + * @author ctranoris + * + */ +@org.springframework.stereotype.Service +public class ResourceReservationRepoService { + + private static final transient Log logger = LogFactory.getLog( ResourceReservationRepoService.class.getName()); + + @Autowired + ResourceReservationRepository resourceReservationRepository; + + @Autowired + ResourcePoolRepoService resourcePoolRepoService; + + + public Reservation addReservation(@Valid ReservationCreate body) { + logger.info("Will add Resource Reservation: " + body.getDescription() ); + + Reservation rp = new Reservation(); + ReservationMapper mapper = Mappers.getMapper( ReservationMapper.class); + rp = mapper.fromReservationDTO(body); + + rp.setReservationState( ReservationStateType.COMPLETED.toString() ); + + + for (ReservationItem ri : rp.getReservationItem()) { + AppliedCapacityAmount apCapAm = new AppliedCapacityAmount(); + apCapAm.setAppliedDemandAmount( ri.getResourceCapacity().getCapacityDemandAmount()); + apCapAm.getResource().addAll( ri.getResourceCapacity().getResourcePool().getResources() ); + + ResourceCapacityDemand resCap = new ResourceCapacityDemand(); + ApplicableTimePeriod applicableTimePeriod = new ApplicableTimePeriod(); + applicableTimePeriod.setFromDateTime( rp.getRequestedPeriodStartDateTime().minusSeconds(1) ); + applicableTimePeriod.setEndDateTime( rp.getRequestedPeriodEndDateTime().plusSeconds(1) ); + resCap.applicableTimePeriod( applicableTimePeriod ); + apCapAm.setResourceCapacityDemand(resCap); + ri.appliedCapacityAmount( apCapAm ); + + @Valid + AvailabilityCheckCreate acreq = new AvailabilityCheckCreate(); + ResourceCapacityDemand rcd = resCap; + acreq.setResourceCapacityDemand(rcd); + rcd.setResourcePool(ri.getResourceCapacity().getResourcePool()); + Set resourcesToReserve = new HashSet<>(); + resourcesToReserve.addAll( ri.getResourceCapacity().getResourcePool().getResources() ); + rcd.setResources( resourcesToReserve ); + + + AvailabilityCheck respAvailabilityCheck = resourcePoolRepoService.availabilityCheck(acreq ); + if ( respAvailabilityCheck.getAvailableResources().size() == 0 ) { + rp.setReservationState( ReservationStateType.REJECTED.toString() ); + return rp; + } + + } + + + + rp = this.resourceReservationRepository.save( rp ); + return rp; + } + + public Reservation findByUuid(String id) { + Optional optionalCat = this.resourceReservationRepository.findByUuid( id ); + return optionalCat + .orElse(null); + } + + public List findAll() { + return (List) this.resourceReservationRepository.findAll(); + } + + public Reservation updateReservation(String id, @Valid ReservationUpdate body) { + Reservation rp = this.findByUuid(id); + + + ReservationMapper mapper = Mappers.getMapper( ReservationMapper.class); + rp = mapper.updateReservation(rp, body) ; + + //re-calculate the reservation + for (ReservationItem ri : rp.getReservationItem()) { + AppliedCapacityAmount apCapAm = new AppliedCapacityAmount(); + apCapAm.setAppliedDemandAmount( ri.getResourceCapacity().getCapacityDemandAmount()); + apCapAm.getResource().addAll( ri.getResourceCapacity().getResourcePool().getResources() ); + + ResourceCapacityDemand resCap = new ResourceCapacityDemand(); + ApplicableTimePeriod applicableTimePeriod = new ApplicableTimePeriod(); + applicableTimePeriod.setFromDateTime( rp.getRequestedPeriodStartDateTime().minusSeconds(1) ); + applicableTimePeriod.setEndDateTime( rp.getRequestedPeriodEndDateTime().plusSeconds(1) ); + resCap.applicableTimePeriod( applicableTimePeriod ); + apCapAm.setResourceCapacityDemand(resCap); + ri.appliedCapacityAmount( apCapAm ); + + @Valid + AvailabilityCheckCreate acreq = new AvailabilityCheckCreate(); + ResourceCapacityDemand rcd = resCap; + acreq.setResourceCapacityDemand(rcd); + rcd.setResourcePool(ri.getResourceCapacity().getResourcePool()); + Set resourcesToReserve = new HashSet<>(); + resourcesToReserve.addAll( ri.getResourceCapacity().getResourcePool().getResources() ); + rcd.setResources( resourcesToReserve ); + + + AvailabilityCheck respAvailabilityCheck = resourcePoolRepoService.availabilityCheck(acreq ); + if ( respAvailabilityCheck.getAvailableResources().size() == 0 ) { + rp.setReservationState( ReservationStateType.REJECTED.toString() ); + return rp; + } + + } + + + rp = this.resourceReservationRepository.save( rp ); + return rp; + } + + + + public Void deleteByUuid(String id) { + Reservation s = this.findByUuid(id); + if (s == null) { + return null; + } + + this.resourceReservationRepository.delete( s ); + return null; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/sac640/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/sac640/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..28c3af68c0661fa530f38cfbc53cbd5342f9edb4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/ApiException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.sac640.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+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/sac640/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/sac640/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..ba07009459fed6b1cd5a5e56a2b81f846591b3df --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/ApiOriginFilter.java @@ -0,0 +1,50 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.sac640.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 = "2020-04-29T12:42:32.118457300+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/sac640/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/sac640/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..c8c676304cf122d632c78f6ba297752691c72fbc --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/ApiResponseMessage.java @@ -0,0 +1,88 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.sac640.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+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/sac640/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/sac640/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..fbb32c02a3b9bc699f726182a09dc44cd201bd75 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.sac640.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.sac640.model.EventSubscription; +import org.etsi.osl.tmf.sac640.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+03:00[Europe/Athens]") +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sac640/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/sac640/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..4c0a93ddf05f1747571ae413dfc47cb88f2994ec --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/HubApiController.java @@ -0,0 +1,55 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.sac640.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+03:00[Europe/Athens]") +@Controller("HubApiController640") +@RequestMapping("/ServiceActivationAndConfiguration/v3/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sac640/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/sac640/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..72285891da1bf2a2ce07db050d75d7b81d63f288 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/ListenerApi.java @@ -0,0 +1,327 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.sac640.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.sac640.model.EventSubscription; +import org.etsi.osl.tmf.sac640.model.MonitorAttributeValueChangeNotification; +import org.etsi.osl.tmf.sac640.model.MonitorCreateNotification; +import org.etsi.osl.tmf.sac640.model.MonitorDeleteNotification; +import org.etsi.osl.tmf.sac640.model.MonitorStateChangeNotification; +import org.etsi.osl.tmf.sim638.model.ServiceAttributeValueChangeNotification; +import org.etsi.osl.tmf.sim638.model.ServiceCreateNotification; +import org.etsi.osl.tmf.sim638.model.ServiceDeleteNotification; +import org.etsi.osl.tmf.sim638.model.ServiceStateChangeNotification; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+03:00[Europe/Athens]") +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity MonitorAttributeValueChangeNotification", operationId = "listenToMonitorAttributeValueChangeNotification", description = "Example of a client listener for receiving the notification MonitorAttributeValueChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/monitorAttributeValueChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToMonitorAttributeValueChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody MonitorAttributeValueChangeNotification body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity MonitorCreateNotification", operationId = "listenToMonitorCreateNotification", description = "Example of a client listener for receiving the notification MonitorCreateNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/monitorCreateNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToMonitorCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody MonitorCreateNotification body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity MonitorDeleteNotification", operationId = "listenToMonitorDeleteNotification", description = "Example of a client listener for receiving the notification MonitorDeleteNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/monitorDeleteNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToMonitorDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody MonitorDeleteNotification body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity MonitorStateChangeNotification", operationId = "listenToMonitorStateChangeNotification", description = "Example of a client listener for receiving the notification MonitorStateChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/monitorStateChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToMonitorStateChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody MonitorStateChangeNotification body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceAttributeValueChangeNotification", operationId = "listenToServiceAttributeValueChangeNotification", description = "Example of a client listener for receiving the notification ServiceAttributeValueChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceAttributeValueChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceAttributeValueChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceAttributeValueChangeNotification body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceCreateNotification", operationId = "listenToServiceCreateNotification", description = "Example of a client listener for receiving the notification ServiceCreateNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCreateNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCreateNotification body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceDeleteNotification", operationId = "listenToServiceDeleteNotification", description = "Example of a client listener for receiving the notification ServiceDeleteNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceDeleteNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceDeleteNotification body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceStateChangeNotification", operationId = "listenToServiceStateChangeNotification", description = "Example of a client listener for receiving the notification ServiceStateChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceStateChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceStateChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceStateChangeNotification body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sac640/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/sac640/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..6c1aca562edda79ceedec1436ff97660c4a1c5b5 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.sac640.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+03:00[Europe/Athens]") + +@Controller("ListenerApiController640") +@RequestMapping("/ServiceActivationAndConfiguration/v3/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sac640/api/MonitorApi.java b/src/main/java/org/etsi/osl/tmf/sac640/api/MonitorApi.java new file mode 100644 index 0000000000000000000000000000000000000000..c4d1775bc64af8f43eee25efc8aa1cc84640ffe0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/MonitorApi.java @@ -0,0 +1,130 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.sac640.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.sac640.model.Monitor; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+03:00[Europe/Athens]") +@Tag(name = "monitor", description = "the monitor API") +public interface MonitorApi { + + Logger log = LoggerFactory.getLogger(MonitorApi.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 = "List or find Monitor objects", operationId = "listMonitor", description = "This operation list or find Monitor entities" , tags={ "monitor", }) + @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 = "/monitor", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listMonitor(@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 +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\r\n \"request\" : {\r\n \"method\" : \"method\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"header\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"to\" : \"to\",\r\n \"body\" : \"body\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"response\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"header\" : [ null, null ],\r\n \"body\" : \"body\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"statusCode\" : \"statusCode\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"sourceHref\" : \"sourceHref\"\r\n}, {\r\n \"request\" : {\r\n \"method\" : \"method\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"header\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"to\" : \"to\",\r\n \"body\" : \"body\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"response\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"header\" : [ null, null ],\r\n \"body\" : \"body\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"statusCode\" : \"statusCode\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"sourceHref\" : \"sourceHref\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default MonitorApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a Monitor by ID", operationId = "retrieveMonitor", description = "This operation retrieves a Monitor entity. Attribute selection is enabled for all first level attributes.", tags={ "monitor", }) + @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 = "/monitor/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveMonitor(@Parameter(description = "Identifier of the Monitor",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("{\r\n \"request\" : {\r\n \"method\" : \"method\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"header\" : [ {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n }, {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : \"value\"\r\n } ],\r\n \"to\" : \"to\",\r\n \"body\" : \"body\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n },\r\n \"@baseType\" : \"@baseType\",\r\n \"response\" : {\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"header\" : [ null, null ],\r\n \"body\" : \"body\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"statusCode\" : \"statusCode\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"sourceHref\" : \"sourceHref\"\r\n}", Monitor.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 MonitorApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sac640/api/MonitorApiController.java b/src/main/java/org/etsi/osl/tmf/sac640/api/MonitorApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..719408b93c8cac4cbe0459b204ab83329540a6bd --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/MonitorApiController.java @@ -0,0 +1,53 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.sac640.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+03:00[Europe/Athens]") +@Controller +public class MonitorApiController implements MonitorApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public MonitorApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sac640/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/sac640/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..299498996bc67b3983d7acd2de5e2dd45729e4f9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/NotFoundException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.sac640.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+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/sac640/api/ServiceApiController.java b/src/main/java/org/etsi/osl/tmf/sac640/api/ServiceApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..e01805ed3515bce36bddf47eb251f1f4404574d1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sac640/api/ServiceApiController.java @@ -0,0 +1,41 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.sac640.api; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-04-29T12:42:32.118457300+03:00[Europe/Athens]") +@Controller("ServiceApiController640") +@RequestMapping("/ServiceActivationAndConfiguration/v3/") +public class ServiceApiController extends org.etsi.osl.tmf.sim638.api.ServiceApiController{ + + + + @Autowired + public ServiceApiController(ObjectMapper objectMapper, HttpServletRequest request) { + super(objectMapper, request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ExportJobApi.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ExportJobApi.java new file mode 100644 index 0000000000000000000000000000000000000000..bda16faed7ff79e8706bd954018f69ec11f0290a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ExportJobApi.java @@ -0,0 +1,113 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.4). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.scm633.api; + +import java.util.List; +import org.etsi.osl.tmf.scm633.model.ExportJob; +import org.etsi.osl.tmf.scm633.model.ExportJobCreate; +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.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Tag(name = "exportJob", description = "the exportJob API") +public interface ExportJobApi { + + @Operation(summary = "Creates a ExportJob", operationId = "createExportJob", description = "This operation creates a ExportJob entity.", tags={ "exportJob", }) + @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 = "/exportJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity createExportJob(@Parameter(description = "The ExportJob to be created" ,required=true ) @Valid @RequestBody ExportJobCreate exportJob); + + + @Operation(summary = "Deletes a ExportJob", operationId = "deleteExportJob", description = "This operation deletes a ExportJob entity.", tags={ "exportJob", }) + @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 = "/exportJob/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + ResponseEntity deleteExportJob(@Parameter(description = "Identifier of the ExportJob",required=true) @PathVariable("id") String id); + + + @Operation(summary = "List or find ExportJob objects", operationId = "listExportJob", description = "This operation list or find ExportJob entities" , tags={ "exportJob", }) + @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 = "/exportJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity> listExportJob(@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); + + + @Operation(summary = "Retrieves a ExportJob by ID", operationId = "retrieveExportJob", description = "This operation retrieves a ExportJob entity. Attribute selection is enabled for all first level attributes.", tags={ "exportJob", }) + @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 = "/exportJob/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity retrieveExportJob(@Parameter(description = "Identifier of the ExportJob",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields); + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ExportJobApiController633.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ExportJobApiController633.java new file mode 100644 index 0000000000000000000000000000000000000000..c5ff4dc54f253570ceb771ba3c9b9208a05dfa2f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ExportJobApiController633.java @@ -0,0 +1,105 @@ +/*- + * ========================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.scm633.api; + +import java.io.IOException; +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.scm633.model.ExportJob; +import org.etsi.osl.tmf.scm633.model.ExportJobCreate; +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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Controller("ExportJobApiController633") +@RequestMapping("/serviceCatalogManagement/v4/") +public class ExportJobApiController633 implements ExportJobApi { + + private static final Logger log = LoggerFactory.getLogger(ExportJobApiController633.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ExportJobApiController633(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + public ResponseEntity createExportJob(@Parameter(description = "The ExportJob to be created" ,required=true ) @Valid @RequestBody ExportJobCreate exportJob) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"@type\" : \"@type\", \"query\" : \"query\", \"errorLog\" : \"errorLog\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"url\" : \"url\", \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"status\" : \"status\"}", ExportJob.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 deleteExportJob(@Parameter(description = "Identifier of the ExportJob",required=true) @PathVariable("id") String id) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity> listExportJob(@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) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"@type\" : \"@type\", \"query\" : \"query\", \"errorLog\" : \"errorLog\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"url\" : \"url\", \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"status\" : \"status\"}, { \"@type\" : \"@type\", \"query\" : \"query\", \"errorLog\" : \"errorLog\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"url\" : \"url\", \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"status\" : \"status\"} ]", 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 retrieveExportJob(@Parameter(description = "Identifier of the ExportJob",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @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("{ \"@type\" : \"@type\", \"query\" : \"query\", \"errorLog\" : \"errorLog\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"url\" : \"url\", \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"id\" : \"id\", \"href\" : \"href\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"status\" : \"status\"}", ExportJob.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/scm633/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/scm633/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..cd7d1306f137b198a673c0248fbb222efc70e9f8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/HubApi.java @@ -0,0 +1,77 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.4). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.scm633.api; + +import org.etsi.osl.tmf.scm633.model.EventSubscription; +import org.etsi.osl.tmf.scm633.model.EventSubscriptionInput; +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 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.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + @Operation(summary = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data); + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id); + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/scm633/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..2d7ec59a96d552681641c23c97ab80f9fe3931d3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/HubApiController.java @@ -0,0 +1,75 @@ +/*- + * ========================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.scm633.api; + +import java.io.IOException; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.scm633.model.EventSubscription; +import org.etsi.osl.tmf.scm633.model.EventSubscriptionInput; +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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Controller("HubApiController633") +@RequestMapping("/serviceCatalogManagement/v4/") +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(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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(description = "The id of the registered listener",required=true) @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/scm633/api/ImportJobApi.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ImportJobApi.java new file mode 100644 index 0000000000000000000000000000000000000000..905123abf3f0f0567cd87ee7b8c267ee7affe880 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ImportJobApi.java @@ -0,0 +1,113 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.4). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.scm633.api; + +import java.util.List; +import org.etsi.osl.tmf.scm633.model.ImportJob; +import org.etsi.osl.tmf.scm633.model.ImportJobCreate; +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.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Tag(name = "importJob", description = "the importJob API") +public interface ImportJobApi { + + @Operation(summary = "Creates a ImportJob", operationId = "createImportJob", description = "This operation creates a ImportJob entity.", tags={ "importJob", }) + @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 = "/importJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity createImportJob(@Parameter(description = "The ImportJob to be created" ,required=true ) @Valid @RequestBody ImportJobCreate importJob); + + + @Operation(summary = "Deletes a ImportJob", operationId = "deleteImportJob", description = "This operation deletes a ImportJob entity.", tags={ "importJob", }) + @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 = "/importJob/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + ResponseEntity deleteImportJob(@Parameter(description = "Identifier of the ImportJob",required=true) @PathVariable("id") String id); + + + @Operation(summary = "List or find ImportJob objects", operationId = "listImportJob", description = "This operation list or find ImportJob entities" , tags={ "importJob", }) + @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 = "/importJob", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity> listImportJob(@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); + + + @Operation(summary = "Retrieves a ImportJob by ID", operationId = "retrieveImportJob", description = "This operation retrieves a ImportJob entity. Attribute selection is enabled for all first level attributes.", tags={ "importJob", }) + @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 = "/importJob/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity retrieveImportJob(@Parameter(description = "Identifier of the ImportJob",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields); + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ImportJobApiController.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ImportJobApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..a8a40db8e4ccf0c04399346d2576ed636959e24b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ImportJobApiController.java @@ -0,0 +1,105 @@ +/*- + * ========================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.scm633.api; + +import java.io.IOException; +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.scm633.model.ImportJob; +import org.etsi.osl.tmf.scm633.model.ImportJobCreate; +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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Controller("ImportJobApiController633") +@RequestMapping("/serviceCatalogManagement/v4/") +public class ImportJobApiController implements ImportJobApi { + + private static final Logger log = LoggerFactory.getLogger(ImportJobApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ImportJobApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + public ResponseEntity createImportJob(@Parameter(description = "The ImportJob to be created" ,required=true ) @Valid @RequestBody ImportJobCreate importJob) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"errorLog\" : \"errorLog\", \"id\" : \"id\", \"href\" : \"href\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"url\" : \"url\", \"status\" : \"status\"}", ImportJob.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 deleteImportJob(@Parameter(description = "Identifier of the ImportJob",required=true) @PathVariable("id") String id) { + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + public ResponseEntity> listImportJob(@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) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity>(objectMapper.readValue("[ { \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"errorLog\" : \"errorLog\", \"id\" : \"id\", \"href\" : \"href\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"url\" : \"url\", \"status\" : \"status\"}, { \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"errorLog\" : \"errorLog\", \"id\" : \"id\", \"href\" : \"href\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"url\" : \"url\", \"status\" : \"status\"} ]", 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 retrieveImportJob(@Parameter(description = "Identifier of the ImportJob",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @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("{ \"path\" : \"path\", \"@baseType\" : \"@baseType\", \"@type\" : \"@type\", \"completionDate\" : \"2000-01-23T04:56:07.000+00:00\", \"errorLog\" : \"errorLog\", \"id\" : \"id\", \"href\" : \"href\", \"creationDate\" : \"2000-01-23T04:56:07.000+00:00\", \"@schemaLocation\" : \"http://example.com/aeiou\", \"contentType\" : \"contentType\", \"url\" : \"url\", \"status\" : \"status\"}", ImportJob.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/scm633/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..32be677ca28857d1b64d78477095ec41f446ff52 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ListenerApi.java @@ -0,0 +1,276 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.4). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.scm633.api; + +import org.etsi.osl.tmf.scm633.model.EventSubscription; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateChangeNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateCreateNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateDeleteNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogBatchNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogChangeNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogCreateNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogDeleteNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryChangeNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryCreateNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryDeleteNotification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationChangeNotification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreateNotification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationDeleteNotification; +import org.springframework.http.ResponseEntity; +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.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + @Operation(summary = "Client listener for entity ServiceCandidateChangeNotification", operationId = "listenToServiceCandidateChangeNotification", description = "Example of a client listener for receiving the notification ServiceCandidateChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCandidateChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCandidateChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCandidateChangeNotification data); + + + @Operation(summary = "Client listener for entity ServiceCandidateCreateNotification", operationId = "listenToServiceCandidateCreateNotification", description = "Example of a client listener for receiving the notification ServiceCandidateCreateNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCandidateCreateNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCandidateCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCandidateCreateNotification data); + + + @Operation(summary = "Client listener for entity ServiceCandidateDeleteNotification", operationId = "listenToServiceCandidateDeleteNotification", description = "Example of a client listener for receiving the notification ServiceCandidateDeleteNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCandidateDeleteNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCandidateDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCandidateDeleteNotification data); + + + @Operation(summary = "Client listener for entity ServiceCatalogBatchNotification", operationId = "listenToServiceCatalogBatchNotification", description = "Example of a client listener for receiving the notification ServiceCatalogBatchNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCatalogBatchNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCatalogBatchNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCatalogBatchNotification data); + + + @Operation(summary = "Client listener for entity ServiceCatalogChangeNotification", operationId = "listenToServiceCatalogChangeNotification", description = "Example of a client listener for receiving the notification ServiceCatalogChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCatalogChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCatalogChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCatalogChangeNotification data); + + + @Operation(summary = "Client listener for entity ServiceCatalogCreateNotification", operationId = "listenToServiceCatalogCreateNotification", description = "Example of a client listener for receiving the notification ServiceCatalogCreateNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCatalogCreateNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCatalogCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCatalogCreateNotification data); + + + @Operation(summary = "Client listener for entity ServiceCatalogDeleteNotification", operationId = "listenToServiceCatalogDeleteNotification", description = "Example of a client listener for receiving the notification ServiceCatalogDeleteNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCatalogDeleteNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCatalogDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCatalogDeleteNotification data); + + + @Operation(summary = "Client listener for entity ServiceCategoryChangeNotification", operationId = "listenToServiceCategoryChangeNotification", description = "Example of a client listener for receiving the notification ServiceCategoryChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCategoryChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCategoryChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCategoryChangeNotification data); + + + @Operation(summary = "Client listener for entity ServiceCategoryCreateNotification", operationId = "listenToServiceCategoryCreateNotification", description = "Example of a client listener for receiving the notification ServiceCategoryCreateNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCategoryCreateNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCategoryCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCategoryCreateNotification data); + + + @Operation(summary = "Client listener for entity ServiceCategoryDeleteNotification", operationId = "listenToServiceCategoryDeleteNotification", description = "Example of a client listener for receiving the notification ServiceCategoryDeleteNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCategoryDeleteNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceCategoryDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCategoryDeleteNotification data); + + + @Operation(summary = "Client listener for entity ServiceSpecificationChangeNotification", operationId = "listenToServiceSpecificationChangeNotification", description = "Example of a client listener for receiving the notification ServiceSpecificationChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceSpecificationChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceSpecificationChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceSpecificationChangeNotification data); + + + @Operation(summary = "Client listener for entity ServiceSpecificationCreateNotification", operationId = "listenToServiceSpecificationCreateNotification", description = "Example of a client listener for receiving the notification ServiceSpecificationCreateNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceSpecificationCreateNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceSpecificationCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceSpecificationCreateNotification data); + + + @Operation(summary = "Client listener for entity ServiceSpecificationDeleteNotification", operationId = "listenToServiceSpecificationDeleteNotification", description = "Example of a client listener for receiving the notification ServiceSpecificationDeleteNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceSpecificationDeleteNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity listenToServiceSpecificationDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceSpecificationDeleteNotification data); + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..912e48f60ee5b99e8c07e10eda7185fb20c1456b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ListenerApiController.java @@ -0,0 +1,249 @@ +/*- + * ========================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.scm633.api; + +import java.io.IOException; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.scm633.model.EventSubscription; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateChangeNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateCreateNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateDeleteNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogBatchNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogChangeNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogCreateNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogDeleteNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryChangeNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryCreateNotification; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryDeleteNotification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationChangeNotification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreateNotification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationDeleteNotification; +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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Controller("ListenerApiController633") +@RequestMapping("/serviceCatalogManagement/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 listenToServiceCandidateChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCandidateChangeNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceCandidateCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCandidateCreateNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceCandidateDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCandidateDeleteNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceCatalogBatchNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCatalogBatchNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceCatalogChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCatalogChangeNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceCatalogCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCatalogCreateNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceCatalogDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCatalogDeleteNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceCategoryChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCategoryChangeNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceCategoryCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCategoryCreateNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceCategoryDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCategoryDeleteNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceSpecificationChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceSpecificationChangeNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceSpecificationCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceSpecificationCreateNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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 listenToServiceSpecificationDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceSpecificationDeleteNotification data) { + String accept = request.getHeader("Accept"); + if (accept != null && accept.contains("application/json")) { + try { + return new ResponseEntity(objectMapper.readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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/scm633/api/ServiceCandidateApi.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCandidateApi.java new file mode 100644 index 0000000000000000000000000000000000000000..df96d13a1c4c5435a1cc8581095210337c070387 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCandidateApi.java @@ -0,0 +1,128 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.4). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.scm633.api; + +import java.util.List; +import org.etsi.osl.tmf.scm633.model.ServiceCandidate; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateUpdate; +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.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Tag(name = "serviceCandidate", description = "the serviceCandidate API") +public interface ServiceCandidateApi { + + @Operation(summary = "Creates a ServiceCandidate", operationId = "createServiceCandidate", description = "This operation creates a ServiceCandidate entity.", tags={ "serviceCandidate", }) + @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 = "/serviceCandidate", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity createServiceCandidate(@Parameter(description = "The ServiceCandidate to be created" ,required=true ) @Valid @RequestBody ServiceCandidateCreate serviceCandidate); + + + @Operation(summary = "Deletes a ServiceCandidate", operationId = "deleteServiceCandidate", description = "This operation deletes a ServiceCandidate entity.", tags={ "serviceCandidate", }) + @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 = "/serviceCandidate/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + ResponseEntity deleteServiceCandidate(@Parameter(description = "Identifier of the ServiceCandidate",required=true) @PathVariable("id") String id); + + + @Operation(summary = "List or find ServiceCandidate objects", operationId = "listServiceCandidate", description = "This operation list or find ServiceCandidate entities" , tags={ "serviceCandidate", }) + @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 = "/serviceCandidate", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity> listServiceCandidate(@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); + + + @Operation(summary = "Updates partially a ServiceCandidate", operationId = "patchServiceCandidate", description = "This operation updates partially a ServiceCandidate entity.", tags={ "serviceCandidate", }) + @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 = "/serviceCandidate/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + ResponseEntity patchServiceCandidate(@Parameter(description = "Identifier of the ServiceCandidate",required=true) @PathVariable("id") String id,@Parameter(description = "The ServiceCandidate to be updated" ,required=true ) @Valid @RequestBody ServiceCandidateUpdate serviceCandidate); + + + @Operation(summary = "Retrieves a ServiceCandidate by ID", operationId = "retrieveServiceCandidate", description = "This operation retrieves a ServiceCandidate entity. Attribute selection is enabled for all first level attributes.", tags={ "serviceCandidate", }) + @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 = "/serviceCandidate/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity retrieveServiceCandidate(@Parameter(description = "Identifier of the ServiceCandidate",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields); + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCandidateApiController.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCandidateApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..a5ec332706d92d496479e8f477dc4eb27405d902 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCandidateApiController.java @@ -0,0 +1,111 @@ +/*- + * ========================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.scm633.api; + +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.scm633.model.ServiceCandidate; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateUpdate; +import org.etsi.osl.tmf.scm633.reposervices.CandidateRepoService; +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.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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Controller +@RequestMapping("/serviceCatalogManagement/v4/") +public class ServiceCandidateApiController implements ServiceCandidateApi { + + private static final Logger log = LoggerFactory.getLogger(ServiceCandidateApiController.class); + + private final HttpServletRequest request; + + @Autowired + CandidateRepoService candidateRepoService; + + + @org.springframework.beans.factory.annotation.Autowired + public ServiceCandidateApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.request = request; + } + + public ResponseEntity createServiceCandidate(@Parameter(description = "The ServiceCandidate to be created" ,required=true ) @Valid @RequestBody ServiceCandidateCreate serviceCandidate) { + try { + + ServiceCandidate c = candidateRepoService.addServiceCandidate( serviceCandidate ); + + return new ResponseEntity(c, HttpStatus.OK); + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + public ResponseEntity deleteServiceCandidate(@Parameter(description = "Identifier of the ServiceCandidate",required=true) @PathVariable("id") String id) { + try { + + return new ResponseEntity( candidateRepoService.deleteById( 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); + } + } + + public ResponseEntity> listServiceCandidate(@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) { + String accept = request.getHeader("Accept"); + try { + return new ResponseEntity>( candidateRepoService.findAll() , HttpStatus.OK); + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + public ResponseEntity patchServiceCandidate(@Parameter(description = "Identifier of the ServiceCandidate",required=true) @PathVariable("id") String id,@Parameter(description = "The ServiceCandidate to be updated" ,required=true ) @Valid @RequestBody ServiceCandidateUpdate serviceCandidate) { + + ServiceCandidate c = candidateRepoService.updateCandidate( id, serviceCandidate ); + + return new ResponseEntity(c, HttpStatus.OK); + } + + public ResponseEntity retrieveServiceCandidate(@Parameter(description = "Identifier of the ServiceCandidate",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + try { + + return new ResponseEntity( candidateRepoService.findById( 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/scm633/api/ServiceCatalogApi.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCatalogApi.java new file mode 100644 index 0000000000000000000000000000000000000000..2e1bc184906d9bacdd4b0350bdc0e422f6c9a333 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCatalogApi.java @@ -0,0 +1,128 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.4). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.scm633.api; + +import java.util.List; +import org.etsi.osl.tmf.scm633.model.ServiceCatalog; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogUpdate; +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.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Tag(name = "serviceCatalog", description = "the serviceCatalog API") +public interface ServiceCatalogApi { + + @Operation(summary = "Creates a ServiceCatalog", operationId = "createServiceCatalog", description = "This operation creates a ServiceCatalog entity.", tags={ "serviceCatalog", }) + @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 = "/serviceCatalog", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity createServiceCatalog(@Parameter(description = "The ServiceCatalog to be created" ,required=true ) @Valid @RequestBody ServiceCatalogCreate serviceCatalog); + + + @Operation(summary = "Deletes a ServiceCatalog", operationId = "deleteServiceCatalog", description = "This operation deletes a ServiceCatalog entity.", tags={ "serviceCatalog", }) + @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 = "/serviceCatalog/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + ResponseEntity deleteServiceCatalog(@Parameter(description = "Identifier of the ServiceCatalog",required=true) @PathVariable("id") String id); + + + @Operation(summary = "List or find ServiceCatalog objects", operationId = "listServiceCatalog", description = "This operation list or find ServiceCatalog entities" , tags={ "serviceCatalog", }) + @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 = "/serviceCatalog", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity> listServiceCatalog(@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); + + + @Operation(summary = "Updates partially a ServiceCatalog", operationId = "patchServiceCatalog", description = "This operation updates partially a ServiceCatalog entity.", tags={ "serviceCatalog", }) + @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 = "/serviceCatalog/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + ResponseEntity patchServiceCatalog(@Parameter(description = "Identifier of the ServiceCatalog",required=true) @PathVariable("id") String id,@Parameter(description = "The ServiceCatalog to be updated" ,required=true ) @Valid @RequestBody ServiceCatalogUpdate serviceCatalog); + + + @Operation(summary = "Retrieves a ServiceCatalog by ID", operationId = "retrieveServiceCatalog", description = "This operation retrieves a ServiceCatalog entity. Attribute selection is enabled for all first level attributes.", tags={ "serviceCatalog", }) + @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 = "/serviceCatalog/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity retrieveServiceCatalog(@Parameter(description = "Identifier of the ServiceCatalog",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields); + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCatalogApiController.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCatalogApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..92a7d5104dacda1fff4103c75d130b03ffbe193e --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCatalogApiController.java @@ -0,0 +1,108 @@ +/*- + * ========================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.scm633.api; + +import java.util.List; +import org.etsi.osl.tmf.scm633.model.ServiceCatalog; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogUpdate; +import org.etsi.osl.tmf.scm633.reposervices.CatalogRepoService; +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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Controller +@RequestMapping("/serviceCatalogManagement/v4/") +public class ServiceCatalogApiController implements ServiceCatalogApi { + + private static final Logger log = LoggerFactory.getLogger(ServiceCatalogApiController.class); + + + + @Autowired + CatalogRepoService catalogRepoService; + + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createServiceCatalog( + @Parameter(description = "The ServiceCatalog to be created" ,required=true ) @Valid @RequestBody ServiceCatalogCreate serviceCatalog) { + try { + + ServiceCatalog c = catalogRepoService.addCatalog( serviceCatalog ); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity deleteServiceCatalog(@Parameter(description = "Identifier of the ServiceCatalog",required=true) @PathVariable("id") String id) { + try { + + return new ResponseEntity( catalogRepoService.deleteById( 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); + } + } + + public ResponseEntity> listServiceCatalog(@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) { + + try { + return new ResponseEntity>( catalogRepoService.findAll() , 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity patchServiceCatalog(@Parameter(description = "Identifier of the ServiceCatalog",required=true) @PathVariable("id") String id,@Parameter(description = "The ServiceCatalog to be updated" ,required=true ) @Valid @RequestBody ServiceCatalogUpdate serviceCatalog) { + + ServiceCatalog c = catalogRepoService.updateCatalog( id, serviceCatalog ); + + return new ResponseEntity(c, HttpStatus.OK); + } + + public ResponseEntity retrieveServiceCatalog(@Parameter(description = "Identifier of the ServiceCatalog",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + try { + + return new ResponseEntity( catalogRepoService.findById( 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/scm633/api/ServiceCategoryApi.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCategoryApi.java new file mode 100644 index 0000000000000000000000000000000000000000..4f15500c7c0030d2c70ebe331895027baf833146 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCategoryApi.java @@ -0,0 +1,129 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.4). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.scm633.api; + +import java.util.List; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryUpdate; +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.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Tag(name = "serviceCategory", description = "the serviceCategory API") +public interface ServiceCategoryApi { + + @Operation(summary = "Creates a ServiceCategory", operationId = "createServiceCategory", description = "This operation creates a ServiceCategory entity.", tags={ "serviceCategory", }) + @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 = "/serviceCategory", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity createServiceCategory(@Parameter(description = "The ServiceCategory to be created" ,required=true ) @Valid @RequestBody ServiceCategoryCreate serviceCategory); + + + @Operation(summary = "Deletes a ServiceCategory", operationId = "deleteServiceCategory", description = "This operation deletes a ServiceCategory entity.", tags={ "serviceCategory", }) + @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 = "/serviceCategory/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + ResponseEntity deleteServiceCategory(@Parameter(description = "Identifier of the ServiceCategory",required=true) @PathVariable("id") String id); + + + @Operation(summary = "List or find ServiceCategory objects", operationId = "listServiceCategory", description = "This operation list or find ServiceCategory entities" , tags={ "serviceCategory", }) + @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 = "413", description = "Not modifed" ), + @ApiResponse(responseCode = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/serviceCategory", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity> listServiceCategory(@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); + + + @Operation(summary = "Updates partially a ServiceCategory", operationId = "patchServiceCategory", description = "This operation updates partially a ServiceCategory entity.", tags={ "serviceCategory", }) + @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 = "/serviceCategory/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + ResponseEntity patchServiceCategory(@Parameter(description = "Identifier of the ServiceCategory",required=true) @PathVariable("id") String id,@Parameter(description = "The ServiceCategory to be updated" ,required=true ) @Valid @RequestBody ServiceCategoryUpdate serviceCategory); + + + @Operation(summary = "Retrieves a ServiceCategory by ID", operationId = "retrieveServiceCategory", description = "This operation retrieves a ServiceCategory entity. Attribute selection is enabled for all first level attributes.", tags={ "serviceCategory", }) + @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 = "/serviceCategory/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity retrieveServiceCategory(@Parameter(description = "Identifier of the ServiceCategory",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields); + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCategoryApiController.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCategoryApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..0b745f2f863afc57c90e85ca6ea7eba00ce1bd11 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceCategoryApiController.java @@ -0,0 +1,138 @@ +/*- + * ========================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.scm633.api; + +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryUpdate; +import org.etsi.osl.tmf.scm633.reposervices.CategoryRepoService; +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 io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Controller +@RequestMapping("/serviceCatalogManagement/v4/") +public class ServiceCategoryApiController implements ServiceCategoryApi { + + private static final Logger log = LoggerFactory.getLogger(ServiceCategoryApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Autowired + CategoryRepoService categoryRepoService; + + @org.springframework.beans.factory.annotation.Autowired + public ServiceCategoryApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createServiceCategory( + @Parameter(description = "The ServiceCategory to be created", required = true) @Valid @RequestBody ServiceCategoryCreate serviceCategory) { + + try { + + ServiceCategory c = categoryRepoService.addCategory(serviceCategory); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity deleteServiceCategory( + @Parameter(description = "Identifier of the ServiceCategory", required = true) @PathVariable("id") String id) { + + try { + if ( categoryRepoService.deleteById(id) ) { + return new ResponseEntity(HttpStatus.OK); + + } else { + return new ResponseEntity(HttpStatus.NOT_MODIFIED ); + } + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + public ResponseEntity> listServiceCategory( + @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) { + + try { + return new ResponseEntity>(categoryRepoService.findAll(), 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity patchServiceCategory( + @Parameter(description = "Identifier of the ServiceCategory", required = true) @PathVariable("id") String id, + @Parameter(description = "The ServiceCategory to be updated", required = true) @Valid @RequestBody ServiceCategoryUpdate serviceCategory) { + + ServiceCategory c = categoryRepoService.updateCategory(id, serviceCategory); + + return new ResponseEntity(c, HttpStatus.OK); + } + + public ResponseEntity retrieveServiceCategory( + @Parameter(description = "Identifier of the ServiceCategory", required = true) @PathVariable("id") String id, + @Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + + try { + + return new ResponseEntity(categoryRepoService.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/scm633/api/ServiceSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..bb2e27f606fdc7f35bf6f8d4b967e4307ae99383 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApi.java @@ -0,0 +1,345 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.4). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.scm633.api; + +import java.util.List; +import java.util.Map; +import org.etsi.osl.sd.model.ServiceDescriptor; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationUpdate; +import org.springframework.http.MediaType; +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 org.springframework.web.multipart.MultipartFile; +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 jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +public interface ServiceSpecificationApi { + + @Operation(summary = "Creates a ServiceSpecification", operationId = "createServiceSpecification", description = "This operation creates a ServiceSpecification entity.", tags={ "serviceSpecification", }) + @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 = "/serviceSpecification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + ResponseEntity createServiceSpecification(@Parameter(description = "The ServiceSpecification to be created" ,required=true ) @Valid @RequestBody ServiceSpecificationCreate serviceSpecification); + + + @Operation(summary = "Deletes a ServiceSpecification", operationId = "deleteServiceSpecification", description = "This operation deletes a ServiceSpecification entity.", tags={ "serviceSpecification", }) + @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 = "/serviceSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + ResponseEntity deleteServiceSpecification(@Parameter(description = "Identifier of the ServiceSpecification",required=true) @PathVariable("id") String id); + + + @Operation(summary = "List or find ServiceSpecification objects", operationId = "listServiceSpecification", description = "This operation list or find ServiceSpecification entities" , tags={ "serviceSpecification", }) + @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 = "/serviceSpecification", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity> listServiceSpecification(@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); + + + @Operation(summary = "Updates partially a ServiceSpecification", operationId = "patchServiceSpecification", description = "This operation updates partially a ServiceSpecification entity.", tags={ "serviceSpecification", }) + @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 = "/serviceSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + ResponseEntity patchServiceSpecification(@Parameter(description = "Identifier of the ServiceSpecification",required=true) @PathVariable("id") String id,@Parameter(description = "The ServiceSpecification to be updated" ,required=true ) @Valid @RequestBody ServiceSpecificationUpdate serviceSpecification); + + + @Operation(summary = "Retrieves a ServiceSpecification by ID", operationId = "retrieveServiceSpecification", description = "This operation retrieves a ServiceSpecification entity. Attribute selection is enabled for all first level attributes.", tags={ "serviceSpecification", }) + @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 = "/serviceSpecification/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity retrieveServiceSpecification(@Parameter(description = "Identifier of the ServiceSpecification",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields); + + @Operation(summary = "Clones a ServiceSpecification", operationId = "cloneServiceSpecification", description = "This operation clones a ServiceSpecification entity. The response is the cloned spec", tags={ "serviceSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Cloned" ), + @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 = "/serviceSpecification/{id}/clone", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity cloneServiceSpecification(@Parameter(description = "Identifier of the ServiceSpecification to clone",required=true) @PathVariable("id") String id ); + + @Operation(summary = "Clones a GST ServiceSpecification", operationId = "cloneGSTServiceSpecification", + description = "This operation clones a ServiceSpecification GST entity. The response is the cloned spec", tags={ "serviceSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Cloned" ), + @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 = "/serviceSpecification/cloneGST", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity cloneGSTServiceSpecification( + @Parameter(description = "A name of the cloned GST") @RequestParam(value="serviceName", required=true) String serviceName); + + @Operation(summary = "Clones a VINNI ServiceSpecification", operationId = "cloneVINNIServiceSpecification", + description = "This operation clones a ServiceSpecification 5G-VINNI entity. The response is the cloned spec", tags={ "serviceSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Cloned" ), + @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 = "/serviceSpecification/cloneVINNI", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity cloneVINNIServiceSpecification( + @Parameter(description = "A name of the cloned VINNI Template") @RequestParam( value="serviceName",required=true) String serviceName, + @Parameter(description = "If true adds a Service Topology Spec in the Bundle") @RequestParam( value="addServiceTopology",required=true) Boolean addServiceTopology, + @Parameter(description = "If true adds a Service Requirements Spec in the Bundle") @RequestParam( value="addServiceRequirements",required=true) Boolean addServiceRequirements, + @Parameter(description = "If true adds a Service Exposure Level1 Spec in the Bundle") @RequestParam( value="addServiceExposureLevel1",required=true) Boolean addServiceExposureLevel1, + @Parameter(description = "If true adds a Service Exposure Level2 Spec in the Bundle") @RequestParam( value="addServiceExposureLevel2",required=true) Boolean addServiceExposureLevel2, + @Parameter(description = "If true adds a Service Exposure Level3 Spec in the Bundle") @RequestParam( value="addServiceExposureLevel3",required=true) Boolean addServiceExposureLevel3, + @Parameter(description = "If true adds a Service Exposure Level4 Spec in the Bundle" ) @RequestParam( value="addServiceExposureLevel4",required=true) Boolean addServiceExposureLevel4, + @Parameter(description = "If true adds a Service Monitoring Spec in the Bundle" ) @RequestParam( value="addServiceMonitoring",required=true) Boolean addServiceMonitoring, + @Parameter(description = "If true adds a Service Testing Spec in the Bundle" ) @RequestParam( value="addServiceTesting",required=true) Boolean addServiceTesting, + @Parameter(description = "If true adds a Service 3rd party VNF Spec in the Bundle" ) @RequestParam( value="addServiceVNF",required=true) Boolean addServiceVNF, + @Parameter(description = "If true adds a Service 3rd party NSD Spec in the Bundle" ) @RequestParam( value="addServiceNSD",required=true) Boolean addServiceNSD); + + + @Operation(summary = "Creates a ServiceSpecification from an NSD id. It retreives the NSD from the NSD/VNF catalog", operationId = "createServiceSpecificationFromNSDID", + description = "This operation creates a ServiceSpecification from an NSD id. It retreives the NSD from the NSD/VNF catalog. " + + "The response is the cloned spec", tags={ "serviceSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Created" ), + @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 = "/serviceSpecification/specFromNSDID/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity specFromNSDID( @Parameter(description = "Identifier of the NSD id from the NSD/VNF catalog",required=true) @PathVariable("id") String id ); + + @Operation(summary = "Adds an attachment to a ServiceSpecification", operationId = "addAttachmentToServiceSpecification", + description = "This operation adds an attachment to a ServiceSpecification and updates partially a ServiceSpecification entity", tags={ "serviceSpecification", }) + @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 = "/serviceSpecification/{id}/attachment", + produces = { "application/json;charset=utf-8" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + ResponseEntity addAttachmentToServiceSpecification( + @Parameter(description = "Identifier of the ServiceSpecification",required=true) @PathVariable("id") String id, + //@Parameter(description = "The Attachment object to be added" ,required=false ) @Valid @ModelAttribute("attachment") Attachment attachment, + @Parameter(description = "The Attachment file to be added" ,required=false, name = "afile" ) @Valid MultipartFile file, + HttpServletRequest request); + + @Operation(summary = "Get an attachment", operationId = "getAttachment", + description = "This operation gets an attachment", tags={ "serviceSpecification", }) + @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 = "/serviceSpecification/{id}/attachment/{attid}", + produces = MediaType.ALL_VALUE, + method = RequestMethod.GET) + ResponseEntity getAttachment( + @Parameter(description = "Identifier of the ServiceSpecification",required=true) @PathVariable("id") String id, + @Parameter(description = "Identifier of the Attachment",required=true) @PathVariable("attid") String attid); + + + + @Operation(summary = "Get an attachment with filename", operationId = "getAttachmentWithFilename", + description = "This operation gets an attachment", tags={ "serviceSpecification", }) + @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 = "/serviceSpecification/{id}/attachment/{attid}/{afilename}", + produces = MediaType.ALL_VALUE , + method = RequestMethod.GET) + ResponseEntity getAttachmentWithFilename( + @Parameter(description = "Identifier of the ServiceSpecification",required=true) @PathVariable("id") String id, + @Parameter(description = "Identifier of the Attachment",required=true) @PathVariable("attid") String attid, + @Parameter(description = "Identifier of the Filename",required=true) @PathVariable("afilename") String afilename); + + + + @Operation(summary = "Retrieves a ServiceDescriptor by ServiceSpecification ID", operationId = "retrieveServiceSpecificationDescriptor", description = "This operation retrieves a Service Descriptor entity. Attribute selection is enabled for all first level attributes.", tags={ "serviceSpecification", }) + @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 = "/serviceSpecification/{id}/sd", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity retrieveServiceSpecificationDescriptor(@Parameter(description = "Identifier of the ServiceSpecification",required=true) @PathVariable("id") String id); + + @Operation(summary = "Creates a ServiceSpecification from an ServiceTestSpecification id. It retreives the ServicTestSpecification from the ServiceTestSpecification catalog", operationId = "createServiceSpecificationFromServiceTestSpecification", + description = "This operation creates a ServiceSpecification from a ServiceTestSpecification id. It retreives the ServiceTestSpecification from the ServiceTestSpecification catalog. " + + "The response is the Service Spec", tags={ "serviceSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Created" ), + @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 = "/serviceSpecification/specFromTestSpec/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity specFromTestSpec( @Parameter(description = "Identifier of the ServiceTestSpecification id from the ServiceTestSpecification catalog",required=true) @PathVariable("id") String id ); + + + @Operation(summary = "Creates a Resource Facing ServiceSpecification from a ResourceSpecification id. It retreives the ResourceSpecification from the ResourceSpecification catalog", + operationId = "createServiceSpecificationFromResourceSpecification", + description = "This operation creates a Resource Facing ServiceSpecification from a ResourceSpecification id. It retreives the ResourceSpecification from the ResourceSpecification catalog. " + + "The response is the Service Spec", tags={ "serviceSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Created" ), + @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 = "/serviceSpecification/specFromResourceSpec/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + ResponseEntity specFromResourceSpec( @Parameter(description = "Identifier of the ResourceSpecification id from the ResourceSpecification catalog",required=true) @PathVariable("id") String id ); + + + + @Operation(summary = "Get a SVG image with specification relationship graph", operationId = "getImageSpecificationRelationshipGraph", + description = "This operation returns a SVG image with specification relationship graph", tags={ "serviceSpecification", }) + @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 = "/serviceSpecification/{id}/relationship_graph", + produces = MediaType.ALL_VALUE , + method = RequestMethod.GET) + ResponseEntity getImageSpecificationRelationshipGraph( + @Parameter(description = "Identifier of the ServiceSpecification",required=true) @PathVariable("id") String id); +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..12482fb6c40803c28239eb73944481422946567b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiController.java @@ -0,0 +1,369 @@ +/*- + * ========================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.scm633.api; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URI; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.io.IOUtils; +import org.etsi.osl.centrallog.client.CLevel; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.sd.model.ServiceDescriptor; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationUpdate; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.util.AddUserAsOwnerToRelatedParties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.CacheControl; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +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.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-29T19:18:54.771Z") + +@Controller +@RequestMapping("/serviceCatalogManagement/v4/") +@Tag(name = "serviceSpecification", description = "the serviceSpecification API") +public class ServiceSpecificationApiController implements ServiceSpecificationApi { + + private static final Logger log = LoggerFactory.getLogger(ServiceSpecificationApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Autowired + ServiceSpecificationRepoService serviceSpecificationRepoService; + + + @Value("${spring.application.name}") + private String compname; + + + @Value("${kroki.serverurl}") + private String KROKI_SERVERURL = ""; + + @Autowired + private CentralLogger centralLogger; + + @org.springframework.beans.factory.annotation.Autowired + public ServiceSpecificationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity createServiceSpecification( + @Parameter(description = "The ServiceSpecification to be created", required = true) @Valid @RequestBody ServiceSpecificationCreate serviceSpecification) { + try { + + serviceSpecification.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser( + SecurityContextHolder.getContext().getAuthentication().getName(), + SecurityContextHolder.getContext().getAuthentication().getName(), + UserPartRoleType.OWNER, + "", + serviceSpecification.getRelatedParty())); + + ServiceSpecification c = serviceSpecificationRepoService.addServiceSpecification(serviceSpecification); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity deleteServiceSpecification( + @Parameter(description = "Identifier of the ServiceSpecification", required = true) @PathVariable("id") String id) { + try { + + return new ResponseEntity(serviceSpecificationRepoService.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); + } + } + + + public ResponseEntity> listServiceSpecification( + @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) { + + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>( + serviceSpecificationRepoService.findAll( myfields, allParams), HttpStatus.OK); +// return new ResponseEntity>(serviceSpecificationRepoService.findAll(), +// HttpStatus.OK); + + + } else { + + + return new ResponseEntity>( + serviceSpecificationRepoService.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("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity patchServiceSpecification( + @Parameter(description = "Identifier of the ServiceSpecification", required = true) @PathVariable("id") String id, + @Parameter(description = "The ServiceSpecification to be updated", required = true) @Valid @RequestBody ServiceSpecificationUpdate serviceSpecification) { + + ServiceSpecification c = serviceSpecificationRepoService.updateServiceSpecification(id, serviceSpecification); + + return new ResponseEntity(c, HttpStatus.OK); + } + + public ResponseEntity retrieveServiceSpecification( + @Parameter(description = "Identifier of the ServiceSpecification", required = true) @PathVariable("id") String id, + @Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + try { + + return new ResponseEntity(serviceSpecificationRepoService.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); + } + + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + public ResponseEntity cloneServiceSpecification( + @Parameter(description = "Identifier of the ServiceSpecification to clone", required = true) @PathVariable("id") String id) { + + ServiceSpecification c = serviceSpecificationRepoService.cloneServiceSpecification(id); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity addAttachmentToServiceSpecification(String specid, + //@Valid @ModelAttribute("attachment") Attachment att, + @RequestParam(name = "afile") @Valid MultipartFile file, + HttpServletRequest request) { + try { + + //log.info("addAttachmentToServiceSpecification attachment=" + att.toString()); + log.info("addAttachmentToServiceSpecification file=" + file); + + //Attachment att = objectMapper.readValue(attachment, Attachment.class); + //log.info("addAttachmentToServiceSpecification att=" + att); + +// return new ResponseEntity( serviceSpecificationRepoService.findByUuid( id ), HttpStatus.OK); + Attachment c = serviceSpecificationRepoService.addAttachmentToService(specid, file, request.getRequestURI()); + + return new ResponseEntity(c, 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 + @ResponseBody + public ResponseEntity getAttachment(String id, String attid) { + try { + Attachment att; + if ( attid.equals("logo")) { + att = serviceSpecificationRepoService.getAttachmentLogo( id, attid ); + } else { + att = serviceSpecificationRepoService.getAttachment( attid ); + } + + if ( att == null ) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + if ( att.getContent() == null ) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + File file = new File( att.getContent() ); + Path path = Paths.get(file.getAbsolutePath()); + //ByteArrayResource resource = new ByteArrayResource(Files.readAllBytes(path)); + HttpHeaders headers = new HttpHeaders(); + InputStream in = new FileInputStream( file ); + + byte[] media = IOUtils.toByteArray(in); + headers.setCacheControl(CacheControl.noCache().getHeaderValue()); + headers.setContentType( MediaType. parseMediaType( att.getMimeType()) ); + + if ( att.getMimeType().contains("zip") || att.getMimeType().contains("gz")) { + headers.add( "Content-Disposition", "attachment; filename=" + file.getName());//remove this returns directly the object + } + + ResponseEntity responseEntity = new ResponseEntity<>(media, headers, HttpStatus.OK); + return responseEntity; + + +// return ResponseEntity.ok() +// .header("Content-Disposition", "attachment; filename=" + file.getName()) +// .contentLength(file.length()) +// .contentType( MediaType. parseMediaType( att.getMimeType()) )//MediaType.parseMediaType("application/gzip")) +// .body(resource); + + + } catch (Exception e) { + log.error("Couldn't serialize response ByteArrayResource", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + + + @Override + @ResponseBody + public ResponseEntity getAttachmentWithFilename(String id, String attid, String afilename) { + + return getAttachment(id, attid); + } + + + + @Override + public ResponseEntity retrieveServiceSpecificationDescriptor(String id) { + try { + ServiceSpecification spec = serviceSpecificationRepoService.findByUuid(id); + if (spec != null) { + return new ResponseEntity(spec.getServiceDescriptor(), HttpStatus.OK); + } else { + + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity cloneGSTServiceSpecification(String serviceName) { + ServiceSpecification c = serviceSpecificationRepoService.cloneGSTServiceSpecification( serviceName ); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @Override + public ResponseEntity cloneVINNIServiceSpecification(String serviceName, Boolean addServiceTopology, + Boolean addServiceRequirements, Boolean addServiceExposureLevel1, Boolean addServiceExposureLevel2, + Boolean addServiceExposureLevel3, Boolean addServiceExposureLevel4, Boolean addServiceMonitoring, + Boolean addServiceTesting, Boolean addServiceVNF, Boolean addServiceNSD) { + + ServiceSpecification c = serviceSpecificationRepoService.cloneVINNIServiceSpecification(serviceName, + addServiceTopology, + addServiceRequirements, addServiceExposureLevel1, addServiceExposureLevel2, addServiceExposureLevel3, + addServiceExposureLevel4, addServiceMonitoring, addServiceTesting, addServiceVNF, addServiceNSD); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity specFromNSDID(String id) { + List result = serviceSpecificationRepoService.specFromNSDID(id); + ServiceSpecification c = null; + if ( result.size()>0) { + c = result.get(0); //we by default return the first one + } + return new ResponseEntity(c, HttpStatus.OK); + } + + @Override + public ResponseEntity specFromTestSpec(String id) { + ServiceSpecification result = serviceSpecificationRepoService.specFromTestSpec(id); + + return new ResponseEntity( result, HttpStatus.OK); + } + + @Override + public ResponseEntity getImageSpecificationRelationshipGraph(String id) { + + String encodedDiagram = serviceSpecificationRepoService.getImageSpecificationRelationshipGraph(id); + + //consider redirect to kroki..id + return ResponseEntity + .status(HttpStatus.FOUND) + .location(URI.create(KROKI_SERVERURL + "/blockdiag/svg/" + encodedDiagram)) + .build(); + //return null; + } + + @Override + public ResponseEntity specFromResourceSpec(String id) { + ServiceSpecification result = serviceSpecificationRepoService.specFromResourceSpec(id); + return new ResponseEntity( result, HttpStatus.OK); + } + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..8116a38c20479395b44ff0e2e7770f470f5c7f2f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiRouteBuilder.java @@ -0,0 +1,129 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.scm633.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.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.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationUpdate; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.so641.api.ServiceOrderApiRouteBuilder; +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 ServiceSpecificationApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ServiceOrderApiRouteBuilder.class.getName()); + + @Value("${CATALOG_GET_SERVICESPEC_BY_ID}") + private String CATALOG_GET_SERVICESPEC_BY_ID = ""; + + + @Value("${CATALOG_ADD_SERVICESPEC}") + private String CATALOG_ADD_SERVICESPEC = ""; + + + @Value("${CATALOG_UPD_SERVICESPEC}") + private String CATALOG_UPD_SERVICESPEC = ""; + + @Value("${CATALOG_UPDADD_SERVICESPEC}") + private String CATALOG_UPDADD_SERVICESPEC = ""; + + @Value("${NFV_CATALOG_GET_NSD_BY_ID}") + private String NFV_CATALOG_GET_NSD_BY_ID = ""; + + @Value("${CATALOG_UPD_EXTERNAL_SERVICESPEC}") + private String CATALOG_UPD_EXTERNAL_SERVICESPEC = ""; + + @Autowired + ServiceSpecificationRepoService serviceSpecificationRepoService; + + + @Override + public void configure() throws Exception { + + from( CATALOG_GET_SERVICESPEC_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICESPEC_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( serviceSpecificationRepoService, "findByUuidEager") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + from( CATALOG_UPD_EXTERNAL_SERVICESPEC ) + .log(LoggingLevel.INFO, log, CATALOG_UPD_EXTERNAL_SERVICESPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal() + .json(JsonLibrary.Jackson, ServiceSpecification.class, true) + .bean( serviceSpecificationRepoService, "updateExternalServiceSpec(${header.servicespecid}, ${header.orgid}, ${body})") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + from( CATALOG_ADD_SERVICESPEC ) + .log(LoggingLevel.INFO, log, CATALOG_ADD_SERVICESPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ServiceSpecificationCreate .class, true) + .bean( serviceSpecificationRepoService, "addServiceSpecification(${body})") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_UPD_SERVICESPEC ) + .log(LoggingLevel.INFO, log, CATALOG_UPD_SERVICESPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ServiceSpecificationUpdate.class, true) + .bean( serviceSpecificationRepoService, "updateServiceSpecification(${header.serviceSpecId}, ${body} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_UPDADD_SERVICESPEC ) + .log(LoggingLevel.INFO, log, CATALOG_UPD_SERVICESPEC + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ServiceSpecificationUpdate.class, true) + .bean( serviceSpecificationRepoService, "updateOrAddServiceSpecification(${header.serviceSpecId}, ${header.forceId}, ${body} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + } + + + + + + 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/scm633/api/ServiceSpecificationApiRouteBuilderNSD.java b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiRouteBuilderNSD.java new file mode 100644 index 0000000000000000000000000000000000000000..92bfb908ce3a65d0b1d26827027fef208aaa689f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/api/ServiceSpecificationApiRouteBuilderNSD.java @@ -0,0 +1,93 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.scm633.api; + +import java.io.IOException; + +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.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.etsi.osl.model.nfv.NetworkServiceDescriptor; + +@Configuration +//@RefreshScope +@Component +public class ServiceSpecificationApiRouteBuilderNSD extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ServiceSpecificationApiRouteBuilderNSD.class.getName()); + + @Value("${NFV_CATALOG_GET_NSD_BY_ID}") + private String NFV_CATALOG_GET_NSD_BY_ID = ""; + + + @Autowired + private ProducerTemplate template; + + @Override + public void configure() throws Exception { + + + } + + + /** + * get service order by id from model via bus + * @param id + * @return + * @throws IOException + */ + public NetworkServiceDescriptor retrieveNSD( String nsdID) { + logger.info("will retrieve NetworkServiceDescriptor from NSD/VNF catalog nsdID=" + nsdID ); + try { + Object response = template. + requestBody( NFV_CATALOG_GET_NSD_BY_ID, nsdID); + + if ( !(response instanceof String)) { + logger.error("NetworkServiceDescriptor object is wrong."); + return null; + } + NetworkServiceDescriptor sor = toJsonObj( (String)response, NetworkServiceDescriptor.class); + //logger.debug("retrieveServiceOrder response is: " + response); + return sor; + + }catch (Exception e) { + logger.error("Cannot retrieve NetworkServiceDescriptor details from catalog. " + e.toString()); + } + return null; + } + + + + 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/scm633/repo/CandidateRepository.java b/src/main/java/org/etsi/osl/tmf/scm633/repo/CandidateRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..df131d4b69dbc5c10a2a6e9107a8e5a0edab5ca6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/repo/CandidateRepository.java @@ -0,0 +1,39 @@ +/*- + * ========================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.scm633.repo; + +import java.util.Optional; +import org.etsi.osl.tmf.scm633.model.ServiceCandidate; +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 CandidateRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + @Query("SELECT sc FROM ServiceCandidate sc JOIN FETCH sc.serviceSpecificationObj spec WHERE spec.uuid = ?1") + Optional findByServiceSpecUuid(String id); + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/repo/CatalogRepository.java b/src/main/java/org/etsi/osl/tmf/scm633/repo/CatalogRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..4b3ca3061ccddde1a7f08a05ad21f98330a4d26a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/repo/CatalogRepository.java @@ -0,0 +1,42 @@ +/*- + * ========================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.scm633.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.scm633.model.ServiceCatalog; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface CatalogRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Optional findByName(String aName); + + List findByOrderByName(); + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/repo/CategoriesRepository.java b/src/main/java/org/etsi/osl/tmf/scm633/repo/CategoriesRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..da400ead79155f57003d68632f0ff35cdbfafe08 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/repo/CategoriesRepository.java @@ -0,0 +1,41 @@ +/*- + * ========================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.scm633.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface CategoriesRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Optional findByName(String aName); + + List findByOrderByName(); + + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/repo/ServiceSpecificationRepository.java b/src/main/java/org/etsi/osl/tmf/scm633/repo/ServiceSpecificationRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..9a949c5ceb2b4e19837b17b8d1e9751359bb98f1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/repo/ServiceSpecificationRepository.java @@ -0,0 +1,45 @@ +/*- + * ========================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.scm633.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +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 ServiceSpecificationRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + List findByNameAndVersion(String aname, String aversion); + + List findByOrderByName(); + + + @Query("SELECT spec FROM ServiceSpecification spec JOIN FETCH spec.relatedParty party WHERE party.extendedInfo=?1") + Optional findExternalSpecByExternalId(String servicespecid); + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CandidateRepoService.java b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CandidateRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..872a8229686fa2cf112d5769db4efb4f29281068 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CandidateRepoService.java @@ -0,0 +1,171 @@ +/*- + * ========================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.scm633.reposervices; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.scm633.model.ServiceCandidate; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateUpdate; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryRef; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.repo.CandidateRepository; +import org.etsi.osl.tmf.scm633.repo.ServiceSpecificationRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.validation.Valid; + +@Service +public class CandidateRepoService { + + + @Autowired + CandidateRepository candidateRepo; + + @Autowired + CategoryRepoService categsRepoService; + + + @Autowired + ServiceSpecificationRepository serviceSpecificationRepo; + + public ServiceCandidate addServiceCandidate( ServiceCandidate c) { + + return this.candidateRepo.save( c ); + } + + //@Transactional(propagation=Propagation.REQUIRED, readOnly=false, noRollbackFor=Exception.class) + public ServiceCandidate addServiceCandidate(@Valid ServiceCandidateCreate serviceCand) { + + + ServiceCandidate sc = new ServiceCandidate() ; +// if ( serviceCand.getServiceSpecification() != null) { +// Optional optsc = this.candidateRepo.findByServiceSpecUuid(serviceCand.getServiceSpecification().getId()); +// if (optsc.isPresent() ) { +// sc = optsc.get();//add to an existing candidate +// } +// } + + sc = updateServiceCandidateDataFromAPI( sc, serviceCand); + + return this.candidateRepo.save( sc ); + } + + public List findAll() { + return (List) this.candidateRepo.findAll(); + } + + //@Transactional(propagation=Propagation.REQUIRED, readOnly=true, noRollbackFor=Exception.class) + public ServiceCandidate findById(String id) { + Optional optionalCat = this.candidateRepo.findByUuid( id ); + return optionalCat + .orElse(null); + } + + public Void deleteById(String id) { + Optional optionalCat = this.candidateRepo.findByUuid( id ); + if ( !optionalCat.isEmpty() ) { + this.candidateRepo.delete( optionalCat.get()); + } + return null; + + } + + @Transactional + public ServiceCandidate updateCandidate(String id, @Valid ServiceCandidateUpdate serviceCandidate) { + Optional scopt = this.candidateRepo.findByUuid(id); + if ( scopt == null ) { + return null; + } + ServiceCandidate sc = scopt.get(); + + sc = updateServiceCandidateDataFromAPI( sc, serviceCandidate); + + return this.candidateRepo.save( sc ); + } + + + @Transactional + public ServiceCandidate updateServiceCandidateDataFromAPI(ServiceCandidate sc, @Valid ServiceCandidateUpdate serviceCandidateUpd) { + + ServiceSpecification specObj = null; + + if ( serviceCandidateUpd.getServiceSpecification()!=null) { + Optional optionalCat = this.serviceSpecificationRepo.findByUuid( serviceCandidateUpd.getServiceSpecification().getId() ); + specObj = optionalCat.orElse(null); + } + + if ( specObj != null ) { + sc.setName( specObj.getName() ); + sc.setDescription( specObj.getDescription() ); + sc.setLifecycleStatusEnum ( ELifecycle.getEnum( specObj.getLifecycleStatus() ) ); + sc.setVersion( specObj.getVersion() ); + } else { + sc.setName( serviceCandidateUpd.getName() ); + sc.setDescription( serviceCandidateUpd.getDescription() ); + sc.setLifecycleStatusEnum( ELifecycle.LAUNCHED ); + sc.setVersion( serviceCandidateUpd.getVersion()); + } + + sc.setLastUpdate( OffsetDateTime.now(ZoneOffset.UTC) ); + if ( serviceCandidateUpd.getLifecycleStatus() == null ) { + sc.setLifecycleStatusEnum( ELifecycle.LAUNCHED ); + } else { + sc.setLifecycleStatusEnum ( ELifecycle.getEnum( serviceCandidateUpd.getLifecycleStatus() ) ); + } + TimePeriod tp = new TimePeriod(); + + if ( sc.getValidFor() != null ){ + tp.setStartDateTime( sc.getValidFor().getStartDateTime() ); + tp.setEndDateTime( sc.getValidFor().getEndDateTime() ); + } + sc.setValidFor( tp ); + + if ( specObj != null){ + sc.setServiceSpecificationObj( specObj ); + } + + //save first to continue + ServiceCandidate savedCand = this.candidateRepo.save( sc ); + + if ( serviceCandidateUpd.getCategory() !=null ){ + for (ServiceCategoryRef sCategD : serviceCandidateUpd.getCategory()) { + ServiceCategory catObj = this.categsRepoService.findByIdEager(sCategD.getId()); + + if ( catObj!=null){ + catObj.getServiceCandidateObj().add(savedCand); //add candidate ref to category + catObj = this.categsRepoService.categsRepo.save(catObj); + + } + } + } + + + return savedCand; + } + + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CatalogRepoService.java b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CatalogRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..db4c70237acaab21e585f1ce3e41a0fe10b98ec2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CatalogRepoService.java @@ -0,0 +1,145 @@ +/*- + * ========================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.scm633.reposervices; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.scm633.model.ServiceCatalog; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogUpdate; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryRef; +import org.etsi.osl.tmf.scm633.repo.CatalogRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import jakarta.validation.Valid; + +@Service +public class CatalogRepoService { + + + @Autowired + CatalogRepository catalogRepo; + + @Autowired + CategoryRepoService categRepoService; + + @Autowired + ServiceSpecificationRepoService specRepoService; + + @Autowired + CandidateRepoService candidateRepoService; + + public ServiceCatalog addCatalog(ServiceCatalog c) { + + return this.catalogRepo.save(c); + } + + public ServiceCatalog addCatalog(@Valid ServiceCatalogCreate serviceCat) { + + ServiceCatalog sc = new ServiceCatalog(); + + sc = updateCatalogDataFromAPICall(sc, serviceCat); + return this.catalogRepo.save(sc); + } + + public List findAll() { + return (List) this.catalogRepo.findByOrderByName(); + } + + public ServiceCatalog findById(String id) { + Optional optionalCat = this.catalogRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + + public ServiceCatalog findByName(String aName) { + Optional optionalCat = this.catalogRepo.findByName( aName ); + return optionalCat.orElse(null); + } + + public Void deleteById(String id) { + Optional optionalCat = this.catalogRepo.findByUuid(id); + this.catalogRepo.delete(optionalCat.get()); + return null; + + } + + public ServiceCatalog updateCatalog(String id, ServiceCatalogUpdate serviceCatalog) { + + Optional optSC = catalogRepo.findByUuid(id); + if (optSC == null) { + return null; + } + ServiceCatalog sc = optSC.get(); + sc = updateCatalogDataFromAPICall(sc, serviceCatalog); + return this.catalogRepo.save(sc); + } + + public ServiceCatalog updateCatalogDataFromAPICall(ServiceCatalog sc, ServiceCatalogUpdate serviceCatalog) { + + if (serviceCatalog.getName()!=null){ + sc.setName(serviceCatalog.getName()); + } + if (serviceCatalog.getDescription()!=null){ + sc.setDescription(serviceCatalog.getDescription()); + } + if (serviceCatalog.getLifecycleStatus() != null) { + sc.setLifecycleStatusEnum(ELifecycle.getEnum(serviceCatalog.getLifecycleStatus())); + } + if (serviceCatalog.getVersion() != null) { + sc.setVersion(serviceCatalog.getVersion()); + } + sc.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + TimePeriod tp = new TimePeriod(); + if (serviceCatalog.getValidFor() != null) { + tp.setStartDateTime(serviceCatalog.getValidFor().getStartDateTime()); + tp.setEndDateTime(serviceCatalog.getValidFor().getEndDateTime()); + sc.setValidFor(tp); + } + + // add any new category + if (serviceCatalog.getCategory() != null) { + + sc.getCategoryObj().clear(); + for (ServiceCategoryRef scref : serviceCatalog.getCategory()) { + ServiceCategory servcat = this.categRepoService.findByUuid(scref.getId()); + sc.addCategory(servcat); + } + } + + return sc; + + } + + public ServiceCatalog updateCatalog(ServiceCatalog scatalog) { + return this.catalogRepo.save(scatalog); + } + + + + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CategoryRepoService.java b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CategoryRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..cb43791abb4ecb3c54a7414e80badeab7b6b20f6 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/CategoryRepoService.java @@ -0,0 +1,301 @@ +/*- + * ========================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.scm633.reposervices; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.scm633.model.ServiceCandidate; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateRef; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryRef; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryUpdate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharRelationship; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristicValue; +import org.etsi.osl.tmf.scm633.repo.CandidateRepository; +import org.etsi.osl.tmf.scm633.repo.CatalogRepository; +import org.etsi.osl.tmf.scm633.repo.CategoriesRepository; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +@Service +public class CategoryRepoService { + + + @Autowired + CategoriesRepository categsRepo; + + + @Autowired + CandidateRepository candidateRepo; + + + @Autowired + CatalogRepository catalogRepo; + + + private SessionFactory sessionFactory; + + /** + * from https://stackoverflow.com/questions/25063995/spring-boot-handle-to-hibernate-sessionfactory + * @param factory + */ + @Autowired + public CategoryRepoService(EntityManagerFactory factory) { + if(factory.unwrap(SessionFactory.class) == null){ + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + + public ServiceCategory addCategory(ServiceCategory c) { + + return this.categsRepo.save( c ); + } + + public ServiceCategory addCategory(@Valid ServiceCategoryCreate serviceCategory) { + + + ServiceCategory sc = new ServiceCategory() ; + sc = updateCategoryDataFromAPICall(sc, serviceCategory); + return this.categsRepo.save( sc ); + + } + + public List findAll() { + return (List) this.categsRepo.findByOrderByName(); + } + + public ServiceCategory findByUuid(String id) { + Optional optionalCat = this.categsRepo.findByUuid( id ); + return optionalCat + .orElse(null); + } + + + public ServiceCategory findByIdEager(String id) { +// Optional optionalCat = this.categsRepo.findByIdEager( id ); +// return optionalCat +// .orElse(null); + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + ServiceCategory dd = null; + try { + dd = (ServiceCategory) session.get(ServiceCategory.class, id); + Hibernate.initialize( dd.getCategoryObj() ); + Hibernate.initialize( dd.getServiceCandidateObj() ); + for (ServiceCandidate sc : dd.getServiceCandidateObj()) { + Hibernate.initialize(sc ); + Hibernate.initialize(sc.getCategoryObj() ); + Hibernate.initialize(sc.getServiceSpecificationObj() ); + Hibernate.initialize(sc.getServiceSpecificationObj().getServiceSpecCharacteristic() ); + for (ServiceSpecCharacteristic ssc : sc.getServiceSpecificationObj().getServiceSpecCharacteristic() ) { + Hibernate.initialize(ssc.getServiceSpecCharRelationship() ); + for (ServiceSpecCharRelationship srel : ssc.getServiceSpecCharRelationship() ) { + Hibernate.initialize( srel ); + } + Hibernate.initialize(ssc.getServiceSpecCharacteristicValue() ); + for (ServiceSpecCharacteristicValue srel : ssc.getServiceSpecCharacteristicValue() ) { + Hibernate.initialize( srel ); + } + } + Hibernate.initialize(sc.getServiceSpecificationObj().getServiceSpecRelationship() ); + } + + tx.commit(); + } finally { + session.close(); + } + return dd; + } + + + + + + public boolean deleteById(String id) { + Optional optionalCat = this.categsRepo.findByUuid( id ); + if ( optionalCat.get().getCategoryObj().size()>0 ) { + return false; //has children + } + + + if ( optionalCat.get().getParentId() != null ) { + ServiceCategory parentCat = (this.categsRepo.findByUuid( optionalCat.get().getParentId() )).get(); + + //remove from parent category + for (ServiceCategory ss : parentCat.getCategoryObj()) { + if ( ss.getId() == optionalCat.get().getId() ) { + parentCat.getCategoryObj().remove(ss); + break; + } + } + parentCat = this.categsRepo.save(parentCat); + } + + + this.categsRepo.delete( optionalCat.get()); + return true; + + } + + public ServiceCategory updateCategory(String id, @Valid ServiceCategoryUpdate serviceCategory) { + Optional optionalCat = this.categsRepo.findByUuid( id ); + if ( optionalCat == null ) { + return null; + } + + ServiceCategory sc = optionalCat.get(); + sc = updateCategoryDataFromAPICall(sc, serviceCategory); + return this.categsRepo.save( sc ); + } + + public ServiceCategory updateCategoryDataFromAPICall( ServiceCategory sc, ServiceCategoryUpdate serviceCatUpd ) + { + if (serviceCatUpd.getName()!=null) { + sc.setName( serviceCatUpd.getName() ); + } + if (serviceCatUpd.getDescription()!=null) { + sc.setDescription( serviceCatUpd.getDescription()); + } + if ( serviceCatUpd.isIsRoot() != null ) { + sc.setIsRoot( serviceCatUpd.isIsRoot()); + } + + if ( serviceCatUpd.getLifecycleStatus() != null ) { + sc.setLifecycleStatusEnum ( ELifecycle.getEnum( serviceCatUpd.getLifecycleStatus() ) ); + } + + + if ( serviceCatUpd.getVersion() != null ) { + sc.setVersion( serviceCatUpd.getVersion() ); + } + sc.setLastUpdate( OffsetDateTime.now(ZoneOffset.UTC) ); + TimePeriod tp = new TimePeriod(); + if ( serviceCatUpd.getValidFor() != null ) { + tp.setStartDateTime( serviceCatUpd.getValidFor().getStartDateTime() ); + tp.setEndDateTime( serviceCatUpd.getValidFor().getEndDateTime() ); + sc.setValidFor( tp ); + } + + if ( serviceCatUpd.getCategory() !=null ) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ServiceCategoryRef ref : serviceCatUpd.getCategory() ) { + //find by id and reload it here. + boolean idexists = false; + for (ServiceCategory originalSCat : sc.getCategoryObj()) { + if ( originalSCat.getId().equals( ref.getId())) { + idexists = true; + idAddedUpdated.put( originalSCat.getId(), true); + break; + } + } + if (!idexists) { + Optional catToAdd = this.categsRepo.findByUuid( ref.getId() ); + if ( catToAdd.isPresent() ) { + ServiceCategory scatadd = catToAdd.get(); + sc.getCategoryObj().add( scatadd ); + idAddedUpdated.put( ref.getId(), true); + + scatadd.setParentId( sc.getUuid()); + scatadd = this.categsRepo.save( scatadd ); + } + } + } + List toRemove = new ArrayList<>(); + for (ServiceCategory ss : sc.getCategoryObj()) { + if ( idAddedUpdated.get( ss.getId() ) == null ) { + toRemove.add(ss); + } + } + + for (ServiceCategory ar : toRemove) { + sc.getCategoryObj().remove(ar); + } + } + + + if ( serviceCatUpd.getServiceCandidate() !=null ) { + //reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ServiceCandidateRef ref : serviceCatUpd.getServiceCandidate() ) { + //find by id and reload it here. + boolean idexists = false; + for (ServiceCandidate originalSCat : sc.getServiceCandidateObj()) { + if ( originalSCat.getId().equals( ref.getId())) { + idexists = true; + idAddedUpdated.put( originalSCat.getId(), true); + break; + } + } + if (!idexists) { + Optional catToAdd = this.candidateRepo.findByUuid( ref.getId() ); + if ( catToAdd.isPresent() ) { + ServiceCandidate scatadd = catToAdd.get(); + sc.getServiceCandidateObj().add( scatadd ); + idAddedUpdated.put( ref.getId(), true); + + } + } + } + List toRemove = new ArrayList<>(); + for (ServiceCandidate ss : sc.getServiceCandidateObj()) { + if ( idAddedUpdated.get( ss.getId() ) == null ) { + toRemove.add(ss); + } + } + + for (ServiceCandidate ar : toRemove) { + sc.getServiceCandidateObj().remove(ar); + } + } + + return sc; + } + + + public ServiceCategory findByName(String aName) { + Optional optionalCat = this.categsRepo.findByName( aName ); + return optionalCat + .orElse(null); + } + + +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..f2a517266d56a3334fbf812e3806a5a4ede9b5ed --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java @@ -0,0 +1,1464 @@ +/*- + * ========================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.scm633.reposervices; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.common.model.AttachmentRef; +import org.etsi.osl.tmf.common.model.ELifecycle; +import org.etsi.osl.tmf.common.model.EValueType; +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; +import org.etsi.osl.tmf.pcm620.reposervices.AttachmentRepoService; +import org.etsi.osl.tmf.pm632.model.Organization; +import org.etsi.osl.tmf.pm632.reposervices.OrganizationRepoService; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristic; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristicValue; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.scm633.api.ServiceSpecificationApiRouteBuilderNSD; +import org.etsi.osl.tmf.scm633.model.ServiceCandidate; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateUpdate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristicValue; +import org.etsi.osl.tmf.scm633.model.ServiceSpecRelationship; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationUpdate; +import org.etsi.osl.tmf.scm633.repo.ServiceSpecificationRepository; +import org.etsi.osl.tmf.stm653.model.CharacteristicSpecification; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecification; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationUpdate; +import org.etsi.osl.tmf.stm653.reposervices.ServiceTestSpecificationRepoService; +import org.etsi.osl.tmf.util.AttachmentUtil; +import org.etsi.osl.tmf.util.KrokiClient; +import org.etsi.osl.tmf.util.PrimitivesParser; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.transform.ResultTransformer; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import org.etsi.osl.model.nfv.ConstituentVxF; +import org.etsi.osl.model.nfv.ExperimentOnBoardDescriptor; +import org.etsi.osl.model.nfv.NetworkServiceDescriptor; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +/** + * @author ctranoris + * + */ +@Service +@Transactional +public class ServiceSpecificationRepoService { + + private static final transient Log logger = LogFactory.getLog(ServiceSpecificationRepoService.class.getName()); + + @Autowired + ObjectMapper objectMapper; + + @Autowired + ServiceSpecificationRepository serviceSpecificationRepo; + + @Autowired + CandidateRepoService candidateRepoService; + + @Autowired + AttachmentRepoService attachmentRepoService; + + + @Autowired + ResourceSpecificationRepoService resourceSpecRepoService; + + @Autowired + ServiceSpecificationApiRouteBuilderNSD serviceSpecificationApiRouteBuilder; + + + @Autowired + OrganizationRepoService organizationRepoService; + + + @Autowired + ServiceTestSpecificationRepoService serviceTestSpecificationRepoService; + + private SessionFactory sessionFactory; + + private static final String METADATADIR = System.getProperty("user.home") + File.separator + ".attachments" + + File.separator + "metadata" + File.separator; + + @Autowired + public ServiceSpecificationRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + + + public ServiceSpecification addServiceSpecification(@Valid ServiceSpecificationCreate serviceServiceSpecification) { + + ServiceSpecification serviceSpec = new ServiceSpecification(); + + serviceSpec = this.updateServiceSpecDataFromAPIcall(serviceSpec, serviceServiceSpecification); + serviceSpec = this.serviceSpecificationRepo.save(serviceSpec); + serviceSpec.fixSpecCharRelationhsipIDs(); + + /** + * we automatically create s Service Candidate for this spec ready to be + * attached to categories + */ + @Valid + ServiceCandidateCreate serviceCandidate = new ServiceCandidateCreate(); + ServiceSpecificationRef serviceSpecificationRef = new ServiceSpecificationRef(); + serviceCandidate.setServiceSpecification(serviceSpecificationRef); + serviceSpecificationRef.setId(serviceSpec.getId()); + ServiceCandidate serviceCandidateObj = candidateRepoService.addServiceCandidate(serviceCandidate); + + serviceSpec.setServiceCandidateObjId(serviceCandidateObj.getUuid()); + + return this.serviceSpecificationRepo.save(serviceSpec); + } + + public List findAll() { + return (List) this.serviceSpecificationRepo.findByOrderByName(); + } + + /** + * + * This findAll is optimized on fields. + * @param fields + * @param allParams + * @return + * @throws UnsupportedEncodingException + */ + @Transactional + public List findAll(@Valid String fields, Map allParams) + throws UnsupportedEncodingException { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { +// String sql = "SELECT s FROM ServiceSpecification s"; + String sql = "SELECT " + + "s.uuid as uuid," + + "s.id as id," + + "s.name as name," + + "s.description as description," + + "s.isBundle as isBundle," + + "s.version as version," + + "s.type as type"; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", s." + f + " as " + f ; + } + + } + sql += " FROM ServiceSpecification s"; + if (allParams.size() > 0) { + sql += " WHERE "; + for (String pname : allParams.keySet()) { + sql += " " + pname + " LIKE "; + String pval = URLDecoder.decode(allParams.get(pname), StandardCharsets.UTF_8.toString()); + sql += "'" + pval + "'"; + } + + } + sql += " ORDER BY s.name"; + + + + List mapaEntity = session + .createQuery(sql ) + .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("type")) { + alias = "@type"; + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + + } + +// @Transactional(propagation=Propagation.REQUIRED , readOnly=true, +// noRollbackFor=Exception.class) + public ServiceSpecification findByUuid(String id) { + Optional optionalCat = this.serviceSpecificationRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + @Transactional + public ServiceSpecification findByUuidEager(String id) { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); // instead of begin transaction, is it possible to continue? + try { + ServiceSpecification dd = null; + try { + dd = session.get(ServiceSpecification.class, id); + if (dd == null) { + return this.findByUuid(id);// last resort + } + Hibernate.initialize(dd.getAttachment()); + Hibernate.initialize(dd.getRelatedParty()); + Hibernate.initialize(dd.getResourceSpecification()); + Hibernate.initialize(dd.getServiceLevelSpecification()); + Hibernate.initialize(dd.getServiceSpecCharacteristic()); + for (ServiceSpecCharacteristic schar : dd.getServiceSpecCharacteristic()) { + Hibernate.initialize(schar.getServiceSpecCharacteristicValue()); + Hibernate.initialize(schar.getServiceSpecCharRelationship()); + + } + Hibernate.initialize(dd.getServiceSpecRelationship()); + + tx.commit(); + } finally { + session.close(); + } + return dd; + + } catch (Exception e) { + e.printStackTrace(); + } + + session.close(); + return null; + + + } + + public Void deleteByUuid(String id) { + Optional optionalCat = this.serviceSpecificationRepo.findByUuid(id); + ServiceSpecification s = optionalCat.get(); + if (s == null) { + return null; + } + + // ServiceCandidate scopt = + // this.candidateRepoService.findById(s.getServiceCandidateObjId()); + this.candidateRepoService.deleteById(s.getServiceCandidateObjId()); + + /** + * prior deleting we need to delete other dependency objects + */ + + this.serviceSpecificationRepo.delete(s); + return null; + } + + + /** + * @param id + * @param forceId + * @param serviceServiceSpecificationCreate + * @return + */ + @Transactional + public ServiceSpecification updateOrAddServiceSpecification(String id, + @Valid ServiceSpecificationCreate serviceServiceSpecificationCreate) { + + ServiceSpecification serviceSpec = updateServiceSpecification(id, serviceServiceSpecificationCreate ); + if ( serviceSpec == null ) { + serviceSpec = addServiceSpecification( serviceServiceSpecificationCreate ); + } + + return serviceSpec; + } + + + @Transactional + public ServiceSpecification updateServiceSpecification(String id, + @Valid ServiceSpecificationUpdate serviceServiceSpecification) { + + ServiceSpecification s = this.findByUuid(id); + if (s == null) { + return null; + } + ServiceSpecification serviceSpec = s; + serviceSpec = this.updateServiceSpecDataFromAPIcall(serviceSpec, serviceServiceSpecification); + + serviceSpec = this.serviceSpecificationRepo.save(serviceSpec); + serviceSpec.fixSpecCharRelationhsipIDs(); + + //save the equivalent candidate + ServiceCandidate serviceCandidateObj = candidateRepoService.findById( serviceSpec.getServiceCandidateObjId() ); + if ( serviceCandidateObj!=null) { + ServiceCandidateUpdate serviceCandidateUpd = new ServiceCandidateUpdate(); + serviceCandidateUpd.setName( serviceSpec.getName() ); + serviceCandidateUpd.setDescription( serviceSpec.getDescription() ); + serviceCandidateUpd.setLifecycleStatus( serviceSpec.getLifecycleStatus() ); + serviceCandidateUpd.setVersion( serviceSpec.getVersion() ); + candidateRepoService.updateCandidate( serviceCandidateObj.getId(), serviceCandidateUpd); + } else { + ServiceCandidateCreate serviceCandidate = new ServiceCandidateCreate(); + ServiceSpecificationRef serviceSpecificationRef = new ServiceSpecificationRef(); + serviceCandidate.setServiceSpecification(serviceSpecificationRef); + serviceSpecificationRef.setId(serviceSpec.getId()); + serviceCandidateObj = candidateRepoService.addServiceCandidate(serviceCandidate); + serviceSpec.setServiceCandidateObjId(serviceCandidateObj.getUuid()); + } + + return this.serviceSpecificationRepo.save(serviceSpec); + + } + + @Transactional + private ServiceSpecification updateServiceSpecDataFromAPIcall(ServiceSpecification serviceSpec, + ServiceSpecificationUpdate serviceSpecUpd) { + + + + if (serviceSpecUpd.getName() != null) { + serviceSpec.setName(serviceSpecUpd.getName()); + } + + if (serviceSpecUpd.getDescription() != null) { + serviceSpec.setDescription(serviceSpecUpd.getDescription()); + + } + + if (serviceSpecUpd.isIsBundle() != null) { + serviceSpec.isBundle(serviceSpecUpd.isIsBundle()); + + } + + serviceSpec.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + + + if (serviceSpecUpd.getLifecycleStatus() != null) { + serviceSpec.setLifecycleStatusEnum(ELifecycle.getEnum(serviceSpecUpd.getLifecycleStatus())); + } + + if (serviceSpecUpd.getVersion() != null) { + serviceSpec.setVersion(serviceSpecUpd.getVersion()); + } + + /** + * Update Attachment list + */ + if (serviceSpecUpd.getAttachment() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (AttachmentRef ar : serviceSpecUpd.getAttachment()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (AttachmentRef orinalAtt : serviceSpec.getAttachment()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + serviceSpec.getAttachment().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (AttachmentRef ss : serviceSpec.getAttachment()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (AttachmentRef ar : toRemove) { + serviceSpec.getAttachment().remove(ar); + } + + } + + + + + + /** + * Update ServiceSpecCharacteristic list We need to compare by name, since IDs + * will not exist + */ + if (serviceSpecUpd.getServiceSpecCharacteristic() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (ServiceSpecCharacteristic charUpd : serviceSpecUpd.getServiceSpecCharacteristic()) { + + boolean nameExists = false; + for (ServiceSpecCharacteristic originalSpecChar : serviceSpec.getServiceSpecCharacteristic()) { + if (originalSpecChar.getName()!=null && charUpd.getName()!=null && originalSpecChar.getName().equals(charUpd.getName())) { + nameExists = true; + idAddedUpdated.put(originalSpecChar.getName(), true); + originalSpecChar.updateWith(charUpd); + break; + } + } + + if (!nameExists) { + serviceSpec.getServiceSpecCharacteristic().add(new ServiceSpecCharacteristic(charUpd)); + if ( charUpd.getName() == null ) { + charUpd.setName( UUID.randomUUID().toString() ); + } + idAddedUpdated.put(charUpd.getName(), true); + } + + } + + List toRemove = new ArrayList<>(); + for (ServiceSpecCharacteristic ss : serviceSpec.getServiceSpecCharacteristic()) { + if (idAddedUpdated.get(ss.getName()) == null) { + toRemove.add(ss); + } + } + + for (ServiceSpecCharacteristic serviceSpecCharacteristic : toRemove) { + serviceSpec.getServiceSpecCharacteristic().remove(serviceSpecCharacteristic); + } + + } + + /** + * Update RelatedParty list + */ + if (serviceSpecUpd.getRelatedParty() != null) { + // reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (RelatedParty rp : serviceSpecUpd.getRelatedParty()) { + + boolean idexists = false; + for (RelatedParty originalRP : serviceSpec.getRelatedParty()) { + if (originalRP.getId().equals(rp.getId())) { + idexists = true; + idAddedUpdated.put(originalRP.getId(), true); + break; + } + } + if (!idexists) { + serviceSpec.getRelatedParty().add(rp); + idAddedUpdated.put(rp.getId(), true); + } + } + List toRemove = new ArrayList<>(); + for (RelatedParty ss : serviceSpec.getRelatedParty()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (RelatedParty ar : toRemove) { + serviceSpec.getRelatedParty().remove(ar); + } + } + + /** + * Update ServiceSpecRelationship list + */ + + if (serviceSpecUpd.getServiceSpecRelationship() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ServiceSpecRelationship ar : serviceSpecUpd.getServiceSpecRelationship()) { + // find ServiceSpecRelationship by id and reload it here. + // we need the ServiceSpecRelationship model from spec models + boolean idexists = false; + for (ServiceSpecRelationship orinalAtt : serviceSpec.getServiceSpecRelationship()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + serviceSpec.getServiceSpecRelationship().add(ar); + idAddedUpdated.put(ar.getId(), true); + + /** + * Also, + * we will add by default all the characteristics of this service to the related bundle parent service + * Removed to try new approach with rules + */ + + //serviceSpec = copyCharacteristicsOfServiceId( ar.getId(), serviceSpec); + + } + } + + List toRemove = new ArrayList<>(); + for (ServiceSpecRelationship ss : serviceSpec.getServiceSpecRelationship()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (ServiceSpecRelationship ar : toRemove) { + serviceSpec.getServiceSpecRelationship().remove(ar); + } + + } + + /** + * Update ResourceSpecification list + */ + if (serviceSpecUpd.getResourceSpecification() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ResourceSpecificationRef ar : serviceSpecUpd.getResourceSpecification()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (ResourceSpecificationRef orinalAtt : serviceSpec.getResourceSpecification()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + serviceSpec.getResourceSpecification().add(ar); + idAddedUpdated.put(ar.getId(), true); + + /** + * Also, + * we will add by default all the characteristics of this rSpec to the related bundle parent service + */ + serviceSpec = copyCharacteristicsOfResourceSpecId( ar.getId(), serviceSpec); + } + } + + List toRemove = new ArrayList<>(); + for (ResourceSpecificationRef ss : serviceSpec.getResourceSpecification()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (ResourceSpecificationRef ar : toRemove) { + serviceSpec.getResourceSpecification().remove(ar); + } + + } + + /** + * Update ServiceLevelSpecification list + */ + if (serviceSpecUpd.getServiceLevelSpecification() != null) { + serviceSpec.getServiceLevelSpecification().clear(); + serviceSpec.getServiceLevelSpecification().addAll(serviceSpecUpd.getServiceLevelSpecification()); + } + + TimePeriod tp = new TimePeriod(); + if (serviceSpecUpd.getValidFor() != null) { + tp.setStartDateTime(serviceSpecUpd.getValidFor().getStartDateTime()); + tp.setEndDateTime(serviceSpecUpd.getValidFor().getEndDateTime()); + serviceSpec.setValidFor(tp); + } + + if (serviceSpec.getResourceSpecification().size() > 0) { + serviceSpec.setType("ResourceFacingServiceSpecification"); + } else if ( serviceSpecUpd.getType() != null) { + serviceSpec.setType( serviceSpecUpd.getType() ); + } else + { + serviceSpec.setType("CustomerFacingServiceSpecification"); + } + + + String charvalue = createGraphNotation( serviceSpec ); + ServiceSpecCharacteristic gnchar = serviceSpec.findSpecCharacteristicByName("SSPEC_GRAPH_NOTATION"); + if ( gnchar == null ) { + gnchar = addServiceSpecCharacteristic(serviceSpec, "SSPEC_GRAPH_NOTATION", "SSPEC_GRAPH_NOTATION", new Any( charvalue , "SSPEC_GRAPH_NOTATION" ), EValueType.LONGTEXT); + } else { + gnchar.getServiceSpecCharacteristicValue().stream().findFirst().get().setValue( new Any( charvalue , "SSPEC_GRAPH_NOTATION" ) ); + } + + + return serviceSpec; + } + + /** + * @param sourceServiceSpecid + * @param targetServiceSpec + * @return the targetServiceSpec with the copied characteristics + */ + private ServiceSpecification copyCharacteristicsOfServiceId(String sourceServiceSpecid, ServiceSpecification targetServiceSpec) { + + ServiceSpecification sourceSpec = this.findByUuid(sourceServiceSpecid); + if ( sourceSpec != null ) { + for (ServiceSpecCharacteristic ssc : sourceSpec.getServiceSpecCharacteristic()) { + ServiceSpecCharacteristic cnew = new ServiceSpecCharacteristic(ssc); + cnew.setName( sourceSpec.getName() +"::"+ cnew.getName() ); //:: is used as delimiter + + if ( targetServiceSpec.findSpecCharacteristicByName( cnew.getName() ) == null ) { + targetServiceSpec.getServiceSpecCharacteristic().add( cnew ); + } + + } + } + + return targetServiceSpec; + } + + private ServiceSpecification copyCharacteristicsOfResourceSpecId(String sourceResourceSpecid, ServiceSpecification targetServiceSpec) { + + ResourceSpecification rSpec = resourceSpecRepoService.findByUuid( sourceResourceSpecid ); + + if ( rSpec != null ) { + for (ResourceSpecificationCharacteristic sourceChar : rSpec.getResourceSpecCharacteristic()) { + ServiceSpecCharacteristic serviceSpecCharacteristicItem = copyResourceCharacteristic( sourceChar ); + //serviceSpecCharacteristicItem.setName( rSpec.getName() + "::" +sourceChar.getName() ); + serviceSpecCharacteristicItem.setName( sourceChar.getName() ); + + if ( targetServiceSpec.findSpecCharacteristicByName( serviceSpecCharacteristicItem.getName() ) == null ) { + targetServiceSpec.getServiceSpecCharacteristic().add( serviceSpecCharacteristicItem ); + } + } + } + + return targetServiceSpec; + } + + public ServiceSpecification cloneServiceSpecification(String uuid) { + ServiceSpecification source = this.findByUuid(uuid); + + + + ServiceSpecification dest = new ServiceSpecification(source); + + dest.setName("Copy of " + dest.getName()); + dest.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + dest.setLifecycleStatusEnum(ELifecycle.IN_STUDY); +// +// dest = this.serviceSpecificationRepo.save(dest); // save to get uuids +// dest.fixSpecCharRelationhsipIDs(); // fix charRels. this is specific to +// // our solution on cloning +// dest = this.serviceSpecificationRepo.save(dest); // and resave + + return addServiceSpecification( dest ); + } + + public Attachment addAttachmentToService(String id, + //@Valid Attachment attachment, + @Valid MultipartFile afile, + String urlpath) { + Optional s = this.serviceSpecificationRepo.findByUuid(id); + if (s.get() == null) { + return null; + } + + ServiceSpecification spec = s.get(); + Attachment att = new Attachment(); + att = this.attachmentRepoService.addAttachment(att); + att.setMimeType(afile.getContentType()); + + + String tempDir = METADATADIR + spec.getId() + "/attachments/" + att.getId() + File.separator; + + try { + Files.createDirectories(Paths.get(tempDir)); + String aFileNamePosted = afile.getOriginalFilename();// AttachmentUtil.getFileName(image.getHeaders()); + logger.info("aFileNamePosted = " + aFileNamePosted); + // If there is an icon name + if (!aFileNamePosted.equals("")) { + // Save the icon File + String targetfile = AttachmentUtil.saveFile(afile, tempDir); + logger.info("afile saved to = " + targetfile); + att.setContent(targetfile); + att.setName(aFileNamePosted); + // Save the file destination + urlpath = urlpath.replace("tmf-api/", ""); + att.setUrl( urlpath + "/" + att.getId() + "/" + + aFileNamePosted); + att = this.attachmentRepoService.updateAttachment( att ); + } + } catch (IOException e) { + e.printStackTrace(); + return null; + } + + AttachmentRef attref = new AttachmentRef(); + attref.setId(att.getId()); + attref.setDescription(att.getDescription()); + attref.setUrl(att.getUrl()); + attref.setName(att.getName()); + + spec.addAttachmentItem(attref); + this.serviceSpecificationRepo.save(spec); + + + return att; + } + + + public Attachment getAttachment(String attid) { + + return this.attachmentRepoService.findByUuid( attid ); + + } + + public Attachment getAttachmentLogo(String specid, String attid) { + + ServiceSpecification spec = this.findByUuid( specid ); + for (AttachmentRef att : spec.getAttachment()) { + if ( att.getName().contains("logo")) { + return this.attachmentRepoService.findByUuid( att.getId() ); + } + } + + return null; + + } + + + public ServiceSpecification findByNameAndVersion(String aname, String aversion) { + + List optionalCat = this.serviceSpecificationRepo.findByNameAndVersion(aname, + aversion); + if ( ( optionalCat !=null) && ( optionalCat.size()>0) ) { + return optionalCat.get(0); + } else { + return null; + } + } + + // @Transactional(propagation=Propagation.REQUIRED , readOnly=true, + // noRollbackFor=Exception.class) + public ServiceSpecification addServiceSpecification(ServiceSpecification c) { + + @Valid + ServiceSpecificationCreate serviceServiceSpecificationCr = new ServiceSpecificationCreate(); + + serviceServiceSpecificationCr.setName(c.getName()); + serviceServiceSpecificationCr.setDescription(c.getDescription()); + //serviceServiceSpecificationCr.setAttachment(new ArrayList<>(c.getAttachment())); + serviceServiceSpecificationCr.setIsBundle(c.isIsBundle()); + serviceServiceSpecificationCr.setRelatedParty(new ArrayList<>(c.getRelatedParty())); + serviceServiceSpecificationCr.setResourceSpecification(new ArrayList<>(c.getResourceSpecification())); + serviceServiceSpecificationCr.setServiceLevelSpecification(new ArrayList<>(c.getServiceLevelSpecification())); + serviceServiceSpecificationCr.setServiceSpecCharacteristic(new ArrayList<>(c.getServiceSpecCharacteristic())); + serviceServiceSpecificationCr.setServiceSpecRelationship(new ArrayList<>(c.getServiceSpecRelationship())); + serviceServiceSpecificationCr.setVersion(c.getVersion()); + serviceServiceSpecificationCr.setValidFor(new TimePeriod()); + + if (c.getType() != null) { + serviceServiceSpecificationCr.setType( c.getType() ); + } + + return this.addServiceSpecification(serviceServiceSpecificationCr); + + } + + public ServiceSpecification updateServiceSpecification(ServiceSpecification c) { + + @Valid + ServiceSpecificationUpdate serviceServiceSpecificationCr = new ServiceSpecificationUpdate(); + + serviceServiceSpecificationCr.setName(c.getName()); + serviceServiceSpecificationCr.setDescription(c.getDescription()); + serviceServiceSpecificationCr.setAttachment(new ArrayList<>(c.getAttachment())); + serviceServiceSpecificationCr.setIsBundle(c.isIsBundle()); + serviceServiceSpecificationCr.setServiceSpecRelationship(new ArrayList<>(c.getServiceSpecRelationship())); + serviceServiceSpecificationCr.setRelatedParty(new ArrayList<>(c.getRelatedParty())); + serviceServiceSpecificationCr.setResourceSpecification(new ArrayList<>(c.getResourceSpecification())); + serviceServiceSpecificationCr.setServiceLevelSpecification(new ArrayList<>(c.getServiceLevelSpecification())); + serviceServiceSpecificationCr.setServiceSpecCharacteristic(new ArrayList<>(c.getServiceSpecCharacteristic())); + serviceServiceSpecificationCr.setVersion(c.getVersion()); + + if (c.getType() != null) { + serviceServiceSpecificationCr.setType( c.getType() ); + } + + return this.updateServiceSpecification(c.getId(), serviceServiceSpecificationCr); + +// if (spec.getResourceSpecification().size() > 0) { +// spec.setType("ResourceFacingServiceSpecification"); +// } else { +// spec.setType("CustomerFacingServiceSpecification"); +// } +// return this.serviceSpecificationRepo.save( spec ); +// + } + + public ServiceSpecification cloneGSTServiceSpecification() { + return this.cloneGSTServiceSpecification(null); + } + + public ServiceSpecification cloneGSTServiceSpecification(String specName) { + + ServiceSpecification serviceSpecificationObj = readFromLocalResource( "gst.json" ); + serviceSpecificationObj.setName(specName); + serviceSpecificationObj = this.addServiceSpecification(serviceSpecificationObj); + return serviceSpecificationObj; + } + + public ServiceSpecification cloneVINNIServiceSpecification(Boolean addServiceTopology, + Boolean addServiceRequirements, Boolean addServiceExposureLevel1, Boolean addServiceExposureLevel2, + Boolean addServiceExposureLevel3, Boolean addServiceExposureLevel4, Boolean addServiceMonitoring, + Boolean addServiceTesting, Boolean addServiceVNF, Boolean addServiceNSD) { + + return this.cloneVINNIServiceSpecification(null, addServiceTopology, addServiceRequirements, + addServiceExposureLevel1, addServiceExposureLevel2, addServiceExposureLevel3, addServiceExposureLevel4, + addServiceMonitoring, addServiceTesting, addServiceVNF, addServiceNSD); + } + + public ServiceSpecification cloneVINNIServiceSpecification(String specName, Boolean addServiceTopology, + Boolean addServiceRequirements, Boolean addServiceExposureLevel1, Boolean addServiceExposureLevel2, + Boolean addServiceExposureLevel3, Boolean addServiceExposureLevel4, Boolean addServiceMonitoring, + Boolean addServiceTesting, Boolean addServiceVNF, Boolean addServiceNSD) { + + /** + * Create the VINNI-SB as Bundle from file + */ + + + ServiceSpecification serviceSpecVinniSB = readFromLocalResource("vinnisb/vinnisb.json"); + if ( specName!= null ){ + serviceSpecVinniSB.setName(specName); + } + logger.info( "specRepoService size = " + this.findAll().size() ); + serviceSpecVinniSB = this.addServiceSpecification(serviceSpecVinniSB); + logger.info( "specRepoService size = " + this.findAll().size() ); + + for (ServiceSpecification ss : this.findAll()) { + logger.info( "ss id = " + ss.getId() ); + } + logger.info( "serviceSpecVinniSB.getUuid() = " + serviceSpecVinniSB.getUuid() ); + + serviceSpecVinniSB = this.updateServiceSpecification(serviceSpecVinniSB); + serviceSpecVinniSB = this.findByUuidEager( serviceSpecVinniSB.getUuid()); + + /** + * Create RFS + * 1: Create Resource Spec NS Topology + * + */ + if ( addServiceTopology ){ + ResourceSpecification resourceNSTopology = new LogicalResourceSpecification(); + resourceNSTopology.setName( specName + "-" + "NS Topology"); + resourceNSTopology.setVersion( serviceSpecVinniSB.getVersion() ); + ResourceSpecificationCharacteristic resourceSpecCharacteristicItem = new ResourceSpecificationCharacteristic(); + resourceSpecCharacteristicItem.setName("Network Slice name"); + resourceSpecCharacteristicItem.setDescription("Network Slice Name on target NFVO"); + resourceSpecCharacteristicItem.setValueType( EValueType.TEXT.getValue() ); + ResourceSpecificationCharacteristicValue resourceSpecCharacteristicValueItem = new ResourceSpecificationCharacteristicValue(); + resourceSpecCharacteristicValueItem.setValue( new Any("SLICENAME", "The Network slice name")); + resourceSpecCharacteristicItem.addResourceSpecCharacteristicValueItem(resourceSpecCharacteristicValueItem); + resourceNSTopology.addResourceSpecCharacteristicItem(resourceSpecCharacteristicItem); + + resourceNSTopology = resourceSpecRepoService.addResourceSpec( resourceNSTopology ); + /** + * 2: Create Service Topology related to resourceSpec + */ + ServiceSpecification serviceTopology = new ServiceSpecification(); + serviceTopology.setName( specName + "-" +"Service Topology"); + serviceTopology.setDescription( "Service Topology related to a Resource Specification"); + ResourceSpecificationRef resourceSpecificationItemRef = new ResourceSpecificationRef(); + resourceSpecificationItemRef.setId( resourceNSTopology.getId() ); + resourceSpecificationItemRef.setName( resourceNSTopology.getName() ); + resourceSpecificationItemRef.setVersion(resourceNSTopology.getVersion() ); + serviceTopology.addResourceSpecificationItem(resourceSpecificationItemRef); + serviceTopology = this.addServiceSpecification( serviceTopology ); + /** + * ad to vinni sb + */ + ServiceSpecRelationship serviceSpecRelationshipItem =new ServiceSpecRelationship(); + serviceSpecRelationshipItem.setId( serviceTopology.getId()); + serviceSpecRelationshipItem.setName( serviceTopology.getName() ); + serviceSpecVinniSB.addServiceSpecRelationshipItem( serviceSpecRelationshipItem ); + this.copyCharacteristicsOfServiceId( serviceSpecRelationshipItem.getId() , serviceSpecVinniSB); + serviceSpecVinniSB = this.updateServiceSpecification(serviceSpecVinniSB); + } + + + + /** + * Create Service Requirements + */ + if ( addServiceRequirements ){ + ServiceSpecification serviceReq = readFromLocalResource("vinnisb/vinnisb-req.json"); + serviceReq.setName( specName + "-" +serviceReq.getName() ); + serviceReq = this.addServiceSpecification(serviceReq); + ServiceSpecRelationship relServiceReq =new ServiceSpecRelationship(); + relServiceReq.setId( serviceReq.getId()); + relServiceReq.setName( serviceReq.getName() ); + serviceSpecVinniSB.addServiceSpecRelationshipItem( relServiceReq ); + this.copyCharacteristicsOfServiceId( relServiceReq.getId() , serviceSpecVinniSB); + serviceSpecVinniSB = this.updateServiceSpecification(serviceSpecVinniSB); + } + + + /** + * Create Service Exposure Level 1 + */ + if ( addServiceExposureLevel1 ){ + ServiceSpecification serviceExpLevel = readFromLocalResource("vinnisb/vinnisb-exposure-L1.json"); + serviceExpLevel.setName( specName + "-" +serviceExpLevel.getName() ); + serviceExpLevel = this.addServiceSpecification( serviceExpLevel ); + ServiceSpecRelationship relServiceExp =new ServiceSpecRelationship(); + relServiceExp.setId( serviceExpLevel.getId()); + relServiceExp.setName( serviceExpLevel.getName() ); + serviceSpecVinniSB.addServiceSpecRelationshipItem( relServiceExp ); + this.copyCharacteristicsOfServiceId( relServiceExp.getId() , serviceSpecVinniSB); + serviceSpecVinniSB = this.updateServiceSpecification(serviceSpecVinniSB); + } + + /** + * Create Service Exposure Level 2 + */ + if ( addServiceExposureLevel2 ){ + ServiceSpecification serviceExpLevel = readFromLocalResource("vinnisb/vinnisb-exposure-L2.json"); + serviceExpLevel.setName( specName + "-" +serviceExpLevel.getName() ); + serviceExpLevel = this.addServiceSpecification( serviceExpLevel ); + ServiceSpecRelationship relServiceExp =new ServiceSpecRelationship(); + relServiceExp.setId( serviceExpLevel.getId()); + relServiceExp.setName( serviceExpLevel.getName() ); + serviceSpecVinniSB.addServiceSpecRelationshipItem( relServiceExp ); + this.copyCharacteristicsOfServiceId( relServiceExp.getId() , serviceSpecVinniSB); + serviceSpecVinniSB = this.updateServiceSpecification(serviceSpecVinniSB); + } + + /** + * Create Service Exposure Level 3 + */ + if ( addServiceExposureLevel3 ){ + ServiceSpecification serviceExpLevel = readFromLocalResource("vinnisb/vinnisb-exposure-L3.json"); + serviceExpLevel.setName( specName + "-" +serviceExpLevel.getName() ); + serviceExpLevel = this.addServiceSpecification( serviceExpLevel ); + ServiceSpecRelationship relServiceExp =new ServiceSpecRelationship(); + relServiceExp.setId( serviceExpLevel.getId()); + relServiceExp.setName( serviceExpLevel.getName() ); + serviceSpecVinniSB.addServiceSpecRelationshipItem( relServiceExp ); + this.copyCharacteristicsOfServiceId( relServiceExp.getId() , serviceSpecVinniSB); + serviceSpecVinniSB = this.updateServiceSpecification(serviceSpecVinniSB); + } + + /** + * Create Service Exposure Level 4 + */ + if ( addServiceExposureLevel4 ){ + ServiceSpecification serviceExpLevel = readFromLocalResource("vinnisb/vinnisb-exposure-L4.json"); + serviceExpLevel.setName( specName + "-" +serviceExpLevel.getName() ); + serviceExpLevel = this.addServiceSpecification( serviceExpLevel ); + ServiceSpecRelationship relServiceExp =new ServiceSpecRelationship(); + relServiceExp.setId( serviceExpLevel.getId()); + relServiceExp.setName( serviceExpLevel.getName() ); + serviceSpecVinniSB.addServiceSpecRelationshipItem( relServiceExp ); + this.copyCharacteristicsOfServiceId( relServiceExp.getId() , serviceSpecVinniSB); + serviceSpecVinniSB = this.updateServiceSpecification(serviceSpecVinniSB); + } + + /** + * Create Service Monitoring + */ + if ( addServiceMonitoring ){ + ServiceSpecification serviceMon = readFromLocalResource("vinnisb/vinnisb-monitoring.json"); + serviceMon.setName( specName + "-" + serviceMon.getName() ); + serviceMon = this.addServiceSpecification( serviceMon ); + ServiceSpecRelationship relServiceMon =new ServiceSpecRelationship(); + relServiceMon.setId( serviceMon.getId()); + relServiceMon.setName( serviceMon.getName() ); + serviceSpecVinniSB.addServiceSpecRelationshipItem( relServiceMon ); + this.copyCharacteristicsOfServiceId( relServiceMon.getId() , serviceSpecVinniSB); + serviceSpecVinniSB = this.updateServiceSpecification(serviceSpecVinniSB); + + } + + /** + * Create Service Testing + */ + + if ( addServiceTesting ){ + ServiceSpecification serviceTesting = readFromLocalResource("vinnisb/vinnisb-testing.json"); + serviceTesting.setName( specName + "-" + serviceTesting.getName() ); + serviceTesting = this.addServiceSpecification( serviceTesting ); + ServiceSpecRelationship relServiceTest =new ServiceSpecRelationship(); + relServiceTest.setId( serviceTesting.getId()); + relServiceTest.setName( serviceTesting.getName() ); + serviceSpecVinniSB.addServiceSpecRelationshipItem( relServiceTest ); + this.copyCharacteristicsOfServiceId( relServiceTest.getId() , serviceSpecVinniSB); + serviceSpecVinniSB = this.updateServiceSpecification(serviceSpecVinniSB); + + } + + + /** + * Create 3rd party VNF related to resourceSpec + */ + if ( addServiceVNF ){ + ServiceSpecification thirdVNF = new ServiceSpecification(); + thirdVNF.setName( specName + "-" +"3rd party VNF"); + ResourceSpecificationRef resourceSpecificationthirdVNFRef = new ResourceSpecificationRef(); + resourceSpecificationthirdVNFRef.setId( null ); + resourceSpecificationthirdVNFRef.setName( thirdVNF.getName() ); + thirdVNF.addResourceSpecificationItem(resourceSpecificationthirdVNFRef); + this.copyCharacteristicsOfServiceId( resourceSpecificationthirdVNFRef.getId() , serviceSpecVinniSB); + thirdVNF = this.addServiceSpecification( thirdVNF ); + + + } + /** + * Create 3rd party NSD related to resourceSpec + */ + if ( addServiceNSD ){ + ServiceSpecification thirdNSD = new ServiceSpecification(); + thirdNSD.setName( specName + "-" +"3rd party NSD"); + ResourceSpecificationRef resourceSpecificationthirdNSDRef = new ResourceSpecificationRef(); + resourceSpecificationthirdNSDRef.setId( null ); + resourceSpecificationthirdNSDRef.setName(thirdNSD.getName() ); + thirdNSD.addResourceSpecificationItem(resourceSpecificationthirdNSDRef); + this.copyCharacteristicsOfServiceId( resourceSpecificationthirdNSDRef.getId() , serviceSpecVinniSB); + thirdNSD = this.addServiceSpecification( thirdNSD ); + } + + + return serviceSpecVinniSB; + } + + + private ServiceSpecification readFromLocalResource(String rname) { + ServiceSpecification sc; + try { + sc = objectMapper.readValue(new ClassPathResource( rname ).getInputStream(), ServiceSpecification.class); + + return sc; + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } + + /** + * The NSD is retrieved from the catalog via ActiveMQ. + * it will create a Resource Spec based on the NSD object + * It will create a Service Spec (RFS) which references the above Resource Spec + * + * @param id the NSD id + * @return a ServiceSpecification + */ + public List specFromNSDID(String id) { + + NetworkServiceDescriptor nsd = serviceSpecificationApiRouteBuilder.retrieveNSD(id); + if (nsd == null) { + logger.error("nsdid return null"); + return null; + } + + logger.debug("nsdid returned: " + nsd.getName()); + + List newRfservices = new ArrayList<>(); + + /** + * for each OnBoardDescriptor we need to create a resource, because each resource will be an NSD on a specific OSM + */ + + for (ExperimentOnBoardDescriptor eobd : nsd.getExperimentOnBoardDescriptors()) { + ResourceSpecification resourceNSD = new LogicalResourceSpecification(); + resourceNSD.setName( nsd.getName() ); + resourceNSD.setVersion( nsd.getVersion() ); + resourceNSD.setDescription(nsd.getShortDescription()); + resourceNSD = resourceSpecRepoService.addResourceSpec( resourceNSD ); + /** + * add here characteristics + */ + + /** + * 2: Create Service related to resourceSpec + */ + ServiceSpecification serviceSpec = new ServiceSpecification(); + serviceSpec.setName( nsd.getName()+'@'+eobd.getObMANOprovider().getName() ); + serviceSpec.setVersion( nsd.getVersion() ); + serviceSpec.setDescription( nsd.getShortDescription() ); + addServiceSpecCharacteristic(serviceSpec, "PackagingFormat", "NSD PackagingFormat", new Any(nsd.getPackagingFormat().toString(), "PackagingFormat"), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "PackageLocation", "NSD PackageLocation", new Any(nsd.getPackageLocation() , "PackageLocation"), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "Vendor", "NSD Vendor", new Any(nsd.getVendor() , "Vendor"), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "OSM_NSDCATALOGID", "NSD Onboarded MANO provider Name", new Any( eobd.getDeployId() , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "NSDID", "NSD id", new Any(nsd.getId()+"" , "id"), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "MANOproviderName", "NSD Onboarded MANO provider Name", new Any( eobd.getObMANOprovider().getName() , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "MANOproviderID", "NSD Onboarded MANO provider Name", new Any( eobd.getObMANOprovider().getId() , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "OnBoardDescriptorID", "NSD Onboarded MANO provider Name", new Any( eobd.getId() , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "OnBoardDescriptorUUID", "NSD Onboarded MANO provider Name", new Any( eobd.getUuid() , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "OnBoardingStatus", "NSDtOnBoardingStatus", new Any( eobd.getOnBoardingStatus().name() , ""), EValueType.TEXT); + + addServiceSpecCharacteristic(serviceSpec, "SSHKEY", "SSH public key", new Any("" , ""), EValueType.TEXT); + String osmconfig = "{\"nsdId\":\"" + eobd.getDeployId() + "\"}"; + if ( eobd.getObMANOprovider().getVims() != null && eobd.getObMANOprovider().getVims().get(0) != null ) { + osmconfig = "{\"nsdId\":\"" + eobd.getDeployId() + "\", \"vimAccountId\":\"" + eobd.getObMANOprovider().getVims().get(0).getVIMid() + "\"}"; + } + + + addServiceSpecCharacteristic(serviceSpec, "OSM_CONFIG", "Initial config to OSM", new Any( osmconfig , ""), EValueType.TEXT); + + addServiceSpecCharacteristic(serviceSpec, "DeploymentRequestID", "DeploymentRequestID", new Any( "" , ""), EValueType.TEXT); + + addServiceSpecCharacteristic(serviceSpec, "Status", "Status", new Any( "" , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "OperationalStatus", "OperationalStatus", new Any( "" , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "ConstituentVnfrIps", "ConstituentVnfrIps", new Any( "" , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "ConfigStatus", "ConfigStatus", new Any( "" , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "APPLY_CONFIG", "APPLY_CONFIG", new Any( "" , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "InstanceId", "InstanceId", new Any( "" , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "NSR", "NSR", new Any( "" , ""), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "NSLCM", "NSLCM", new Any( "" , ""), EValueType.TEXT); + + + + if ( nsd.getConstituentVxF() != null ) { + for (ConstituentVxF cv : nsd.getConstituentVxF()) { + addServiceSpecCharacteristic(serviceSpec, "MemberVNFIndex_"+cv.getMembervnfIndex(), "Member VNF Index", new Any( cv.getMembervnfIndex() +"" , cv.getVnfdidRef()), EValueType.TEXT); + addServiceSpecCharacteristic(serviceSpec, "VNFINDEXREF_INFO_" +cv.getMembervnfIndex() , "Member VNF Index info", new Any( "" , ""), EValueType.TEXT); + } + } else { + + logger.error("nsdid getConstituentVxF null returned: " + nsd.toString() ); + } + + /******************** Begin Primitives Handling ********************/ + + JSONObject allPrimitives = PrimitivesParser.extractPrimitives(nsd); + + addServiceSpecCharacteristic(serviceSpec, "PrimitivesList", "NSPrimitives", new Any(allPrimitives.toString(), ""), EValueType.TEXT); + + /********************* End Primitives Handling *********************/ + + + ResourceSpecificationRef resourceSpecificationItemRef = new ResourceSpecificationRef(); + resourceSpecificationItemRef.setId( resourceNSD.getId() ); + resourceSpecificationItemRef.setName( resourceNSD.getName() ); + resourceSpecificationItemRef.setVersion(resourceNSD.getVersion() ); + + serviceSpec.addResourceSpecificationItem(resourceSpecificationItemRef); + serviceSpec = this.addServiceSpecification( serviceSpec ); + + newRfservices.add(serviceSpec); + + } + + + + return newRfservices; + } + + /** + * @param serviceSpec + * @param name + * @return + */ + private ServiceSpecCharacteristic addServiceSpecCharacteristic(ServiceSpecification serviceSpec, String aName, String description, Any any, EValueType eValueType) { + ServiceSpecCharacteristic serviceSpecCharacteristicItem = new ServiceSpecCharacteristic(); + serviceSpecCharacteristicItem.setName( aName ); + serviceSpecCharacteristicItem.setDescription(description); + serviceSpecCharacteristicItem.valueType( eValueType.getValue() ); + serviceSpecCharacteristicItem.configurable(false); + serviceSpecCharacteristicItem.setMinCardinality(1); + serviceSpecCharacteristicItem.setMaxCardinality(1); + ServiceSpecCharacteristicValue serviceSpecCharacteristicValueItem = new ServiceSpecCharacteristicValue(); + serviceSpecCharacteristicValueItem.setValue( new Any( any.getValue() , any.getAlias())); + serviceSpecCharacteristicValueItem.isDefault( true ); + serviceSpecCharacteristicValueItem.setUnitOfMeasure("N/A"); + serviceSpecCharacteristicItem.addServiceSpecCharacteristicValueItem(serviceSpecCharacteristicValueItem ); + serviceSpec.addServiceSpecCharacteristicItem(serviceSpecCharacteristicItem ); + return serviceSpecCharacteristicItem; + } + + + /** + * @param servicespecid of ID of external service spec + * @param orgid + * @param spec + * @return + */ + public ServiceSpecification updateExternalServiceSpec(String servicespecid, + String orgid, + @Valid ServiceSpecification spec) { + Optional resultq = this.serviceSpecificationRepo.findExternalSpecByExternalId( servicespecid ); + ServiceSpecification specToUpdate = resultq.orElse(null); + + /** + * we need to do a massage here before properly importing it + */ + + spec.getRelatedParty().clear();//clear all related parties if any + spec.getAttachment().clear(); + spec.getResourceSpecification().clear(); + spec.getServiceLevelSpecification().clear(); + spec.getServiceSpecRelationship().clear(); + for (ServiceSpecCharacteristic schar : spec.getServiceSpecCharacteristic()) { + schar.setUuid( null );//in case it exists + } + + + + if ( specToUpdate == null ) { + RelatedParty relatedPartyItem = new RelatedParty(); + Organization o =organizationRepoService.findById( orgid ); + relatedPartyItem.setId( o.getId() ); + relatedPartyItem.name( o.getName() ); + relatedPartyItem.setRole(UserPartRoleType.ORGANIZATION.getValue()); + /** + * Note: the following Extended Info will be used to identify the Service Spec + * in remote catalog + */ + relatedPartyItem.setExtendedInfo( servicespecid ); + spec.addRelatedPartyItem(relatedPartyItem ); + return this.addServiceSpecification( spec ); + } else { + spec.setUuid( specToUpdate.getId() ); + spec.setRelatedParty( specToUpdate.getRelatedParty() );//remove it so not to update the related parties + return this.updateServiceSpecification( spec ); + } + + + } + + public ServiceSpecification specFromTestSpec(String id) { + ServiceTestSpecification testSpec = serviceTestSpecificationRepoService.findByUuid(id); + if (testSpec == null) { + logger.error("specFromTestSpec return null"); + return null; + } + + + /** + * 1: Create Service Spec related to ServiceTestSpecification + */ + ServiceSpecification serviceSpec = new ServiceSpecification(); + serviceSpec.setName( testSpec.getName() ); + serviceSpec.setVersion( testSpec.getVersion() ); + serviceSpec.setDescription( testSpec.getDescription() ); + + addServiceSpecCharacteristic(serviceSpec, "testSpecRef", "testSpecRef", new Any( testSpec.getId() , testSpec.getId() ), EValueType.TEXT); + + for (CharacteristicSpecification sourceChar : testSpec.getSpecCharacteristic()) { + addServiceSpecCharacteristic(serviceSpec, + sourceChar.getName(), + sourceChar.getDescription() , new Any( "" , ""), EValueType.TEXT); + + } + + + serviceSpec = this.addServiceSpecification( serviceSpec ); + + ServiceSpecificationRef serviceSpecRef = new ServiceSpecificationRef(); + serviceSpecRef.setId(serviceSpec.getId()); + @Valid + ServiceTestSpecificationUpdate stUpd = new ServiceTestSpecificationUpdate(); + stUpd.addRelatedServiceSpecificationItem( serviceSpecRef ); + + serviceTestSpecificationRepoService.updateServiceTestSpecification(id, stUpd ); + + return serviceSpec; + } + + private String createGraphNotation( ServiceSpecification serviceSpec ) { + String result = getSpecGraphNotation(serviceSpec, 0 ); + result = "blockdiag {" + + "default_textcolor = white;\r\n" + + "default_fontsize = 12;\r\n" + + "\r\n" + result + "}"; + return result; + } + + private String getSpecGraphNotation( ServiceSpecification serviceSpec, int depth ) { + String result = ""; + if (depth>10) { + return result; + } + for (ServiceSpecRelationship specRel : serviceSpec.getServiceSpecRelationship()) { + result += "\""+ serviceSpec.getId() + "\""+ " -> " + "\""+ specRel.getId() +"\" "+";\r\n"; + ServiceSpecification aSpec= this.findByUuid( specRel.getId() ); + if ( aSpec!= null) { + result += getSpecGraphNotation( aSpec, depth ++ ); + } + } + for (ResourceSpecificationRef resRel : serviceSpec.getResourceSpecification() ) { + + result += "\""+ serviceSpec.getId() + "\""+ " -> " + "\""+ resRel.getId() + "\""+ ";\r\n"; + result += "\""+ resRel.getId() + "\""+ " [ label = \""+ resRel.getName() +"\", shape = roundedbox, color = \"#e28743\"]; "; + + } + result += "\""+ serviceSpec.getId() + "\""+ " [ label = \""+ serviceSpec.getName() +"\", color = \"#2596be\"]; "; + return result; + } + + public String getImageSpecificationRelationshipGraph(String id) { + + //it is good to update the graph + //ServiceSpecification aSpec= this.findByUuid( id ); + ServiceSpecificationUpdate serviceServiceSpecificationUpd = new ServiceSpecificationUpdate(); + ServiceSpecification aSpec = this.updateServiceSpecification( id, serviceServiceSpecificationUpd ); + + String graph = null; + if ( aSpec != null ) { + ServiceSpecCharacteristic gnchar = aSpec.findSpecCharacteristicByName("SSPEC_GRAPH_NOTATION"); + if ( gnchar != null ) { + graph = gnchar.getServiceSpecCharacteristicValue().stream().findFirst().get().getValue().getValue(); + + } + } + + return KrokiClient.encodedGraph(graph); + + + } + + + + public ServiceSpecification specFromResourceSpec(String id) { + ResourceSpecification rSpec = resourceSpecRepoService.findByUuid(id); + if (rSpec == null) { + logger.error("specFromResourceSpec return null"); + return null; + } + + + /** + * 1: Create Service Spec related to ResourceSpecification + */ + ServiceSpecification serviceSpec = new ServiceSpecification(); + serviceSpec.setName( rSpec.getName() ); + serviceSpec.setVersion( rSpec.getVersion() ); + serviceSpec.setDescription( rSpec.getDescription() ); + serviceSpec.setType("ResourceFacingServiceSpecification"); + + + + for (ResourceSpecificationCharacteristic sourceChar : rSpec.getResourceSpecCharacteristic()) { + ServiceSpecCharacteristic serviceSpecCharacteristicItem = copyResourceCharacteristic( sourceChar ); +// serviceSpecCharacteristicItem.setName( rSpec.getName() + "::" +sourceChar.getName() ); + serviceSpec.addServiceSpecCharacteristicItem(serviceSpecCharacteristicItem ); + } + + + ResourceSpecificationRef resourceSpecRef = new ResourceSpecificationRef(); + resourceSpecRef.setId( rSpec.getId()); + + serviceSpec = this.addServiceSpecification( serviceSpec ); + + + + return serviceSpec; + } + + private ServiceSpecCharacteristic copyResourceCharacteristic( ResourceSpecificationCharacteristic sourceChar ) { + + ServiceSpecCharacteristic serviceSpecCharacteristicItem = new ServiceSpecCharacteristic(); + serviceSpecCharacteristicItem.setDescription( sourceChar.getDescription()); + serviceSpecCharacteristicItem.valueType( sourceChar.getValueType() ); + serviceSpecCharacteristicItem.configurable(sourceChar.isConfigurable()); + serviceSpecCharacteristicItem.setMinCardinality( sourceChar.getMinCardinality() ); + serviceSpecCharacteristicItem.setMaxCardinality( sourceChar.getMaxCardinality() ); + serviceSpecCharacteristicItem.setValidFor( sourceChar.getValidFor() ); + for (ResourceSpecificationCharacteristicValue cv : sourceChar.getResourceSpecCharacteristicValue()) { + ServiceSpecCharacteristicValue serviceSpecCharacteristicValueItem = new ServiceSpecCharacteristicValue(); + serviceSpecCharacteristicValueItem.setValue( new Any( cv.getValue().getValue(), cv.getValue().getAlias())); + serviceSpecCharacteristicValueItem.isDefault( cv.isIsDefault() ); + serviceSpecCharacteristicValueItem.setUnitOfMeasure( cv.getUnitOfMeasure() ); + serviceSpecCharacteristicItem.addServiceSpecCharacteristicValueItem(serviceSpecCharacteristicValueItem ); + } + return serviceSpecCharacteristicItem; + } + + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/sim638/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..54f0c2255ed8a713c0056ef7374eb1e65e2c50c8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.sim638.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +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/sim638/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..ca7a41ff2fd400b9e8a47ddf6727366706e4b5f0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================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.sim638.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.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +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/sim638/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..6229976a28a7441c9f95886de9f4fae245f97d77 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================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.sim638.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +@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/sim638/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/sim638/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..744d47fa3a1b4e26f80b4c9fc2beb18528c0ba0d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.sim638.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.sim638.model.EventSubscription; +import org.etsi.osl.tmf.sim638.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sim638/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/sim638/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..cd7c8053444d7e65a95e83d2b8924826d909e74b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.sim638.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +@Controller("HubApiController638") +@RequestMapping("/serviceInventory/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sim638/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..9f22b493061112266fd90197f6140e0f9838ebf4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ListenerApi.java @@ -0,0 +1,224 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.sim638.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.sim638.model.EventSubscription; +import org.etsi.osl.tmf.sim638.model.ServiceAttributeValueChangeNotification; +import org.etsi.osl.tmf.sim638.model.ServiceBatchNotification; +import org.etsi.osl.tmf.sim638.model.ServiceCreateNotification; +import org.etsi.osl.tmf.sim638.model.ServiceDeleteNotification; +import org.etsi.osl.tmf.sim638.model.ServiceStateChangeNotification; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity ServiceAttributeValueChangeNotification", operationId = "listenToServiceAttributeValueChangeNotification", description = "Example of a client listener for receiving the notification ServiceAttributeValueChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceAttributeValueChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceAttributeValueChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceAttributeValueChangeNotification data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceBatchNotification", operationId = "listenToServiceBatchNotification", description = "Example of a client listener for receiving the notification ServiceBatchNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceBatchNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceBatchNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceBatchNotification data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceCreateNotification", operationId = "listenToServiceCreateNotification", description = "Example of a client listener for receiving the notification ServiceCreateNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceCreateNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceCreateNotification data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceDeleteNotification", operationId = "listenToServiceDeleteNotification", description = "Example of a client listener for receiving the notification ServiceDeleteNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceDeleteNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceDeleteNotification data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceStateChangeNotification", operationId = "listenToServiceStateChangeNotification", description = "Example of a client listener for receiving the notification ServiceStateChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceStateChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceStateChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceStateChangeNotification data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sim638/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..2647db9920e2a06bc25b0e17b14251c16f76b81b --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.sim638.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +@Controller("ListenerApiController638") +@RequestMapping("/serviceInventory/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sim638/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/sim638/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..f33716cc1b934d6970ceded8969d260e19f88664 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/NotFoundException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.sim638.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +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/sim638/api/RFC3339DateFormat.java b/src/main/java/org/etsi/osl/tmf/sim638/api/RFC3339DateFormat.java new file mode 100644 index 0000000000000000000000000000000000000000..7059d81b6ef2512f572ad662c4b1873549af0b97 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/RFC3339DateFormat.java @@ -0,0 +1,41 @@ +/*- + * ========================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.sim638.api; + +import java.text.FieldPosition; +import java.util.Date; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + + +public class RFC3339DateFormat extends ISO8601DateFormat { + + private static final long serialVersionUID = 1L; + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApi.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApi.java new file mode 100644 index 0000000000000000000000000000000000000000..31c7c81cff55ffe1eb86c29775e8ce3ae6952c11 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApi.java @@ -0,0 +1,173 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.sim638.api; + +import java.security.Principal; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +@Tag(name = "service", description = "the service API") +public interface ServiceApi { + + Logger log = LoggerFactory.getLogger(ServiceApi.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 Service", operationId = "createService", description = "This operation creates a Service entity.", tags={ "service", }) + @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 = "/service", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createService( + Principal principal, + @Parameter(description = "The Service to be created" ,required=true ) @Valid @RequestBody ServiceCreate service) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a Service", operationId = "deleteService", description = "This operation deletes a Service entity.", tags={ "service", }) + @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 = "/service/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteService(@Parameter(description = "Identifier of the Service",required=true) @PathVariable("id") String id) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find Service objects", operationId = "listService", description = "This operation list or find Service entities" , tags={ "service", }) + @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 = "/service", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listService( + 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) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a Service", operationId = "patchService", description = "This operation updates partially a Service entity.", tags={ "service", }) + @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 = "/service/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchService( + Principal principal, + @Parameter(description = "Identifier of the Service",required=true) @PathVariable("id") String id,@Parameter(description = "The Service to be updated" ,required=true ) @Valid @RequestBody ServiceUpdate service) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a Service by ID", operationId = "retrieveService", description = "This operation retrieves a Service entity. Attribute selection is enabled for all first level attributes.", tags={ "service", }) + @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 = "/service/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveService( + Principal principal, + @Parameter(description = "Identifier of the Service",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiController.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..ac5ee19bc3ab6b14baff64f96a69a4369a84ff56 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiController.java @@ -0,0 +1,176 @@ +/*- + * ========================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.sim638.api; + +import java.security.Principal; +import java.util.HashMap; +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import org.etsi.osl.tmf.util.AddUserAsOwnerToRelatedParties; +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.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; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:12:41.682+03:00") + +@Controller("ServiceApiController638") +@RequestMapping("/serviceInventory/v4/") +public class ServiceApiController implements ServiceApi { + + private static final Logger log = LoggerFactory.getLogger(ServiceApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Autowired + ServiceRepoService serviceRepoService; + + @org.springframework.beans.factory.annotation.Autowired + public ServiceApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity createService(Principal principal, @Valid ServiceCreate service) { + try { + if (SecurityContextHolder.getContext().getAuthentication() != null) { + service.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser(principal.getName(), principal.getName(), + UserPartRoleType.REQUESTER, "", service.getRelatedParty())); + + Service c = serviceRepoService.addService(service); + + return new ResponseEntity(c, HttpStatus.OK); + } else { + + return new ResponseEntity(HttpStatus.FORBIDDEN); + } + + } catch (Exception e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity deleteService(String id) { + return ServiceApi.super.deleteService(id); + } + + @Override + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + public ResponseEntity> listService(Principal principal, @Valid String fields, @Valid Integer offset, + @Valid Integer limit) { + try { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + + + + if ( authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) ) ) { + return new ResponseEntity>(serviceRepoService.findAll(null, new HashMap<>()), HttpStatus.OK); + //return new ResponseEntity>(serviceOrderRepoService.findAll(null, new HashMap<>()), HttpStatus.OK); + }else { + return new ResponseEntity>(serviceRepoService.findAll( principal.getName(), UserPartRoleType.REQUESTER ), HttpStatus.OK); + //return new ResponseEntity>(serviceOrderRepoService.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); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity patchService(Principal principal, String id, @Valid ServiceUpdate service) { + Service c = serviceRepoService.updateService(id, service, true, null, null); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity retrieveService(Principal principal, String id, @Valid String fields) { + try { + + return new ResponseEntity(serviceRepoService.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); + } + } + + +// @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) +// @RequestMapping(value = "/service/updateServiceDeploymentDescriptor/{id}", +// produces = { "application/json;charset=utf-8" }, +// method = RequestMethod.GET) +// public ResponseEntity updateServiceDeploymentDescriptor( +// Principal principal, +// @Parameter(description = "Identifier of the Service",required=true) @PathVariable("id") String id,@Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { +// +// try { +// +// @Valid +// DeploymentDescriptor dd = new DeploymentDescriptor(); +// dd.setId( Long.parseLong(id) ); +// dd.setNs_nslcm_details("NEW NSLCM updated"); +// dd.setNsr("new nsr updated"); +// serviceRepoService.nfvCatalogNSResourceChanged(dd ); +// +// +// var aservices = serviceRepoService.findDeploymentRequestID( id ); +// for (org.etsi.osl.tmf.sim638.model.Service as : aservices) { +// +// Service aService = serviceRepoService.getServiceEager( as.getId() ); +// return new ResponseEntity(aService, HttpStatus.OK); +// } +// +// } catch (Exception e) { +// log.error("Couldn't serialize response for content type application/json", e); +// +// return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); +// } +// return null; +// } + +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..93afc976d554ffe86976320a3e0d56fd7b591191 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilder.java @@ -0,0 +1,261 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.sim638.api; + +import java.io.IOException; +import java.util.Date; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.camel.Exchange; +import org.apache.camel.LoggingLevel; +import org.apache.camel.Processor; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.RuntimeCamelException; +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.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.etsi.osl.tmf.sim638.model.ServiceActionQueueItem; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +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.etsi.osl.model.nfv.DeploymentDescriptor; +import org.etsi.osl.model.nfv.ExperimentMetadata; +import org.etsi.osl.model.nfv.Product; +import org.etsi.osl.model.nfv.ValidationJob; +import org.etsi.osl.model.nfv.ValidationStatus; +import org.etsi.osl.model.nfv.VxFMetadata; + +@Configuration +//@RefreshScope +@Component +public class ServiceApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ServiceApiRouteBuilder.class.getName()); + + + @Value("${CATALOG_ADD_SERVICE}") + private String CATALOG_ADD_SERVICE = ""; + + @Value("${CATALOG_UPD_SERVICE}") + private String CATALOG_UPD_SERVICE = ""; + + @Value("${CATALOG_GET_SERVICE_BY_ID}") + private String CATALOG_GET_SERVICE_BY_ID = ""; + + @Value("${CATALOG_GET_SERVICE_BY_ORDERID}") + private String CATALOG_GET_SERVICE_BY_ORDERID = ""; + + + @Value("${CATALOG_SERVICE_QUEUE_ITEMS_GET}") + private String CATALOG_SERVICE_QUEUE_ITEMS_GET = ""; + + @Value("${CATALOG_SERVICE_QUEUE_ITEM_UPD}") + private String CATALOG_SERVICE_QUEUE_ITEM_UPD = ""; + + @Value("${CATALOG_SERVICE_QUEUE_ITEM_DELETE}") + private String CATALOG_SERVICE_QUEUE_ITEM_DELETE = ""; + + @Value("${EVENT_SERVICE_CREATE}") + private String EVENT_SERVICE_CREATE = ""; + + + @Value("${CATALOG_SERVICES_TO_TERMINATE}") + private String CATALOG_SERVICES_TO_TERMINATE = ""; + + @Value("${CATALOG_SERVICES_OF_PARTNERS}") + private String CATALOG_SERVICES_OF_PARTNERS = ""; + + + @Value("${NFV_CATALOG_NS_LCMCHANGED}") + private String NFV_CATALOG_NS_LCMCHANGED = ""; + + + //services care to take this event in case they are related to a specific resource (see CRs) + @Value("${EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED}") + private String EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED = ""; + + //services care to take this event in case they are related to a specific resource (see CRs) + @Value("${EVENT_RESOURCE_STATE_CHANGED}") + private String EVENT_RESOURCE_STATE_CHANGED = ""; + + + @Value("${EVENT_RESOURCE_CREATE}") + private String EVENT_RESOURCE_CREATE = ""; + + @Autowired + private ProducerTemplate template; + + @Autowired + ServiceRepoService serviceRepoService; + + @Override + public void configure() throws Exception { + + + + + from( CATALOG_ADD_SERVICE ) + .log(LoggingLevel.INFO, 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})") + .marshal().json( JsonLibrary.Jackson) + .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!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( serviceRepoService, "getServiceEagerAsString") + .convertBodyTo( String.class ); + + + + from( CATALOG_UPD_SERVICE ) + .log(LoggingLevel.INFO, 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} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + + from( CATALOG_SERVICE_QUEUE_ITEMS_GET ) + .log(LoggingLevel.INFO, 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!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ServiceActionQueueItem.class, true) + .bean( serviceRepoService, "updateServiceActionQueueItem(${body})") + .marshal().json( JsonLibrary.Jackson) + .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!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ServiceActionQueueItem.class, true) + .bean( serviceRepoService, "deleteServiceActionQueueItemByUuid(${header.itemid})"); + + + + from( CATALOG_SERVICES_TO_TERMINATE ) + .log(LoggingLevel.INFO, 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) + .convertBodyTo( String.class ); + + + from( CATALOG_SERVICES_OF_PARTNERS ) + .log(LoggingLevel.INFO, 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) + .convertBodyTo( String.class ); + + + from( CATALOG_GET_SERVICE_BY_ORDERID ) + .log(LoggingLevel.INFO, 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!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, DeploymentDescriptor.class, true) + .bean( serviceRepoService, "nfvCatalogNSResourceChanged(${body})"); + + + + from( EVENT_RESOURCE_STATE_CHANGED ) + .log(LoggingLevel.INFO, 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})"); + + + from( EVENT_RESOURCE_CREATE ) + .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_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})"); + + + + + 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})"); + + + + /** + * dead Letter Queue msgs if everything fails to connect + */ + from("direct:retriesDeadLetters") + //.setBody() + //.body(String.class) + //.process( ErroneousValidationProcessor ) + .to("log:DEBUG?showBody=true&showHeaders=true") + .to("stream:out"); + } + + + 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/api/ServiceApiRouteBuilderEvents.java b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilderEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..fe4e5e74363af66bf28f3784d4f1df68953e95ba --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilderEvents.java @@ -0,0 +1,114 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.sim638.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.sim638.model.ServiceAttributeValueChangeNotification; +import org.etsi.osl.tmf.sim638.model.ServiceCreateNotification; +import org.etsi.osl.tmf.sim638.model.ServiceDeleteNotification; +import org.etsi.osl.tmf.sim638.model.ServiceStateChangeNotification; +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 ServiceApiRouteBuilderEvents extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ServiceApiRouteBuilderEvents.class.getName()); + + + + @Value("${EVENT_SERVICE_CREATE}") + private String EVENT_SERVICE_CREATE = ""; + + @Value("${EVENT_SERVICE_STATE_CHANGED}") + private String EVENT_SERVICE_STATE_CHANGED = ""; + + @Value("${EVENT_SERVICE_DELETE}") + private String EVENT_SERVICE_DELETE = ""; + + @Value("${EVENT_SERVICE_ATTRIBUTE_VALUE_CHANGED}") + private String EVENT_SERVICE_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 for type " + n.getEventType()); + try { + String msgtopic=""; + + if ( n instanceof ServiceCreateNotification) { + msgtopic = EVENT_SERVICE_CREATE; + } else if ( n instanceof ServiceStateChangeNotification) { + msgtopic = EVENT_SERVICE_STATE_CHANGED; + } else if ( n instanceof ServiceDeleteNotification) { + msgtopic = EVENT_SERVICE_DELETE; + } else if ( n instanceof ServiceAttributeValueChangeNotification) { + msgtopic = EVENT_SERVICE_ATTRIBUTE_VALUE_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/repo/ServiceActionQueueRepository.java b/src/main/java/org/etsi/osl/tmf/sim638/repo/ServiceActionQueueRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..d6d7549da64ca23152a1d97cf89d5b20e2ed2e9f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/repo/ServiceActionQueueRepository.java @@ -0,0 +1,46 @@ +/*- + * ========================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.sim638.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.sim638.model.ServiceActionQueueAction; +import org.etsi.osl.tmf.sim638.model.ServiceActionQueueItem; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + + +@Repository +public interface ServiceActionQueueRepository extends CrudRepository, PagingAndSortingRepository { + + + Optional findByUuid(String id); + + List findFirst10ByOrderByInsertedDate(); + + List findByServiceRefIdAndAction(String serviceRefId, + ServiceActionQueueAction action); + + + void deleteByServiceRefIdAndAction(String serviceRefId, + ServiceActionQueueAction action); +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..bd2cbf0c15ceb24a1fd8d65d20734ebe4a3a8638 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/repo/ServiceRepository.java @@ -0,0 +1,72 @@ +/*- + * ========================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.sim638.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.sim638.model.Service; +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 { + + + Optional findByUuid(String id); + + @Query("SELECT srv FROM Service srv JOIN FETCH srv.relatedParty rp WHERE rp.name = ?1") + Iterable findByRolename(String name); + + @Query("SELECT srv FROM Service srv WHERE ( srv.state != org.etsi.osl.tmf.common.model.service.ServiceStateType.TERMINATED ) AND srv.endDate < CURRENT_TIMESTAMP") + List findActiveToTerminate(); + + @Query("SELECT srv FROM Service srv " + + "JOIN FETCH srv.serviceCharacteristic char " + + "JOIN FETCH char.value val " + + "WHERE char.name = 'DeploymentRequestID' AND " + + " val.value = ?1 " ) + List findByDeploymentRequestID(String aDeploymentRequestID); + + + @Query("SELECT srv FROM Service srv " + + "JOIN FETCH srv.serviceCharacteristic char " + + "JOIN FETCH char.value val " + + "WHERE (srv.state = org.etsi.osl.tmf.common.model.service.ServiceStateType.ACTIVE OR " + + " srv.state = org.etsi.osl.tmf.common.model.service.ServiceStateType.RESERVED OR " + + " srv.state = org.etsi.osl.tmf.common.model.service.ServiceStateType.FEASIBILITYCHECKED) AND " + + "char.name = 'externalPartnerServiceId'" + ) + List findActiveAndReservedServicesOfPartners(); + + @Query("SELECT srv FROM Service srv " + + "JOIN FETCH srv.serviceOrder sorder " + + "WHERE sorder.id = ?1 " ) + List findServicesFromOrderID(String orderid); + + @Query("SELECT srv FROM Service srv " + + "JOIN FETCH srv.supportingResource sres " + + "WHERE sres.id = ?1 " ) + List findServicesHavingThisSupportingResourceID(String resourceID); + +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..eaf0609a083947ceee28114efacb3f886ee9b9f2 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java @@ -0,0 +1,1254 @@ +/*- + * ========================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.sim638.service; + +import java.io.UnsupportedEncodingException; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +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.datatype.hibernate5.jakarta.Hibernate5JakartaModule; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.common.model.service.Characteristic; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.common.model.service.Place; +import org.etsi.osl.tmf.common.model.service.ResourceRef; +import org.etsi.osl.tmf.common.model.service.ServiceRef; +import org.etsi.osl.tmf.common.model.service.ServiceRelationship; +import org.etsi.osl.tmf.common.model.service.ServiceStateType; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.ri639.model.Resource; +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.etsi.osl.tmf.ri639.repo.ResourceRepository; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.sim638.api.ServiceApiRouteBuilderEvents; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceActionQueueAction; +import org.etsi.osl.tmf.sim638.model.ServiceActionQueueItem; +import org.etsi.osl.tmf.sim638.model.ServiceAttributeValueChangeEvent; +import org.etsi.osl.tmf.sim638.model.ServiceAttributeValueChangeNotification; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceCreateEvent; +import org.etsi.osl.tmf.sim638.model.ServiceCreateNotification; +import org.etsi.osl.tmf.sim638.model.ServiceOrderRef; +import org.etsi.osl.tmf.sim638.model.ServiceStateChangeEvent; +import org.etsi.osl.tmf.sim638.model.ServiceStateChangeNotification; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.sim638.repo.ServiceActionQueueRepository; +import org.etsi.osl.tmf.sim638.repo.ServiceRepository; +import org.etsi.osl.tmf.so641.model.ServiceOrder; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.transform.ResultTransformer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.etsi.osl.model.nfv.DeploymentDescriptor; +import org.etsi.osl.model.nfv.DeploymentDescriptorVxFInstanceInfo; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + + + +@org.springframework.stereotype.Service +public class ServiceRepoService { + + private static final transient Log logger = LogFactory.getLog(ServiceRepoService.class.getName()); + + @Autowired + ObjectMapper objectMapper; + + @Autowired + ServiceRepository serviceRepo; + + + @Autowired + ResourceRepository resourceRepo; + + @Autowired + ServiceActionQueueRepository serviceActionQueueRepo; + + @Autowired + ServiceSpecificationRepoService serviceSpecRepoService; + + private SessionFactory sessionFactory; + + @Autowired + ServiceApiRouteBuilderEvents serviceApiRouteBuilder; + + @Autowired + public ServiceRepoService(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.serviceRepo.findAll(); + } + + public List findAll(@Valid String fields, Map allParams) + throws UnsupportedEncodingException { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + List alist = null; + try { +// String sql = "SELECT s FROM ServiceSpecification s"; + String sql = "SELECT " + + "srv.uuid as uuid," + + "srv.serviceDate as serviceDate," + + "srv.name as name," + + "srv.startDate as startDate," + + "srv.category as category," + + "srv.state as state," + + "srv.startMode as startMode," + + "srv.serviceType as serviceType," + + "sor.id as serviceOrderId" +// + "rp.uuid as relatedParty_uuid," +// + "rp.name as relatedParty_name" + ; + + if (fields != null) { + String[] field = fields.split(","); + for (String f : field) { + sql += ", srv." + f + " as " + f ; + } + + } + sql += " FROM Service srv " + //+ "JOIN srv.relatedParty rp " + + "JOIN srv.serviceOrder sor "; +// 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' "; +// } + + sql += " ORDER BY srv.startDate DESC"; + + List mapaEntity = session + .createQuery(sql ) + .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.equals("serviceOrderId")) { + if ( result.get( "serviceOrder" ) == null ) { + result.put("serviceOrder", new ArrayList() ) ; + } + ArrayList< Object> rpList = (ArrayList< Object>) result.get( "serviceOrder" ); + LinkedHashMap rp = new LinkedHashMap<>(); + rp.put("id", tuple[i]); + rpList.add(rp); + } + if (alias != null) { + result.put(alias, tuple[i]); + } + } + + return result; + } + + @Override + public List transformList(List collection) { + return collection; + } + } ) + .list(); + + + +// List mapaEntity = session +// .createQuery(sql ) +// .setResultTransformer( new ResultTransformer() { +// +// @Override +// public ServiceOrder transformTuple(Object[] tuple, String[] aliases) { +// //Map result = new LinkedHashMap(tuple.length); +// ServiceOrder so = new ServiceOrder(); +// so.setUuid( (String) tuple[0] ); +// so.setOrderDate( (OffsetDateTime) tuple[1] ); +// ServiceOrderItem soi = new ServiceOrderItem(); +// so.addOrderItemItem( soi ); +// ServiceRestriction service = new ServiceRestriction(); +// service.setName( (String) tuple[9] ); +// soi.setService(service ); +// +//// for (int i = 0; i < tuple.length; i++) { +//// String alias = aliases[i]; +//// if (alias.equals("type")) { +//// alias = "@type"; +//// } +//// if (alias != null) { +//// result.put(alias, tuple[i]); +//// } +//// } +// +// return so; +// } +// +// @Override +// public List transformList(List collection) { +// return collection; +// } +// } ) +// .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + + } + + + public List findAll(String name, UserPartRoleType requester) { + // TODO Auto-generated method stub + return (List) this.serviceRepo.findByRolename(name); + } + + + public Service addService(@Valid ServiceCreate service) { + logger.info("Will add service: " + service.getName() ); + Service s = new Service(); + if (service.getType()!=null) { + s.setType(service.getType()); + } + s.setName(service.getName()); + s.setCategory( service.getCategory() ); + s.setDescription( service.getDescription() ); + s.setStartDate( service.getStartDate()); + s.setEndDate( service.getEndDate() ); + s.hasStarted( service.isHasStarted()); + s.setIsServiceEnabled( service.isIsServiceEnabled()); + s.setIsStateful(service.isIsStateful()); + s.setServiceDate( service.getServiceDate()); + s.setServiceType( service.getServiceType()); + s.setStartMode( service.getStartMode()); + s.setState(service.getState()); + s.setServiceSpecificationRef( service.getServiceSpecificationRef() ); + if ( service.getNote() != null) { + s.getNote().addAll( service.getNote() ); + } + if ( service.getPlace() != null) { + s.getPlace().addAll( service.getPlace() ); + } + + if ( service.getRelatedParty()!=null ) { + s.getRelatedParty().addAll( service.getRelatedParty()); + } + + if ( service.getServiceCharacteristic () != null) { + s.getServiceCharacteristic().addAll( service.getServiceCharacteristic() ); + } + + if ( service.getServiceOrder() != null) { + s.getServiceOrder().addAll( service.getServiceOrder() ); + } + if ( service.getServiceRelationship() != null) { + s.getServiceRelationship().addAll( service.getServiceRelationship() ); + } + if ( service.getSupportingResource() != null) { + s.getSupportingResource().addAll( service.getSupportingResource() ); + } + if ( service.getSupportingService() != null) { + s.getSupportingService().addAll( service.getSupportingService() ); + } + + Note noteItem = new Note(); + noteItem.setText("Service " + s.getState() ); + noteItem.setAuthor("API"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + s.addNoteItem(noteItem); + + s = this.serviceRepo.save( s ); + + raiseServiceCreateNotification(s); + return s; + } + + + + public Service findByUuid(String id) { + Optional optionalCat = this.serviceRepo.findByUuid( id ); + return optionalCat + .orElse(null); + } + + /** + * @param id + * @param servUpd + * @param triggerServiceActionQueue + * @param updatedFromParentService + * @param updatedFromChildService + * @return + */ + @Transactional + public Service updateService(String id, @Valid ServiceUpdate servUpd, boolean triggerServiceActionQueue, Service updatedFromParentService, Service updatedFromChildService ) { + //Service service = this.findByUuid(id); + Service service = this.getServiceEager(id); + + + 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; + try { + originaServiceAsJson = mapper.writeValueAsString( service ); + } catch (JsonProcessingException e) { + logger.error("cannot umarshall service: " + service.getName() ); + e.printStackTrace(); + } + + + if (servUpd.getType()!=null) { + service.setType(servUpd.getType()); + } + + if (servUpd.getName() != null ) { + service.setName(servUpd.getName()); + } + + if (servUpd.getCategory() != null ) { + service.setCategory( servUpd.getCategory() ); + } + if (servUpd.getDescription() != null ) { + service.setDescription( servUpd.getDescription() ); + } + if (servUpd.getStartDate() != null ) { + + service.setStartDate( servUpd.getStartDate()); + } + if (servUpd.getEndDate() != null ) { + service.setEndDate( servUpd.getEndDate() ); + } + if (servUpd.isHasStarted() != null ) { + service.hasStarted( servUpd.isHasStarted()); + } + if (servUpd.isIsServiceEnabled() != null ) { + service.setIsServiceEnabled( servUpd.isIsServiceEnabled()); + } + if (servUpd.isIsStateful() != null ) { + service.setIsStateful(servUpd.isIsStateful()); + } + if (servUpd.getServiceDate() != null ) { + service.setServiceDate( servUpd.getServiceDate()); + + } + if (servUpd.getServiceType() != null ) { + service.setServiceType( servUpd.getServiceType()); + + } + if (servUpd.getStartMode() != null ) { + service.setStartMode( servUpd.getStartMode()); + + } + + + boolean stateChanged = false; + ServiceStateType previousState = service.getState(); + if (servUpd.getState() != null ) { + stateChanged = service.getState() != servUpd.getState(); + service.setState(servUpd.getState()); + + } + if (servUpd.getServiceSpecificationRef() != null ) { + + service.setServiceSpecificationRef( servUpd.getServiceSpecificationRef() ); + } + + /** + * the following need to be modified for deleting items from lists. + */ + + if ( servUpd.getNote()!=null ) { + for (Note n : servUpd.getNote()) { + if (n.getUuid() == null) { + service.addNoteItem(n); + } + } + } + + if ( servUpd.getPlace()!=null ) { + for (Place n : servUpd.getPlace()) { + if (n.getUuid() == null) { + service.addPlaceItem(n); + } + } + } + + if ( servUpd.getRelatedParty()!=null ) { + for (RelatedParty n : servUpd.getRelatedParty()) { + if (n.getUuid() == null) { + service.addRelatedPartyItem(n); + } + } + } + + boolean serviceCharacteristicChanged = false; + boolean serviceCharacteristicChangedContainsPrimitive = false; + boolean serviceCharacteristicChangedContainsNSLCM; + + String charChangedForNotes = ""; + //List childCharacteristicsChanged = new ArrayList<>(); + + + //logger.info("==> Will update serviceToString: " + service.toString() ); + + + if ( servUpd.getServiceCharacteristic()!=null ) { + for (Characteristic n : servUpd.getServiceCharacteristic()) { + serviceCharacteristicChangedContainsNSLCM = false; + + if ( service.getServiceCharacteristicByName( n.getName() )!= null ) { + + Characteristic origChar = service.getServiceCharacteristicByName( n.getName() ); + if ( ( origChar !=null ) && ( origChar.getValue() !=null ) && ( origChar.getValue().getValue() !=null )) { + if ( !origChar.getValue().getValue().equals(n.getValue().getValue()) ) { +// if ( n.getName().contains("::") ) { +// childCharacteristicsChanged.add(n); //the characteristic needs later to be propagated to its children +// +// } + + if ( !n.getName().contains("::") ) { //it is not a child characteristic + serviceCharacteristicChanged = true; //change only characteristics of this service + charChangedForNotes += n.getName() + ", "; + } + if ( n.getName().toUpperCase().contains( "PRIMITIVE::" ) ){ + serviceCharacteristicChanged = true; + serviceCharacteristicChangedContainsPrimitive = true; + } + + // Check if the name contains "NSLCM" + if (n.getName().toUpperCase().contains("NSLCM")) { + // Flag to indicate that service characteristic with NSLCM is present + serviceCharacteristicChangedContainsNSLCM = true; + + // Update the NSLCM Characteristic + updateNSLCMCharacteristic(service, n); + } + + + } + } + + // As the NSLCM Characteristic was already updated, skip that one + if (!serviceCharacteristicChangedContainsNSLCM) { + service.getServiceCharacteristicByName( n.getName() ).setValue( + new Any( n.getValue().getValue(), n.getValue().getAlias() ) + ); + } + + } else { + service.addServiceCharacteristicItem(n); + if ( !n.getName().contains("::") ) { //it is not a child characteristic + serviceCharacteristicChanged = true; + charChangedForNotes += n.getName() + ", "; + } + } + + } + } + + if ( servUpd.getServiceOrder()!=null ) { + for (ServiceOrderRef n : servUpd.getServiceOrder()) { + if (n.getUuid() == null) { + service.addServiceOrderItem(n); + } + } + } + + if ( servUpd.getServiceRelationship()!=null ) { + for (ServiceRelationship n : servUpd.getServiceRelationship()) { + if (n.getUuid() == null) { + service.addServiceRelationshipItem(n); + } + } + } + if ( servUpd.getSupportingResource()!=null ) { + for (ResourceRef n : servUpd.getSupportingResource()) { + if (n.getUuid() == null) { + service.addSupportingResourceItem(n); + } + } + } + if ( servUpd.getSupportingService()!=null ) { + for (ServiceRef n : servUpd.getSupportingService()) { + if (n.getUuid() == null) { + service.addSupportingServiceItem(n); + } + } + //prepei na enimerwsoume ta characteristics edw sto parent servcie pou exei auto ws supported + } + + + if (stateChanged) { + Note noteItem = new Note(); + noteItem.setText("Service is " + service.getState() ); + noteItem.setAuthor("API"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + service.addNoteItem(noteItem); + } + + + + if (charChangedForNotes.contains( "reconciledAt") ) { //this is just a sync message, so we need to igore such changes + serviceCharacteristicChanged = false; + } + + if (serviceCharacteristicChanged) { + Note noteItem = new Note(); + noteItem.setText("Service Characteristic changed: " + charChangedForNotes ); + noteItem.setAuthor("API"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + service.addNoteItem(noteItem); + } + + + + service = this.serviceRepo.save( service ); + + + + /** + * Save in ServiceActionQueueItem + */ + + if (triggerServiceActionQueue && stateChanged) { + ServiceActionQueueItem saqi = new ServiceActionQueueItem(); + saqi.setServiceRefId( id ); + saqi.setOriginalServiceInJSON( originaServiceAsJson ); + if (stateChanged) { + if ( service.getState().equals( ServiceStateType.INACTIVE) ) { + saqi.setAction( ServiceActionQueueAction.DEACTIVATE ); + }else if ( service.getState().equals( ServiceStateType.TERMINATED) ) { + saqi.setAction( ServiceActionQueueAction.TERMINATE ); + } + + } + + if ( saqi.getAction() != ServiceActionQueueAction.NONE ) { + this.addServiceActionQueueItem(saqi); + } + } + + +// //here on any state change of a Service we must send an ActionQueueItem that reflects the state changed with the Action + if ( stateChanged ) { + ServiceActionQueueItem saqi = new ServiceActionQueueItem(); + saqi.setServiceRefId( id ); + saqi.setOriginalServiceInJSON( originaServiceAsJson ); + if ( service.getState().equals( ServiceStateType.ACTIVE) ) { + saqi.setAction( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOACTIVE ); + this.addServiceActionQueueItem(saqi); + }else if ( previousState!=null && previousState.equals( ServiceStateType.ACTIVE) ) { + saqi.setAction( ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOINACTIVE ); + this.addServiceActionQueueItem(saqi); + } + } + + if ( serviceCharacteristicChanged && service.getState().equals( ServiceStateType.ACTIVE) && previousState!=null && previousState.equals( ServiceStateType.ACTIVE) && triggerServiceActionQueue ) { + ServiceActionQueueItem saqi = new ServiceActionQueueItem(); + saqi.setServiceRefId( id ); + saqi.setOriginalServiceInJSON( originaServiceAsJson ); + saqi.setAction( ServiceActionQueueAction.EVALUATE_CHARACTERISTIC_CHANGED ); + if ( serviceCharacteristicChangedContainsPrimitive ) { + saqi.setAction( ServiceActionQueueAction.EVALUATE_CHARACTERISTIC_CHANGED_MANODAY2 ); + } + this.addServiceActionQueueItem(saqi); + } + + /* + * Update any parent service + */ + for (ServiceRelationship serviceRelationship : service.getServiceRelationship()) { + if (serviceRelationship.getRelationshipType().equals("ChildService")) { + if (serviceRelationship.getService() != null) { + + + if (serviceCharacteristicChanged) { + if (updatedFromParentService == null || (updatedFromParentService != null && !updatedFromParentService.getId().equals(serviceRelationship.getService().getId()))) { // avoid circular + ServiceActionQueueItem saqi = new ServiceActionQueueItem(); // this will trigger lcm rule to parent + saqi.setServiceRefId(serviceRelationship.getService().getId()); + try { + saqi.setOriginalServiceInJSON( mapper.writeValueAsString( service ) ); //pass the child service as is + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + saqi.setAction(ServiceActionQueueAction.EVALUATE_CHILD_CHARACTERISTIC_CHANGED); + this.addServiceActionQueueItem(saqi); + } + + } + + if (stateChanged) { + if (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_STATE_CHANGE ); + this.addServiceActionQueueItem(saqi); + } + } + + + + } + } + } + +// if ( childCharacteristicsChanged.size()>0 ) { +// if ( service.getSupportingService() != null ) { //propagate to children +// //copy characteristics values from CFS Service to its supporting services. +// for (ServiceRef sref : service.getSupportingService() ) { +// Service aSupportingService = this.findByUuid( sref.getId() ); +// ServiceUpdate supd = new ServiceUpdate(); +// boolean foundCharacteristicForChild = false; +// for (Characteristic supportingServiceChar : aSupportingService.getServiceCharacteristic() ) { +// +// for (Characteristic serviceCharacteristic : childCharacteristicsChanged ) { +// if ( serviceCharacteristic.getName().contains( aSupportingService.getName() + "::" + supportingServiceChar.getName() )) { +// //supportingServiceChar.setValue( serviceCharacteristic.getValue() ); +// Characteristic cNew = new Characteristic(); +// cNew.setName(supportingServiceChar.getName()); +// cNew.value( new Any( serviceCharacteristic.getValue() )); +// supd.addServiceCharacteristicItem( cNew ); +// foundCharacteristicForChild = true; +// } +// } +// } +// +// if ( foundCharacteristicForChild ) { +// Note n = new Note(); +// n.setText("Child Characteristics Changed" ); +// n.setAuthor( "SIM638-API" ); +// n.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); +// supd.addNoteItem( n ); +// if ( updatedFromChildService == null || +// (updatedFromChildService!=null && !updatedFromChildService.getId().equals( aSupportingService.getId())) ) { //avoid circular +// this.updateService( aSupportingService.getId(), supd , false, service, null); //update the service +// } +// } +// } +// +// } +// } + + + + /** + * notify hub + */ + if (stateChanged) { + raiseServiceStateChangedNotification( service ); + } else if ( serviceCharacteristicChanged ) { + raiseServiceAttributeValueChangedNotification( service ); + } + + + 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; + } + + /** + * Updates the NSLCM characteristic within a given service. + * + * @param service The service object containing the characteristics. + * @param n The characteristic object to be checked and potentially updated. + */ + public Service updateNSLCMCharacteristic(Service service, Characteristic n) { + // Create an object mapper for JSON serialization/deserialization + 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("[]"); + } + + // 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(); + + ArrayList arrayList = null; + + // Deserialize the current value back to an array list + try { + arrayList = primitivesObjectMapper.readValue(aNSLCMCharacteristicValue, new TypeReference>() {}); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + // 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(); + } + } + + return service; + } + + + /** + * @param service + * @param parentService + */ +// private void propagateCharacteristicsToParentService(Service childService, String parentServiceId) { +// +// ServiceUpdate servUpd = new ServiceUpdate(); +// +// for (Characteristic n : childService.getServiceCharacteristic()) { +// Characteristic serviceCharacteristicItem = new Characteristic(); +// serviceCharacteristicItem.setName( childService.getName() + "::" + n.getName()); +// serviceCharacteristicItem.setValue( new Any( n.getValue() )); +// servUpd.addServiceCharacteristicItem(serviceCharacteristicItem); +// } +// +// this.updateService( parentServiceId, servUpd, false, null, childService); +// } + + @Transactional + public String getServiceEagerAsString(String id) throws JsonProcessingException { + Service s = this.getServiceEager(id); + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new Hibernate5JakartaModule()); + String res = mapper.writeValueAsString(s); + + + Characteristic schart = s.getServiceCharacteristicByName("long_string"); + + if ( schart!= null ) { + String teest = schart.getValue().getValue(); + logger.info("schart size = " + teest.length() ); + + logger.info("schart " + teest ); + logger.info("======================================================================================================"); + } + + return res; + } + + @Transactional + public Service getServiceEager(String id) { + if ( id == null || id.equals("")) { + return null; + } + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + Service s = null; + try { + s = (Service) session.get(Service.class, id); + if (s == null) { + return this.findByUuid(id);// last resort + } + + Hibernate.initialize(s.getRelatedParty()); + Hibernate.initialize(s.getNote() ); + Hibernate.initialize(s.getServiceCharacteristic() ); + Hibernate.initialize(s.getServiceOrder() ); + Hibernate.initialize(s.getServiceRelationship() ); + Hibernate.initialize(s.getServiceSpecificationRef() ); + Hibernate.initialize(s.getSupportingService() ); + Hibernate.initialize(s.getSupportingResource() ); + Hibernate.initialize(s.getPlace() ); + + tx.commit(); + } finally { + session.close(); + } + + return s; + } + + + @Transactional + private void raiseServiceCreateNotification(Service so) { + ServiceCreateNotification n = new ServiceCreateNotification(); + ServiceCreateEvent event = new ServiceCreateEvent(); + event.service( so ); + n.setEvent(event ); + serviceApiRouteBuilder.publishEvent(n, so.getId()); + + } + + @Transactional + private void raiseServiceStateChangedNotification(Service so) { + ServiceStateChangeNotification n = new ServiceStateChangeNotification(); + ServiceStateChangeEvent event = new ServiceStateChangeEvent(); + event.service( so ); + n.setEvent(event ); + serviceApiRouteBuilder.publishEvent(n, so.getId()); + + } + + @Transactional + private void raiseServiceAttributeValueChangedNotification(Service so) { + ServiceAttributeValueChangeNotification n = new ServiceAttributeValueChangeNotification(); + ServiceAttributeValueChangeEvent event = new ServiceAttributeValueChangeEvent(); + event.service( so ); + n.setEvent(event ); + serviceApiRouteBuilder.publishEvent(n, so.getId()); + + } + + + /** + * @return + */ + @Transactional + public List findAllServiceActionQueueItems() { + + return (List) this.serviceActionQueueRepo.findFirst10ByOrderByInsertedDate(); + } + + 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() ); + this.serviceActionQueueRepo.deleteByServiceRefIdAndAction(item.getServiceRefId(), item.getAction()); + + return this.serviceActionQueueRepo.save( item); + } + + /** + * @param item + * @return + */ + @Transactional + public ServiceActionQueueItem updateServiceActionQueueItem(@Valid ServiceActionQueueItem item) { + logger.debug("Will update ServiceActionQueueItem ServiceRefId: " + item.getServiceRefId() ); + return this.serviceActionQueueRepo.save( item); + } + + /** + * @param id + * @return + */ + @Transactional + public Void deleteServiceActionQueueItemByUuid(String id) { + + Optional optso = this.serviceActionQueueRepo.findByUuid(id); + if ( optso.isEmpty() ) { + return null; + } + ServiceActionQueueItem so = optso.get(); + if ( so == null ) { + return null; + } + + this.serviceActionQueueRepo.delete(so); + return null; + } + + + + @Transactional + public List findAllActiveServicesToTerminate(){ + + List result = new ArrayList<>(); + List srvs = this.serviceRepo.findActiveToTerminate(); + for (Service service : srvs) { + result.add( service.getId()); + } + + return result; + } + + /** + * @return UUIDs of Services and put them in a List + */ + @Transactional + public List findAllActiveAndReservedServicesOfPartners(){ + + List result = new ArrayList<>(); + List srvs = this.serviceRepo.findActiveAndReservedServicesOfPartners(); + for (Service service : srvs) { + result.add( service.getId()); + } + + return result; + } + + + + /** + * Given a DeploymentRequestID (which is provided by OSM in our case) + * we locate the equivalent service + * @param aDeploymentRequestID + * @return + */ + @Transactional + public List findDeploymentRequestID( String aDeploymentRequestID){ + + return (List) this.serviceRepo.findByDeploymentRequestID( aDeploymentRequestID ); + + } + + + /** + * Given a Resource (which for example might be provided by a CR update from a cluster ) + * we locate the equivalent services + * @param resourceID + * @return + */ + @Transactional + public List findServicesHavingThisSupportingResourceID( String resourceID){ + + return (List) this.serviceRepo.findServicesHavingThisSupportingResourceID( resourceID ); + + } + + + + /** + * @param item + * @return + */ + @Transactional + public void nfvCatalogNSResourceChanged(@Valid DeploymentDescriptor dd) { + String deploymentRequestID = dd.getId() + ""; + logger.info("Will update nfvCatalogNSResourceChanged for deploymentRequestID = " + deploymentRequestID ); + + var aservices = findDeploymentRequestID( deploymentRequestID ); + for (Service as : aservices) { + + Service aService = findByUuid(as.getId()); + + if ( aService.getState().equals( ServiceStateType.ACTIVE ) ) { + + + ServiceUpdate supd = new ServiceUpdate(); + + Characteristic cNewLCM = new Characteristic(); + cNewLCM.setName("NSLCM" ); + cNewLCM.value( new Any( dd.getNs_nslcm_details() )); + supd.addServiceCharacteristicItem( cNewLCM ); + + Characteristic cNewNSR = new Characteristic(); + //cNewNSR.setUuid(null); + cNewNSR.setName("NSR" ); + cNewNSR.value( new Any( dd.getNsr() )); + supd.addServiceCharacteristicItem( cNewNSR ); + + + + if ( dd.getDeploymentDescriptorVxFInstanceInfo() !=null ) { + for ( DeploymentDescriptorVxFInstanceInfo vnfinfo : dd.getDeploymentDescriptorVxFInstanceInfo() ) { + Characteristic cNewMember = new Characteristic(); + cNewMember.setName( "VNFINDEXREF_INFO_" + vnfinfo.getMemberVnfIndexRef() ); + cNewMember.value( new Any( vnfinfo.getVxfInstanceInfo() + "" )); + supd.addServiceCharacteristicItem( cNewMember ); + } + } + + Note n = new Note(); + n.setText("NS Resource LCM Changed" ); + 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 + } + } + } + + + @Transactional + public List getServicesFromOrderID(String orderid){ + + List result = new ArrayList<>(); + List srvs = this.serviceRepo.findServicesFromOrderID( orderid ); + for (Service service : srvs) { + result.add( service.getId()); + } + + return result; + } + + + @Transactional + public void resourceAttrChangedEvent(@Valid ResourceAttributeValueChangeNotification resNotif) { + 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() ); + + for (Service as : aservices) { + + Service aService = findByUuid(as.getId()); + + //if ( aService.getState().equals( ServiceStateType.ACTIVE ) ) { + + + ServiceUpdate supd = new ServiceUpdate(); + + //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 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 + //} + } + + + }catch (Exception e) { + e.printStackTrace(); + } + + } + + + @Transactional + public void resourceCreatedEvent(@Valid ResourceCreateNotification resNotif) { + try { + Resource res = resNotif.getEvent().getEvent().getResource(); + logger.debug("resourceCreatedEvent for: " + res.getName()); + updateServiceFromresourceChange(res); + }catch (Exception e) { + e.printStackTrace(); + } + + } + + + @Transactional + public void resourceStateChangedEvent(@Valid ResourceStateChangeNotification resNotif) { + try { + + Resource res = resNotif.getEvent().getEvent().getResource(); + logger.debug("resourceStateChangedEvent for: " + res.getName()); + updateServiceFromresourceChange(res); + + }catch (Exception e) { + e.printStackTrace(); + } + + } + + @Transactional + private void updateServiceFromresourceChange(Resource res) { + + logger.info("Will update services related to this resource with id = " + res.getId() ); + var aservices = findServicesHavingThisSupportingResourceID(res.getId()); + + for (Service as : aservices) { + + Service aService = findByUuid(as.getId()); + + + List 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); + 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); + + + } + + @Transactional + private void updateResourceFromKubernetesLabel(Resource res) { + logger.debug("updateResourceFromKubernetesLabel for: " + res.getName()); + + if (res.getResourceCharacteristicByName("org.etsi.osl.serviceId") != null) { + + + logger.debug("org.etsi.osl.serviceId found "); + String serviceId = res.getResourceCharacteristicByName("org.etsi.osl.serviceId").getValue().getValue(); + logger.debug("rserviceId: " + serviceId); + + Service aService = findByUuid( serviceId ); + if ( aService !=null ) { + logger.debug("aService found "); + Boolean resourceFoundInSupportedResourcesOfService = false; + for (ResourceRef as : aService.getSupportingResource()) { + if ( as.getId().equals( res.getId() )) { + resourceFoundInSupportedResourcesOfService = true; + break; + } + } + + logger.debug("resourceFoundInSupportedResourcesOfService= " + resourceFoundInSupportedResourcesOfService); + if ( !resourceFoundInSupportedResourcesOfService ) { + ServiceUpdate supd = new ServiceUpdate(); + + ResourceRef rref = new ResourceRef(); + 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" ); + 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 + } + + } + + } + + } + + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/so641/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/so641/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..eb323003c73c319d61855436259ea932c2bfafab --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.so641.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +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/so641/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/so641/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..8487180654ed342ba13dcc89a1796746d148bb33 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================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.so641.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.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +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/so641/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/so641/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..8f9b969934a9023f1254c6ea3d4e353d88f3d3a8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================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.so641.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +@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/so641/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/so641/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..b789233ba5078f320e7dbdc2bfcacdf1dabab127 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.so641.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.so641.model.EventSubscription; +import org.etsi.osl.tmf.so641.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/so641/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/so641/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..d2ad0b1f6082dd86e6eef77e059e40ad0382d418 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.so641.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +@Controller("HubApiController641") +@RequestMapping("/serviceOrdering/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/so641/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/so641/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..558fcf315e382e081fd79ed6ec3c3410b1857b93 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ListenerApi.java @@ -0,0 +1,192 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.so641.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.so641.model.EventSubscription; +import org.etsi.osl.tmf.so641.model.ServiceOrderAttributeValueChangeNotification; +import org.etsi.osl.tmf.so641.model.ServiceOrderCreateNotification; +import org.etsi.osl.tmf.so641.model.ServiceOrderDeleteNotification; +import org.etsi.osl.tmf.so641.model.ServiceOrderStateChangeNotification; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity ServiceOrderAttributeValueChangeNotification", operationId = "listenToServiceOrderAttributeValueChangeNotification", description = "Example of a client listener for receiving the notification ServiceOrderAttributeValueChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceOrderAttributeValueChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceOrderAttributeValueChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceOrderAttributeValueChangeNotification data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceOrderCreateNotification", operationId = "listenToServiceOrderCreateNotification", description = "Example of a client listener for receiving the notification ServiceOrderCreateNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceOrderCreateNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceOrderCreateNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceOrderCreateNotification data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceOrderDeleteNotification", operationId = "listenToServiceOrderDeleteNotification", description = "Example of a client listener for receiving the notification ServiceOrderDeleteNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceOrderDeleteNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceOrderDeleteNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceOrderDeleteNotification data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceOrderStateChangeNotification", operationId = "listenToServiceOrderStateChangeNotification", description = "Example of a client listener for receiving the notification ServiceOrderStateChangeNotification", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceOrderStateChangeNotification", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceOrderStateChangeNotification(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceOrderStateChangeNotification data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/so641/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/so641/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..fade1425f83dae34d87e57b244d70dcf4e74d2db --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ListenerApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.so641.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +@Controller("ListenerApiController641") +@RequestMapping("/serviceOrdering/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/so641/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/so641/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..e5631b77491ee9bd1575ffae56076ccad9491852 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/NotFoundException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.so641.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +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/so641/api/ServiceOrderApi.java b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApi.java new file mode 100644 index 0000000000000000000000000000000000000000..8ad172ae8b210211b65151a2b182d0797fc062a7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApi.java @@ -0,0 +1,224 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.so641.api; + +import java.security.Principal; +import java.util.Date; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.so641.model.ServiceOrder; +import org.etsi.osl.tmf.so641.model.ServiceOrderCreate; +import org.etsi.osl.tmf.so641.model.ServiceOrderUpdate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.format.annotation.DateTimeFormat; +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; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +@Tag(name = "serviceOrder", description = "the serviceOrder API") +public interface ServiceOrderApi { + + Logger log = LoggerFactory.getLogger(ServiceOrderApi.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 ServiceOrder", operationId = "createServiceOrder", description = "This operation creates a ServiceOrder entity.", tags={ "serviceOrder", }) + @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 = "/serviceOrder", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createServiceOrder( + Principal principal, + @Parameter(description = "The ServiceOrder to be created" ,required=true ) @Valid @RequestBody ServiceOrderCreate serviceOrder) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ServiceOrder", operationId = "deleteServiceOrder", description = "This operation deletes a ServiceOrder entity.", tags={ "serviceOrder", }) + @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 = "/serviceOrder/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteServiceOrder( + Principal principal, + @Parameter(description = "Identifier of the ServiceOrder",required=true) @PathVariable("id") String id) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ServiceOrder objects", operationId = "listServiceOrder", description = "This operation list or find ServiceOrder entities" , tags={ "serviceOrder", }) + @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 = "/serviceOrder", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listServiceOrder( + 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 starttime for start of resources to be provided in response") @Valid @RequestParam(value = "starttime", required = false) @DateTimeFormat(pattern="yyyy-MM-dd'T'HH:mm:ss") Date starttime, + @Parameter(description = "Requested endtime for start of resources to be provided in response") @Valid @RequestParam(value = "endtime", required = false) @DateTimeFormat(pattern="yyyy-MM-dd'T'HH:mm:ss") Date endtime + ) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a ServiceOrder", operationId = "patchServiceOrder", description = "This operation updates partially a ServiceOrder entity.", tags={ "serviceOrder", }) + @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 = "/serviceOrder/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchServiceOrder( + Principal principal, + @Parameter(description = "Identifier of the ServiceOrder",required=true) @PathVariable("id") String id,@Parameter(description = "The ServiceOrder to be updated" ,required=true ) @Valid @RequestBody ServiceOrderUpdate serviceOrder) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ServiceOrder by ID", operationId = "retrieveServiceOrder", description = "This operation retrieves a ServiceOrder entity. Attribute selection is enabled for all first level attributes.", tags={ "serviceOrder", }) + @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 = "/serviceOrder/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveServiceOrder( + Principal principal, + @Parameter(description = "Identifier of the ServiceOrder",required=true) @PathVariable("id") String id, + @Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + + @Operation(summary = "Get a SVG image with service order item services relationship graph", operationId = "getImageServiceOrderItemRelationshipGraph", + description = "This operation returns a SVG image with service order item services relationship graph", tags={ "serviceOrder", }) + @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 ="/serviceOrder/{id}/item/{itemid}/relationship_graph", + produces = MediaType.ALL_VALUE , + method = RequestMethod.GET) + ResponseEntity getImageServiceOrderItemRelationshipGraph( + @Parameter(description = "Identifier of the ServiceOrder",required=true) @PathVariable("id") String id, + @Parameter(description = "Identifier of the ServiceOrderItem",required=true) @PathVariable("itemid") String itemid); + + + @Operation(summary = "Get a SVG image with service order notes activity graph", operationId = "getImageServiceOrderNotesGraph", + description = "This operation returns a SVG image with service order notes activity graph", tags={ "serviceOrder", }) + @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 ="/serviceOrder/{id}/notes_graph", + produces = MediaType.ALL_VALUE , + method = RequestMethod.GET) + ResponseEntity getImageServiceOrderNotesGraph( + @Parameter(description = "Identifier of the ServiceOrder",required=true) @PathVariable("id") String id); + +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..60b5182926540c7de0c3101d617ce2f6c23e3a33 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiController.java @@ -0,0 +1,258 @@ +/*- + * ========================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.so641.api; + +import java.net.URI; +import java.security.Principal; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.so641.model.ServiceOrder; +import org.etsi.osl.tmf.so641.model.ServiceOrderCreate; +import org.etsi.osl.tmf.so641.model.ServiceOrderUpdate; +import org.etsi.osl.tmf.so641.reposervices.ServiceOrderRepoService; +import org.etsi.osl.tmf.util.AddUserAsOwnerToRelatedParties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.oauth2.jwt.Jwt; +import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import org.etsi.osl.model.nfv.UserRoleType; +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:09:58.885+03:00") + +@Controller +@RequestMapping("/serviceOrdering/v4/") +public class ServiceOrderApiController implements ServiceOrderApi { + + private static final Logger log = LoggerFactory.getLogger(ServiceOrderApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + + + @Value("${kroki.serverurl}") + private String KROKI_SERVERURL = ""; + + @Autowired + ServiceOrderRepoService serviceOrderRepoService; + + @Autowired + ServiceOrderApiRouteBuilder serviceOrderApiRouteBuilder; + + @org.springframework.beans.factory.annotation.Autowired + public ServiceOrderApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity createServiceOrder( + Principal principal, + @Parameter(description = "The ServiceOrder to be created", required = true) @Valid @RequestBody ServiceOrderCreate serviceOrder + ) { + + 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); + + serviceOrder.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser( + principal.getName(), + //user.getId()+"", + principal.getName(), + UserPartRoleType.REQUESTER, + extInfo, + serviceOrder.getRelatedParty())); + } + else if ( principal instanceof UsernamePasswordAuthenticationToken ) { + serviceOrder.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser( + principal.getName(), + //user.getId()+"", + principal.getName(), + UserPartRoleType.REQUESTER, + extInfo, + serviceOrder.getRelatedParty())); + } + + + }finally { + + } + + + + + + + ServiceOrder c = serviceOrderRepoService.addServiceOrder(serviceOrder); + + 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); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity deleteServiceOrder( + Principal principal, + @Parameter(description = "Identifier of the ServiceOrder", required = true) @PathVariable("id") String id) { + + + try { + return new ResponseEntity( serviceOrderRepoService.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); + } + + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity> listServiceOrder( + 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 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 ) { + + + try { +// Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); +// SecurityContextHolder.setContext( (SecurityContext) attr ); + + 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>(serviceOrderRepoService.findAll( fields, new HashMap<>(), starttime, endtime), HttpStatus.OK); + }else { + return new ResponseEntity>(serviceOrderRepoService.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); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity patchServiceOrder( + Principal principal, + @Parameter(description = "Identifier of the ServiceOrder", required = true) @PathVariable("id") String id, + @Parameter(description = "The ServiceOrder to be updated", required = true) @Valid @RequestBody ServiceOrderUpdate serviceOrder) { + ServiceOrder c = serviceOrderRepoService.updateServiceOrder(id, serviceOrder); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity retrieveServiceOrder( + Principal principal, + @Parameter(description = "Identifier of the ServiceOrder", required = true) @PathVariable("id") String id, + @Parameter(description = "Comma-separated properties to provide in response") @Valid @RequestParam(value = "fields", required = false) String fields) { + + try { + + return new ResponseEntity( serviceOrderRepoService.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 + public ResponseEntity getImageServiceOrderItemRelationshipGraph(String id, String itemid) { + String encodedDiagram = serviceOrderRepoService.getImageServiceOrderItemRelationshipGraph(id, itemid); + + //consider redirect to kroki..id + return ResponseEntity + .status(HttpStatus.FOUND) + .location(URI.create(KROKI_SERVERURL + "/blockdiag/svg/" + encodedDiagram)) + .build(); + //return null; + } + + @Override + public ResponseEntity getImageServiceOrderNotesGraph(String id) { + String encodedDiagram = serviceOrderRepoService.getImageServiceOrderNotesGraph(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/so641/api/ServiceOrderApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..04bec431a529799829035102dcc13f60cfb93c42 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiRouteBuilder.java @@ -0,0 +1,172 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.so641.api; + +import java.io.IOException; +import java.util.Map; + +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.so641.model.ServiceOrderCreate; +import org.etsi.osl.tmf.so641.model.ServiceOrderUpdate; +import org.etsi.osl.tmf.so641.reposervices.ServiceOrderRepoService; +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.etsi.osl.model.nfv.PortalUser; + +@Configuration +//@RefreshScope +@Component +public class ServiceOrderApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ServiceOrderApiRouteBuilder.class.getName()); + + @Value("${CATALOG_GET_SERVICEORDER_BY_ID}") + private String CATALOG_GET_SERVICEORDER_BY_ID = ""; + + @Value("${CATALOG_GET_SERVICEORDERS}") + private String CATALOG_GET_SERVICEORDERS = ""; + + @Value("${CATALOG_GET_INITIAL_SERVICEORDERS_IDS}") + private String CATALOG_GET_INITIAL_SERVICEORDERS_IDS = ""; + + @Value("${CATALOG_GET_SERVICEORDER_IDS_BY_STATE}") + private String CATALOG_GET_SERVICEORDER_IDS_BY_STATE = ""; + + @Value("${CATALOG_UPD_SERVICEORDER_BY_ID}") + private String CATALOG_UPD_SERVICEORDER_BY_ID = ""; + + @Value("${CATALOG_ADD_SERVICEORDER}") + private String CATALOG_ADD_SERVICEORDER = ""; + + + + @Value("${GET_USER_BY_USERNAME}") + private String GET_USER_BY_USERNAME = ""; + + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private ProducerTemplate template; + + @Autowired + ServiceOrderRepoService serviceOrderRepoService; + + @Autowired + private CentralLogger centralLogger; + + @Override + public void configure() throws Exception { + + from(CATALOG_GET_SERVICEORDERS).log(LoggingLevel.INFO, log, CATALOG_GET_SERVICEORDERS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean(serviceOrderRepoService, "findAllParamsJsonOrderIDs").convertBodyTo(String.class); + +// final Map propertiesMap = new HashMap(); +// propertiesMap.put("state", "INITIAL"); +// logger.info( "propertiesMap.toString() = " + propertiesMap.toString() ); + + from(CATALOG_GET_INITIAL_SERVICEORDERS_IDS) + .log(LoggingLevel.INFO, log, CATALOG_GET_INITIAL_SERVICEORDERS_IDS + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true").setBody(constant("{\"state\":\"INITIAL\"}")).unmarshal() + .json(JsonLibrary.Jackson, Map.class, true).bean(serviceOrderRepoService, "findAllParamsJsonOrderIDs") + .convertBodyTo(String.class); + + from(CATALOG_GET_SERVICEORDER_IDS_BY_STATE) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICEORDER_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(serviceOrderRepoService, "findAllParamsJsonOrderIDs").convertBodyTo(String.class); + + from(CATALOG_GET_SERVICEORDER_BY_ID) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICEORDER_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean(serviceOrderRepoService, "getServiceOrderEagerAsString").convertBodyTo(String.class); + + from(CATALOG_UPD_SERVICEORDER_BY_ID) + .log(LoggingLevel.INFO, log, CATALOG_UPD_SERVICEORDER_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true").unmarshal() + .json(JsonLibrary.Jackson, ServiceOrderUpdate.class, true) + .bean(serviceOrderRepoService, "updateServiceOrder(${header.orderid}, ${body})"); + + + from(CATALOG_ADD_SERVICEORDER) + .log(LoggingLevel.INFO, log, CATALOG_ADD_SERVICEORDER + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true").unmarshal() + .json(JsonLibrary.Jackson, ServiceOrderCreate.class, true) + .bean(serviceOrderRepoService, "addServiceOrderReturnEager(${body})") + .convertBodyTo(String.class); //creates back a response + + + } + + static String toJsonString(Object object) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + return mapper.writeValueAsString(object); + } + + /** + * get service order by id from model via bus + * @param id + * @return + * @throws IOException + */ + public PortalUser retrievePortalUser( String userName ) { + logger.info("will retrieve PortalUser from userName =" + userName ); + try { + Object response = template. + requestBody( GET_USER_BY_USERNAME, userName); + + if ( !(response instanceof String)) { + logger.error("PortalUser object is wrong."); + return null; + } + PortalUser sor = toJsonObj( (String)response, PortalUser.class); + return sor; + + }catch (Exception e) { + logger.error("Cannot retrieve PortalUser details from catalog. " + e.toString()); + } + return null; + } + + + + 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/so641/api/ServiceOrderApiRouteBuilderEvents.java b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiRouteBuilderEvents.java new file mode 100644 index 0000000000000000000000000000000000000000..ac422ef6017f1dc1b3a72b1ceb20fe16427081e7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiRouteBuilderEvents.java @@ -0,0 +1,140 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.so641.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.so641.model.ServiceOrderAttributeValueChangeNotification; +import org.etsi.osl.tmf.so641.model.ServiceOrderCreateNotification; +import org.etsi.osl.tmf.so641.model.ServiceOrderDeleteNotification; +import org.etsi.osl.tmf.so641.model.ServiceOrderStateChangeNotification; +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 ServiceOrderApiRouteBuilderEvents extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ServiceOrderApiRouteBuilderEvents.class.getName()); + + + + + @Value("${EVENT_SERVICE_ORDER_CREATE}") + private String EVENT_SERVICE_ORDER_CREATE = ""; + + @Value("${EVENT_SERVICE_ORDER_STATE_CHANGED}") + private String EVENT_SERVICE_ORDER_STATE_CHANGED = ""; + + @Value("${EVENT_SERVICE_ORDER_DELETE}") + private String EVENT_SERVICE_ORDER_DELETE = ""; + + @Value("${EVENT_SERVICE_ORDER_ATTRIBUTE_VALUE_CHANGED}") + private String EVENT_SERVICE_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 ServiceOrderCreateNotification) { + msgtopic = EVENT_SERVICE_ORDER_CREATE; + } else if ( n instanceof ServiceOrderStateChangeNotification) { + msgtopic = EVENT_SERVICE_ORDER_STATE_CHANGED; + } else if ( n instanceof ServiceOrderDeleteNotification) { + msgtopic = EVENT_SERVICE_ORDER_DELETE; + } else if ( n instanceof ServiceOrderAttributeValueChangeNotification) { + msgtopic = EVENT_SERVICE_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); + } + + + + + + 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/so641/repo/ServiceOrderRepository.java b/src/main/java/org/etsi/osl/tmf/so641/repo/ServiceOrderRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..3279fad9b700b0012c1b1e78e11d449d08bb54fc --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/repo/ServiceOrderRepository.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.so641.repo; + +import java.util.List; +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.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 { + + + Optional findByUuid(String id); + Iterable findByState( ServiceOrderStateType state); + @Query("SELECT sor FROM ServiceOrder sor JOIN FETCH sor.relatedParty rp WHERE rp.name = ?1 AND rp.role = ?2 ORDER BY sor.orderDate DESC") + Iterable findByRolenameAndRoleType(String rolename, UserPartRoleType requester); + @Query("SELECT sor FROM ServiceOrder sor JOIN FETCH sor.relatedParty rp WHERE rp.name = ?1") + Iterable findByRolename(String rolename); + + List findByOrderByOrderDateDesc(); + + @Query("SELECT sor FROM ServiceOrder sor JOIN FETCH sor.relatedParty rp ORDER BY sor.orderDate DESC") + List findAllOptimized(); + + + + @Query("SELECT sor FROM ServiceOrder sor JOIN FETCH sor.note an " + + "WHERE sor.uuid = ?1 " + + "ORDER BY an.date ASC") + Optional findNotesOfServOrder(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 new file mode 100644 index 0000000000000000000000000000000000000000..06864b4a940910bb7441faafc1281b96754588b8 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java @@ -0,0 +1,995 @@ +/*- + * ========================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.so641.reposervices; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +//import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; +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.Any; +import org.etsi.osl.tmf.common.model.EValueType; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.common.model.service.*; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +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.service.ServiceRepoService; +import org.etsi.osl.tmf.so641.api.NotFoundException; +import org.etsi.osl.tmf.so641.api.ServiceOrderApiRouteBuilderEvents; +import org.etsi.osl.tmf.so641.model.*; +import org.etsi.osl.tmf.so641.repo.ServiceOrderRepository; +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.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.TemporalType; +import jakarta.validation.Valid; +import lombok.Data; + +@Service +public class ServiceOrderRepoService { + + private static final transient Log logger = LogFactory.getLog(ServiceOrderRepoService.class.getName()); + + @Autowired + ObjectMapper objectMapper; + + @Autowired + ServiceOrderRepository serviceOrderRepo; + + @Autowired + ServiceSpecificationRepoService serviceSpecRepoService; + + @Autowired + ServiceOrderApiRouteBuilderEvents serviceOrderApiRouteBuilder; + + @Autowired + ServiceRepoService serviceRepoService; + + private SessionFactory sessionFactory; + + + @Autowired + public ServiceOrderRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + /** + * + * 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 s FROM ServiceSpecification s"; + String sql = "SELECT " + + "sor.uuid as uuid," + + "sor.orderDate as orderDate," + + "sor.requestedStartDate as requestedStartDate," + + "sor.requestedCompletionDate as requestedCompletionDate," + + "sor.startDate as startDate," + + "sor.expectedCompletionDate as expectedCompletionDate," + + "sor.state as state," + + "sor.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 ServiceOrder 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 sor.startDate >= :param1"; + + } + if ( endtime != null ) { + sql += " AND sor.expectedCompletionDate <= :param2"; + } + + sql += " ORDER BY sor.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(); + + + +// List mapaEntity = session +// .createQuery(sql ) +// .setResultTransformer( new ResultTransformer() { +// +// @Override +// public ServiceOrder transformTuple(Object[] tuple, String[] aliases) { +// //Map result = new LinkedHashMap(tuple.length); +// ServiceOrder so = new ServiceOrder(); +// so.setUuid( (String) tuple[0] ); +// so.setOrderDate( (OffsetDateTime) tuple[1] ); +// ServiceOrderItem soi = new ServiceOrderItem(); +// so.addOrderItemItem( soi ); +// ServiceRestriction service = new ServiceRestriction(); +// service.setName( (String) tuple[9] ); +// soi.setService(service ); +// +//// for (int i = 0; i < tuple.length; i++) { +//// String alias = aliases[i]; +//// if (alias.equals("type")) { +//// alias = "@type"; +//// } +//// if (alias != null) { +//// result.put(alias, tuple[i]); +//// } +//// } +// +// return so; +// } +// +// @Override +// public List transformList(List collection) { +// return collection; +// } +// } ) +// .list(); + +// //this will fetch the whole object fields +// if ( (( allParams!= null) && ( allParams.size()>0)) ) { +// List resultlist = new ArrayList<>(); +// for (ServiceSpecification s : alist) { +// resultlist.add( findByUuid( s.getUuid() )); +// } +// return resultlist; +// } + + + + return mapaEntity; + + + + + } finally { + tx.commit(); + session.close(); + } + + } + + public List findAll() { + + //return (List) this.serviceOrderRepo.findAll(); + //return (List) this.serviceOrderRepo.findByOrderByOrderDateDesc(); + return (List) this.serviceOrderRepo.findAllOptimized(); + } + + public List findAllParams(Map allParams) { + logger.info("findAll with params:" + allParams.toString()); + if ( ( allParams !=null) && allParams.get("state") !=null) { + ServiceOrderStateType state = ServiceOrderStateType.fromValue( allParams.get("state") ); + logger.info("find by state:" + state ); + return (List) this.serviceOrderRepo.findByState(state); + }else { + return findAll(); + } + + } + + public String findAllParamsJsonOrderIDs(Map allParams) throws JsonProcessingException { + List lso = findAllParams(allParams); + ArrayList oids = new ArrayList<>(); + for (ServiceOrder 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 ServiceOrder addServiceOrder(@Valid ServiceOrderCreate serviceOrderCreate) throws NotFoundException { + // Ensure that all Services Specifications exist + List serviceOrderItemList = serviceOrderCreate.getOrderItem(); + for (ServiceOrderItem serviceOrderItem: serviceOrderItemList) { + ServiceRestriction serviceRestriction = serviceOrderItem.getService(); + ServiceSpecificationRef serviceSpecificationRef = serviceRestriction.getServiceSpecification(); + String serviceSpecificationId = serviceSpecificationRef.getId(); + + ServiceSpecification serviceSpecification = serviceSpecRepoService.findByUuid(serviceSpecificationId); + + if (serviceSpecification == null) + throw new NotFoundException(400, "There is no Service Specification with Id: " + serviceSpecificationId); + } + + ServiceOrder so = new ServiceOrder(); + so.setOrderDate(OffsetDateTime.now(ZoneOffset.UTC)); + so.setCategory(serviceOrderCreate.getCategory()); + so.setDescription(serviceOrderCreate.getDescription()); + so.setExternalId(serviceOrderCreate.getExternalId()); + so.setNotificationContact(serviceOrderCreate.getNotificationContact()); + so.priority(serviceOrderCreate.getPriority()); + so.requestedCompletionDate(serviceOrderCreate.getRequestedCompletionDate()); + so.requestedStartDate(serviceOrderCreate.getRequestedStartDate() ); + so.setStartDate( serviceOrderCreate.getRequestedStartDate() ); + so.setExpectedCompletionDate( serviceOrderCreate.getRequestedCompletionDate() ); //this is by default + if (serviceOrderCreate.getNote() != null) { + so.getNote().addAll(serviceOrderCreate.getNote()); + } + + + + + boolean allAcknowledged = true; + if (serviceOrderCreate.getOrderItem() != null) { + so.getOrderItem().addAll(serviceOrderCreate.getOrderItem()); + for (ServiceOrderItem soi : so.getOrderItem()) { + //as of 18/8/2021 in service item we do not copy all service spec characteristics. The characteristics of the spec, since they are not user configurable will + //be just exist in the service instance + //copySpecCharacteristicsToServiceCharacteristic( soi.getService().getServiceSpecification().getId(), soi.getService().getServiceCharacteristic() ); + + if ( ! soi.getState().equals( ServiceOrderStateType.ACKNOWLEDGED )) { + allAcknowledged = false; + } + } + + + + } + + if (serviceOrderCreate.getRelatedParty() != null) { + so.getRelatedParty().addAll(serviceOrderCreate.getRelatedParty()); + } + if (serviceOrderCreate.getOrderRelationship() != null) { + so.getOrderRelationship().addAll(serviceOrderCreate.getOrderRelationship()); + + } + +// so = this.serviceOrderRepo.save(so); +// so = this.fixServiceOrderItemsDependencies(so); + + Note noteItem = new Note(); + noteItem.setText("Service Order " + ServiceOrderStateType.INITIAL); + noteItem.setAuthor("SO641API-addServiceOrder"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + so.addNoteItem(noteItem); + + so = this.serviceOrderRepo.save(so); + + if (allAcknowledged) { //in the case were order items are automatically acknowledged + so.setState( ServiceOrderStateType.ACKNOWLEDGED ); + so.setStartDate( OffsetDateTime.now(ZoneOffset.UTC) ); + noteItem = new Note(); + noteItem.setText("Service Order " + ServiceOrderStateType.ACKNOWLEDGED); + noteItem.setAuthor("SO641API-addServiceOrder"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + so.addNoteItem(noteItem); + + so = this.serviceOrderRepo.save(so); + } + + raiseSOCreateNotification(so); + + return so; + } + +// private ServiceOrder fixServiceOrderItemsDependencies(ServiceOrder so) { +// +// // we need to resolve service relationships for this order item +// for (ServiceOrderItem soi : so.getOrderItem()) { +// +// // find the proper service spec +// ServiceSpecification spec = serviceSpecRepoService +// .findByUuid(soi.getService().getServiceSpecification().getId()); +// soi = addResourceSpecificationRefs(soi, spec); +// soi = addBundleSpecificationRefs(soi, spec); +// +// for (ServiceSpecCharacteristic specChar : spec.getServiceSpecCharacteristic()) { +// if (specChar.isConfigurable()) { +// Characteristic serviceCharacteristicItem = new Characteristic(); +// serviceCharacteristicItem.setName(specChar.getName()); +// serviceCharacteristicItem.setValueType(specChar.getValueType()); +// for (ServiceSpecCharacteristicValue specval : specChar.getServiceSpecCharacteristicValue()) { +// if (specval.isIsDefault()) { +// serviceCharacteristicItem.setValue(specval.getValue()); +// break; +// } +// } +// soi.getService().addServiceCharacteristicItem(serviceCharacteristicItem); +// } +// } +// +// } +// return so; +// } +// +// private ServiceOrderItem addBundleSpecificationRefs(ServiceOrderItem soi, ServiceSpecification spec) { +// if (spec.isIsBundle()) { +// for (ServiceSpecRelationship specRel : spec.getServiceSpecRelationship()) { +// ServiceSpecification refServiceSpec = serviceSpecRepoService.findByUuid(specRel.getId()); +// +// ServiceRef supportingServiceItem = new ServiceRef(); +// supportingServiceItem.setId(refServiceSpec.getId()); +// supportingServiceItem.setName(refServiceSpec.getName()); +// soi.getService().addSupportingServiceItem(supportingServiceItem); +// ServiceRelationship serviceRelationshipItem = new ServiceRelationship(); +// serviceRelationshipItem.setRelationshipType(specRel.getRelationshipType()); +// serviceRelationshipItem.setService(supportingServiceItem); +// soi.getService().addServiceRelationshipItem(serviceRelationshipItem); +// +// soi = addResourceSpecificationRefs(soi, refServiceSpec); // recursive +// soi = addBundleSpecificationRefs(soi, refServiceSpec); // recursive +// } +// } +// return soi; +// } +// +// private ServiceOrderItem addResourceSpecificationRefs(ServiceOrderItem soi, ServiceSpecification spec) { +// for (ResourceSpecificationRef resSpecRef : spec.getResourceSpecification()) { +// ResourceRef supportingResourceItem = new ResourceRef(); +// supportingResourceItem.setId(resSpecRef.getId()); +// supportingResourceItem.setName(resSpecRef.getName()); +// +// soi.getService().addSupportingResourceItem(supportingResourceItem); +// } +// return soi; +// } + + + + /** + * + * will copy any remaining service spec characteristics that where not included in the initial order + * + * @param sourceSpecID + * @param destServiceCharacteristic + */ + private void copySpecCharacteristicsToServiceCharacteristic(String sourceSpecID, @Valid Set destServiceCharacteristic) { + ServiceSpecification sourceSpec = serviceSpecRepoService.findByUuid(sourceSpecID); + if ( sourceSpec == null ) { + return; + } + + for (ServiceSpecCharacteristic sourceCharacteristic : sourceSpec.getServiceSpecCharacteristic()) { + if ( sourceCharacteristic.getValueType() != null ) { + boolean charfound = false; + for (Characteristic destchar : destServiceCharacteristic) { + if ( destchar.getName().equals(sourceCharacteristic.getName())) { + charfound = true; + break; + } + } + + if (!charfound) { + + Characteristic newChar = new Characteristic(); + newChar.setName( sourceCharacteristic.getName() ); + newChar.setValueType( sourceCharacteristic.getValueType() ); + + if ( sourceCharacteristic.getValueType().equals( EValueType.ARRAY.getValue() ) || + sourceCharacteristic.getValueType().equals( EValueType.SET.getValue() ) ) { + String valString = ""; + for (ServiceSpecCharacteristicValue specchar : sourceCharacteristic.getServiceSpecCharacteristicValue()) { + if ( ( specchar.isIsDefault()!= null) && specchar.isIsDefault() ) { + if ( !valString.equals("")) { + valString = valString + ","; + } + valString = valString + "{\"value\":\"" + specchar.getValue().getValue() + "\",\"alias\":\"" + specchar.getValue().getAlias() + "\"}"; + } + + } + + newChar.setValue( new Any( "[" + valString + "]", "") ); + + + } else { + for (ServiceSpecCharacteristicValue specchar : sourceCharacteristic.getServiceSpecCharacteristicValue()) { + if ( ( specchar.isIsDefault()!= null) && specchar.isIsDefault() ) { + newChar.setValue( new Any( + specchar.getValue().getValue(), + specchar.getValue().getAlias()) ); + break; + }else { + if (specchar.isIsDefault()== null){ + + logger.info("specchar is null value: " + sourceCharacteristic.getName() ); + } + } + + } + } + + //sourceCharacteristic.getServiceSpecCharacteristicValue() + + if ( newChar.getValue() !=null) { + destServiceCharacteristic.add(newChar ); + } + + } + + } + + + } + + } + + @Transactional + public ServiceOrder updateServiceOrder(String id, @Valid ServiceOrderUpdate serviceOrderUpd) { + + logger.info("Will updateServiceOrder:" + id); + + ServiceOrder so = this.findByUuid(id); + boolean stateChanged = false; + boolean expectedCompletionDateChanged = false; + + //logger.info("so:" + so.toString()); + for (ServiceOrderItem oi : so.getOrderItem() ) { + logger.debug( "(oi.getId() = "+oi.getId() ); + + } + if ( serviceOrderUpd.getState()!= null ) { + + + + stateChanged = so.getState() != serviceOrderUpd.getState(); + so.setState( serviceOrderUpd.getState() ); + + if ( so.getState().equals( ServiceOrderStateType.COMPLETED )) { + so.setCompletionDate( OffsetDateTime.now(ZoneOffset.UTC)); + } + + + + + + + + } + if ( serviceOrderUpd.getCategory()!= null ) { + so.setCategory(serviceOrderUpd.getCategory()); + + } + + if ( serviceOrderUpd.getDescription()!= null ) { + so.setDescription(serviceOrderUpd.getDescription()); + + } + + if ( serviceOrderUpd.getNotificationContact()!= null ) { + so.setNotificationContact(serviceOrderUpd.getNotificationContact()); + + } + + if ( serviceOrderUpd.getRequestedCompletionDate()!= null ) { + so.requestedCompletionDate(serviceOrderUpd.getRequestedCompletionDate()); + + } + + if ( serviceOrderUpd.getRequestedStartDate()!= null ) { + so.requestedStartDate(serviceOrderUpd.getRequestedStartDate()); + + } + + if ( serviceOrderUpd.getExpectedCompletionDate()!= null ) { + so.setExpectedCompletionDate(serviceOrderUpd.getExpectedCompletionDate()); + expectedCompletionDateChanged = true; + } + + if ( serviceOrderUpd.getStartDate()!= null ) { + so.setStartDate(serviceOrderUpd.getStartDate()); + + } + + + if ( serviceOrderUpd.getOrderItem() != null ) { + for (ServiceOrderItem soiUpd : serviceOrderUpd.getOrderItem()) { + ServiceOrderItem soiOrigin = so.findOrderItemById( soiUpd.getId() ); + if (soiOrigin!=null) { + updateOrderItem(soiOrigin, soiUpd); + /** + * When we patch the order and see a MODIFY or DELETE action, we set the state to ACKNOWLEDGED + */ + if ( soiOrigin.getAction().equals( ServiceOrderActionType.MODIFY ) || + soiOrigin.getAction().equals( ServiceOrderActionType.DELETE )) { + soiOrigin.setState( ServiceOrderStateType.ACKNOWLEDGED ); + so.setState( ServiceOrderStateType.ACKNOWLEDGED ); + + + } + + } + } + } + + + + + if (serviceOrderUpd.getNote() != null) { + for (Note n : serviceOrderUpd.getNote()) { + if (n.getUuid() == null) { + so.addNoteItem(n); + } + } + + } + + if (serviceOrderUpd.getRelatedParty() != null) { + for (RelatedParty n : serviceOrderUpd.getRelatedParty()) { + if (n.getUuid() == null) { + so.addRelatedPartyItem(n); + } + } + } + if (serviceOrderUpd.getOrderRelationship() != null) { + for (ServiceOrderRelationship n : serviceOrderUpd.getOrderRelationship()) { + if (n.getUuid() == null) { + so.addOrderRelationshipItem(n); + } + } + } + + + if ( stateChanged ) { + Note noteItem = new Note(); + noteItem.setText("Service Order " + so.getState() ); + noteItem.setAuthor("SO641API-stateChanged"); + noteItem.setDate(OffsetDateTime.now(ZoneOffset.UTC) ); + so.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 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()); + } + } + + + + so = this.serviceOrderRepo.save(so); + if (stateChanged) { + raiseSOStateChangedNotification(so); + } else { + raiseSOAttributeValueChangedNotification(so); + } + + return so; + } + + + + + private void updateOrderItem(ServiceOrderItem soiOrigin, ServiceOrderItem soiUpd) { + + if ( soiUpd.getAction()!=null) { + soiOrigin.setAction( soiUpd.getAction() ); + } + + if ( soiUpd.getState()!=null) { + soiOrigin.setState( soiUpd.getState() ); + } + + if ( soiUpd.getService() !=null) { + if ( soiOrigin.getService() == null) { + soiOrigin.setService(soiUpd.getService()); + } else { + soiOrigin.getService().setState( soiUpd.getService().getState() );//this probably will change only + soiOrigin.getService().setName( soiUpd.getService().getName() ); + + + for (Characteristic updChar : soiUpd.getService().getServiceCharacteristic() ) { + String charname = updChar.getName(); + Characteristic originChar = soiOrigin.getService().findCharacteristicByName ( charname ); + if ( ( originChar != null ) && ( updChar != null ) && ( originChar.getValue() != null ) &&( originChar.getValue().getValue() != null ) && ( updChar.getValue() != null ) ) { + if ( !originChar.getValue().getValue().equals( updChar.getValue().getValue() ) ) { + originChar.setValue( new Any( updChar.getValue() ) ); + } + } else if ( ( originChar != null ) && ( originChar.getValue() == null ) && ( updChar.getValue() != null ) ) { + originChar.setValue( new Any( updChar.getValue() ) ); + } + } + + //we need also to update supportingServices + for (ServiceRef serviceRef : soiUpd.getService().getSupportingService()) { + if ( soiOrigin.getService().getSupportingServiceById(serviceRef.getId() ) == null ) { + soiOrigin.getService().addSupportingServiceItem(serviceRef); + } + } + + for (ResourceRef resourceRef : soiUpd.getService().getSupportingResource()) { + if ( soiOrigin.getService().getSupportingResourceById(resourceRef.getId() ) == null ) { + soiOrigin.getService().addSupportingResourceItem(resourceRef) ; + } + } + + + } + } + } + + + + + public ServiceOrder findByUuid(String id) { + Optional optionalCat = this.serviceOrderRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + + public String getServiceOrderEagerAsString(String id) throws JsonProcessingException { + ServiceOrder s = this.getServiceORderEager(id); + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new Hibernate5JakartaModule()); + String res = mapper.writeValueAsString(s); + + return res; + } + + public ServiceOrder getServiceORderEager(String id) { + + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + + try { + ServiceOrder s = null; + try { + s = (ServiceOrder) session.get(ServiceOrder.class, id); + if (s == null) { + return this.findByUuid(id);// last resort + } + + Hibernate.initialize(s.getRelatedParty()); + Hibernate.initialize(s.getOrderItem() ); + Hibernate.initialize(s.getNote() ); + for (ServiceOrderItem soi : s.getOrderItem()) { + Hibernate.initialize( soi.getService().getSupportingService() ); + Hibernate.initialize( soi.getService().getSupportingResource()); + Hibernate.initialize( soi.getService().getServiceCharacteristic() ); + Hibernate.initialize( soi.getService().getRelatedParty() ); + } + + tx.commit(); + } finally { + session.close(); + } + + return s; + } catch (Exception e) { + // TODO: handle exception + } + + session.close(); + return null; + + + } + + @Transactional + private void raiseSOCreateNotification(ServiceOrder so) { + ServiceOrderCreateNotification n = new ServiceOrderCreateNotification(); + ServiceOrderCreateEvent event = new ServiceOrderCreateEvent(); + event.serviceOrder( so ); + n.setEvent(event ); + serviceOrderApiRouteBuilder.publishEvent(n, so.getId()); + + } + + @Transactional + private void raiseSOStateChangedNotification(ServiceOrder so) { + ServiceOrderStateChangeNotification n = new ServiceOrderStateChangeNotification(); + ServiceOrderStateChangeEvent event = new ServiceOrderStateChangeEvent(); + //event.serviceOrder( getServiceORderEager( so.getId()) ); + event.serviceOrder( so ); + n.setEvent(event ); + serviceOrderApiRouteBuilder.publishEvent(n, so.getId()); + + } + + @Transactional + private void raiseSOAttributeValueChangedNotification(ServiceOrder so) { + ServiceOrderAttributeValueChangeNotification n = new ServiceOrderAttributeValueChangeNotification(); + ServiceOrderAttributeValueChangeEvent event = new ServiceOrderAttributeValueChangeEvent(); + event.serviceOrder( so ); + n.setEvent(event ); + serviceOrderApiRouteBuilder.publishEvent(n, so.getId()); + + } + + public List findAll(String rolename, UserPartRoleType requester) { +// return (List) this.serviceOrderRepo.findByRolenameAndRoleType(rolename, requester); + return (List) this.serviceOrderRepo.findByRolename(rolename); + } + + public Void deleteByUuid(String id) { + + Optional optso = this.serviceOrderRepo.findByUuid(id); + ServiceOrder so = optso.get(); + if ( so == null ) { + return null; + } + + this.serviceOrderRepo.delete(so); + return null; + } + + public String addServiceOrderReturnEager(@Valid ServiceOrderCreate serviceOrderCreate) { + try { + ServiceOrder so = this.addServiceOrder(serviceOrderCreate); + return this.getServiceOrderEagerAsString( so.getUuid()); + } catch (JsonProcessingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + public String getImageServiceOrderItemRelationshipGraph(String id, String itemid) { + + ServiceOrder so = this.findByUuid(id); + String charvalue = null; + if ( so!=null) { + for (ServiceOrderItem soiOrigin : so.getOrderItem()) { + if ( soiOrigin.getId().equals(itemid)) { + charvalue = createItemRelationshipGraphNotation( soiOrigin ); + +// Characteristic gnchar = soiOrigin.getService().findCharacteristicByName ( "SOITEM_GRAPH_NOTATION" ); +// if ( gnchar == null ) { +// Characteristic serviceCharacteristicItem = new Characteristic(); +// serviceCharacteristicItem.setName( "SOITEM_GRAPH_NOTATION" ); +// serviceCharacteristicItem.setValue( new Any( charvalue , "SOITEM_GRAPH_NOTATION" ) ); +// serviceCharacteristicItem.setValueType( EValueType.LONGTEXT.getValue() ); +// soiOrigin.getService().addServiceCharacteristicItem( serviceCharacteristicItem ); + // +// } else { +// gnchar.setValue( new Any( charvalue , "SOITEM_GRAPH_NOTATION" ) ); +// } + } + + } + } + + return KrokiClient.encodedGraph( charvalue ); + } + + + + private String createItemRelationshipGraphNotation( ServiceOrderItem soiOrigin ) { + String result = getSOItemGraphNotation(soiOrigin, 0 ); + result = "blockdiag {" + + "default_textcolor = white;\r\n" + + "default_fontsize = 12;\r\n" + + "\r\n" + result + "}"; + return result; + } + + + + private String getSOItemGraphNotation(ServiceOrderItem soiOrigin, int depth) { + String result = ""; + 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"; + 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() ) { + 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"; + 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 getImageServiceOrderNotesGraph(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.serviceOrderRepo.findNotesOfServOrder(id); + if ( optionalCat.isPresent() ) { + + ServiceOrder 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/sqm657/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..fa613176c685dbf5220cf7896eb70861c5a52d6f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/ApiException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.sqm657.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +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/sqm657/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..eadacc8dd20a1cc7e2d46eb4b763d14e6a0b653c --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/ApiOriginFilter.java @@ -0,0 +1,51 @@ +/*- + * ========================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.sqm657.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.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +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/sqm657/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..548f0e9680e539e022021f653f095e6f4caf7148 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/ApiResponseMessage.java @@ -0,0 +1,89 @@ +/*- + * ========================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.sqm657.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +@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/sqm657/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..0ecc8b0b7629552daad737483d9db558b6048cfb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.sqm657.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.sqm657.model.EventSubscription; +import org.etsi.osl.tmf.sqm657.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput data) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"query\" : \"query\", \"callback\" : \"callback\", \"id\" : \"id\"}", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sqm657/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..273698960d77cbefad65351ee127b5bf002c7d3f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/HubApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.sqm657.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +@Controller("HubApiController657") +@RequestMapping("/serviceQualityManagement/v2/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sqm657/api/NotFoundException.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..221fbb228ac6b221f208e3c9f933b9e971879119 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/NotFoundException.java @@ -0,0 +1,30 @@ +/*- + * ========================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.sqm657.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +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/sqm657/api/RFC3339DateFormat.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/RFC3339DateFormat.java new file mode 100644 index 0000000000000000000000000000000000000000..806eeaccc757d5d8507de6b383c4a108cbce2ffa --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/RFC3339DateFormat.java @@ -0,0 +1,41 @@ +/*- + * ========================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.sqm657.api; + +import java.text.FieldPosition; +import java.util.Date; + +import com.fasterxml.jackson.databind.util.ISO8601DateFormat; +import com.fasterxml.jackson.databind.util.ISO8601Utils; + + +public class RFC3339DateFormat extends ISO8601DateFormat { + + private static final long serialVersionUID = 1L; + + // Same as ISO8601DateFormat but serializing milliseconds. + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + String value = ISO8601Utils.format(date, true); + toAppendTo.append(value); + return toAppendTo; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelObjectiveApi.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelObjectiveApi.java new file mode 100644 index 0000000000000000000000000000000000000000..2d6b1cddcfb4a998ef3f4cb9775c806de6080c1f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelObjectiveApi.java @@ -0,0 +1,216 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.sqm657.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.sqm657.model.ServiceLevelObjective; +import org.etsi.osl.tmf.sqm657.model.ServiceLevelObjectiveCreate; +import org.etsi.osl.tmf.sqm657.model.ServiceLevelObjectiveUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +@Tag(name = "serviceLevelObjective", description = "the serviceLevelObjective API") +public interface ServiceLevelObjectiveApi { + + Logger log = LoggerFactory.getLogger(ServiceLevelObjectiveApi.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 'ServiceLevelObjective'", operationId = "createServiceLevelObjective", description = "", tags={ "serviceLevelObjective", }) + @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 = "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 = "/serviceLevelObjective", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createServiceLevelObjective(@Parameter(description = "The Service Level Objective to be created" ,required=true ) @Valid @RequestBody ServiceLevelObjectiveCreate serviceLevelObjective) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"specConsequence\" : [ { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"conformanceComparator\" : \"conformanceComparator\", \"graceTimes\" : \"graceTimes\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"specParameter\" : { \"serviceParmCategory\" : \"serviceParmCategory\", \"transformationAlgorithmOfKQI\" : \"transformationAlgorithmOfKQI\", \"serviceParmPerspective\" : \"serviceParmPerspective\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedEntity\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"name\" : \"name\", \"type\" : \"type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"conformanceTarget\" : \"conformanceTarget\", \"toleranceTarget\" : \"toleranceTarget\", \"@baseType\" : \"@baseType\", \"tolerancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"name\" : \"name\", \"conformancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"thresholdTarget\" : \"thresholdTarget\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"}", ServiceLevelObjective.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 ServiceLevelObjectiveApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a 'ServiceLevelObjective' by Id", operationId = "deleteServiceLevelObjective", description = "", tags={ "serviceLevelObjective", }) + @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 = "/serviceLevelObjective/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteServiceLevelObjective(@Parameter(description = "Identifier of the Service Level Objective",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ServiceLevelObjectiveApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find 'ServiceLevelObjective' objects", operationId = "listServiceLevelObjective", description = "" , tags={ "serviceLevelObjective", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/serviceLevelObjective", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> listServiceLevelObjective(@Parameter(description = "Comma separated properties to display 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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"specConsequence\" : [ { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"conformanceComparator\" : \"conformanceComparator\", \"graceTimes\" : \"graceTimes\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"specParameter\" : { \"serviceParmCategory\" : \"serviceParmCategory\", \"transformationAlgorithmOfKQI\" : \"transformationAlgorithmOfKQI\", \"serviceParmPerspective\" : \"serviceParmPerspective\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedEntity\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"name\" : \"name\", \"type\" : \"type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"conformanceTarget\" : \"conformanceTarget\", \"toleranceTarget\" : \"toleranceTarget\", \"@baseType\" : \"@baseType\", \"tolerancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"name\" : \"name\", \"conformancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"thresholdTarget\" : \"thresholdTarget\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"}, { \"specConsequence\" : [ { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"conformanceComparator\" : \"conformanceComparator\", \"graceTimes\" : \"graceTimes\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"specParameter\" : { \"serviceParmCategory\" : \"serviceParmCategory\", \"transformationAlgorithmOfKQI\" : \"transformationAlgorithmOfKQI\", \"serviceParmPerspective\" : \"serviceParmPerspective\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedEntity\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"name\" : \"name\", \"type\" : \"type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"conformanceTarget\" : \"conformanceTarget\", \"toleranceTarget\" : \"toleranceTarget\", \"@baseType\" : \"@baseType\", \"tolerancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"name\" : \"name\", \"conformancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"thresholdTarget\" : \"thresholdTarget\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ServiceLevelObjectiveApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a 'ServiceLevelObjective' by Id", operationId = "patchServiceLevelObjective", description = "", tags={ "serviceLevelObjective", }) + @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 = "/serviceLevelObjective/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.PATCH) + default ResponseEntity patchServiceLevelObjective(@Parameter(description = "Identifier of the Service Level Objective",required=true) @PathVariable("id") String id,@Parameter(description = "The Service Level Objective to be updated" ,required=true ) @Valid @RequestBody ServiceLevelObjectiveUpdate serviceLevelObjective) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"specConsequence\" : [ { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"conformanceComparator\" : \"conformanceComparator\", \"graceTimes\" : \"graceTimes\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"specParameter\" : { \"serviceParmCategory\" : \"serviceParmCategory\", \"transformationAlgorithmOfKQI\" : \"transformationAlgorithmOfKQI\", \"serviceParmPerspective\" : \"serviceParmPerspective\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedEntity\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"name\" : \"name\", \"type\" : \"type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"conformanceTarget\" : \"conformanceTarget\", \"toleranceTarget\" : \"toleranceTarget\", \"@baseType\" : \"@baseType\", \"tolerancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"name\" : \"name\", \"conformancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"thresholdTarget\" : \"thresholdTarget\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"}", ServiceLevelObjective.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 ServiceLevelObjectiveApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a 'ServiceLevelObjective' by Id", operationId = "retrieveServiceLevelObjective", description = "" , tags={ "serviceLevelObjective", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/serviceLevelObjective/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> retrieveServiceLevelObjective(@Parameter(description = "Identifier of the Service Level Objective",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"specConsequence\" : [ { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"conformanceComparator\" : \"conformanceComparator\", \"graceTimes\" : \"graceTimes\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"specParameter\" : { \"serviceParmCategory\" : \"serviceParmCategory\", \"transformationAlgorithmOfKQI\" : \"transformationAlgorithmOfKQI\", \"serviceParmPerspective\" : \"serviceParmPerspective\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedEntity\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"name\" : \"name\", \"type\" : \"type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"conformanceTarget\" : \"conformanceTarget\", \"toleranceTarget\" : \"toleranceTarget\", \"@baseType\" : \"@baseType\", \"tolerancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"name\" : \"name\", \"conformancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"thresholdTarget\" : \"thresholdTarget\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"}, { \"specConsequence\" : [ { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" }, { \"prescribedAction\" : \"prescribedAction\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"@schemaLocation\" : \"@schemaLocation\" } ], \"conformanceComparator\" : \"conformanceComparator\", \"graceTimes\" : \"graceTimes\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"specParameter\" : { \"serviceParmCategory\" : \"serviceParmCategory\", \"transformationAlgorithmOfKQI\" : \"transformationAlgorithmOfKQI\", \"serviceParmPerspective\" : \"serviceParmPerspective\", \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"relatedEntity\" : [ { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"name\" : \"name\", \"href\" : \"href\", \"id\" : \"id\" } ], \"name\" : \"name\", \"type\" : \"type\", \"@schemaLocation\" : \"@schemaLocation\" }, \"conformanceTarget\" : \"conformanceTarget\", \"toleranceTarget\" : \"toleranceTarget\", \"@baseType\" : \"@baseType\", \"tolerancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"name\" : \"name\", \"conformancePeriod\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"thresholdTarget\" : \"thresholdTarget\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\"} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ServiceLevelObjectiveApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelObjectiveApiController.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelObjectiveApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..61ab1e4986005b619de3fd829bc22f025ba38156 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelObjectiveApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.sqm657.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +@Controller +@RequestMapping("/serviceQualityManagement/v2/") +public class ServiceLevelObjectiveApiController implements ServiceLevelObjectiveApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ServiceLevelObjectiveApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelSpecificationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..4b700a443ffd130dc6eca00791fb29e78084eca4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelSpecificationApi.java @@ -0,0 +1,216 @@ +/*- + * ========================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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (2.4.9). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.sqm657.api; + +import java.io.IOException; +import java.util.List; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.sqm657.model.ServiceLevelSpecification; +import org.etsi.osl.tmf.sqm657.model.ServiceLevelSpecificationCreate; +import org.etsi.osl.tmf.sqm657.model.ServiceLevelSpecificationUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +@Tag(name = "serviceLevelSpecification", description = "the serviceLevelSpecification API") +public interface ServiceLevelSpecificationApi { + + Logger log = LoggerFactory.getLogger(ServiceLevelSpecificationApi.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 'ServiceLevelSpecification'", operationId = "createServiceLevelSpecification", description = "", tags={ "serviceLevelSpecification", }) + @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 = "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 = "/serviceLevelSpecification", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createServiceLevelSpecification(@Parameter(description = "The Service Level Specification to be created" ,required=true ) @Valid @RequestBody ServiceLevelSpecificationCreate serviceLevelSpecification) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]}", ServiceLevelSpecification.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 ServiceLevelSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a 'ServiceLevelSpecification' by Id", operationId = "deleteServiceLevelSpecification", description = "", tags={ "serviceLevelSpecification", }) + @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 = "/serviceLevelSpecification/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteServiceLevelSpecification(@Parameter(description = "Identifier of the Service Level Specification",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ServiceLevelSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find 'ServiceLevelSpecification' objects", operationId = "listServiceLevelSpecification", description = "" , tags={ "serviceLevelSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/serviceLevelSpecification", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> listServiceLevelSpecification(@Parameter(description = "Comma separated properties to display 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) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]}, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ServiceLevelSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a 'ServiceLevelSpecification' by Id", operationId = "patchServiceLevelSpecification", description = "", tags={ "serviceLevelSpecification", }) + @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 = "/serviceLevelSpecification/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.PATCH) + default ResponseEntity patchServiceLevelSpecification(@Parameter(description = "Identifier of the Service Level Specification",required=true) @PathVariable("id") String id,@Parameter(description = "The Service Level Specification to be updated" ,required=true ) @Valid @RequestBody ServiceLevelSpecificationUpdate serviceLevelSpecification) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]}", ServiceLevelSpecification.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 ServiceLevelSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a 'ServiceLevelSpecification' by Id", operationId = "retrieveServiceLevelSpecification", description = "" , tags={ "serviceLevelSpecification", }) + @ApiResponses(value = { + @ApiResponse(responseCode ="200", description = "Ok" ), + @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 = "/serviceLevelSpecification/{id}", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> retrieveServiceLevelSpecification(@Parameter(description = "Identifier of the Service Level Specification",required=true) @PathVariable("id") String id) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]}, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]} ]", 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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ServiceLevelSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelSpecificationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..0810034cb9d49156bea6cf3c58d93e986ca028a0 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/sqm657/api/ServiceLevelSpecificationApiController.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 openslice.io + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * =========================LICENSE_END================================== + */ +package org.etsi.osl.tmf.sqm657.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-10-19T00:14:31.369+03:00") + +@Controller +@RequestMapping("/serviceQualityManagement/v2/") +public class ServiceLevelSpecificationApiController implements ServiceLevelSpecificationApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public ServiceLevelSpecificationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/stm653/api/ApiException.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ApiException.java new file mode 100644 index 0000000000000000000000000000000000000000..266fbbdcc73f4d8dc2733b0251dc49c1b036b4eb --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ApiException.java @@ -0,0 +1,29 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.api; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-08T11:50:07.226173200+02: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/stm653/api/ApiOriginFilter.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ApiOriginFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..603bb9d3aaafed3f3c4b24c2627fd98fe0595c70 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ApiOriginFilter.java @@ -0,0 +1,50 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.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 = "2021-02-08T11:50:07.226173200+02: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/stm653/api/ApiResponseMessage.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ApiResponseMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..4e023718bb8c9614ec72798c50354134a4bf8114 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ApiResponseMessage.java @@ -0,0 +1,88 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.api; + +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-08T11:50:07.226173200+02: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/stm653/api/HubApi.java b/src/main/java/org/etsi/osl/tmf/stm653/api/HubApi.java new file mode 100644 index 0000000000000000000000000000000000000000..b5760a8ce5381ad8041a8fa97ae24d0974b38e41 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/HubApi.java @@ -0,0 +1,119 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.stm653.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.stm653.model.EventSubscription; +import org.etsi.osl.tmf.stm653.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.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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-08T11:50:07.226173200+02:00[Europe/Athens]") +@Tag(name = "hub", description = "the hub API") +public interface HubApi { + + Logger log = LoggerFactory.getLogger(HubApi.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 = "Register a listener", operationId = "registerListener", 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 = "400", description = "Subscribed" ), + @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 = "/hub", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity registerListener(@Parameter(description = "Data containing the callback endpoint to deliver the information" ,required=true ) @Valid @RequestBody EventSubscriptionInput body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Unregister a listener", operationId = "unregisterListener", 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" ), + @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 = "500", description = "Internal Server Error" ) }) + @RequestMapping(value = "/hub/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity unregisterListener(@Parameter(description = "The id of the registered listener",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default HubApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/stm653/api/HubApiController.java b/src/main/java/org/etsi/osl/tmf/stm653/api/HubApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..57c22b5bec62de1c6e4a1131826d7667464ecdc5 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/HubApiController.java @@ -0,0 +1,55 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-08T11:50:07.226173200+02:00[Europe/Athens]") +@Controller("HubApiController653") +@RequestMapping("/serviceTestManagement/v4/") +public class HubApiController implements HubApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/stm653/api/ListenerApi.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ListenerApi.java new file mode 100644 index 0000000000000000000000000000000000000000..662793e39c15626e08dcc2a310cb5f4a32437b8f --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ListenerApi.java @@ -0,0 +1,261 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.stm653.api; + +import java.io.IOException; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.stm653.model.EventSubscription; +import org.etsi.osl.tmf.stm653.model.ServiceTestAttributeValueChangeEvent; +import org.etsi.osl.tmf.stm653.model.ServiceTestCreateEvent; +import org.etsi.osl.tmf.stm653.model.ServiceTestDeleteEvent; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationAttributeValueChangeEvent; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationCreateEvent; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationDeleteEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-08T11:50:07.226173200+02:00[Europe/Athens]") +@Tag(name = "listener", description = "the listener API") +public interface ListenerApi { + + Logger log = LoggerFactory.getLogger(ListenerApi.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 = "Client listener for entity ServiceTestAttributeValueChangeEvent", operationId = "listenToServiceTestAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification ServiceTestAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceTestAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceTestAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceTestAttributeValueChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceTestCreateEvent", operationId = "listenToServiceTestCreateEvent", description = "Example of a client listener for receiving the notification ServiceTestCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceTestCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceTestCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceTestCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceTestDeleteEvent", operationId = "listenToServiceTestDeleteEvent", description = "Example of a client listener for receiving the notification ServiceTestDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceTestDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceTestDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceTestDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceTestSpecificationAttributeValueChangeEvent", operationId = "listenToServiceTestSpecificationAttributeValueChangeEvent", description = "Example of a client listener for receiving the notification ServiceTestSpecificationAttributeValueChangeEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceTestSpecificationAttributeValueChangeEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceTestSpecificationAttributeValueChangeEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceTestSpecificationAttributeValueChangeEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceTestSpecificationCreateEvent", operationId = "listenToServiceTestSpecificationCreateEvent", description = "Example of a client listener for receiving the notification ServiceTestSpecificationCreateEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceTestSpecificationCreateEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceTestSpecificationCreateEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceTestSpecificationCreateEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Client listener for entity ServiceTestSpecificationDeleteEvent", operationId = "listenToServiceTestSpecificationDeleteEvent", description = "Example of a client listener for receiving the notification ServiceTestSpecificationDeleteEvent", tags={ "notification listeners (client side)", }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Notified" ), + @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 = "/listener/serviceTestSpecificationDeleteEvent", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity listenToServiceTestSpecificationDeleteEvent(@Parameter(description = "The event data" ,required=true ) @Valid @RequestBody ServiceTestSpecificationDeleteEvent body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ListenerApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/stm653/api/ListenerApiController.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ListenerApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..72566defce213f490713fcd2aeef2df7b78a708d --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ListenerApiController.java @@ -0,0 +1,55 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.api; + +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import jakarta.servlet.http.HttpServletRequest; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-08T11:50:07.226173200+02:00[Europe/Athens]") +@Controller("ListenerApiController653") +@RequestMapping("/serviceTestManagement/v4/") +public class ListenerApiController implements ListenerApi { + + 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; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestApi.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestApi.java new file mode 100644 index 0000000000000000000000000000000000000000..ce6e2d8c38e0d52cf495882832ebac1d01d081b9 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestApi.java @@ -0,0 +1,222 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.stm653.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.stm653.model.ServiceTest; +import org.etsi.osl.tmf.stm653.model.ServiceTestCreate; +import org.etsi.osl.tmf.stm653.model.ServiceTestUpdate; +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; +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-08T11:50:07.226173200+02:00[Europe/Athens]") +@Tag(name = "serviceTest", description = "the serviceTest API") +public interface ServiceTestApi { + + Logger log = LoggerFactory.getLogger(ServiceTestApi.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 ServiceTest", operationId = "createServiceTest", description = "This operation creates a ServiceTest entity.", tags={ "serviceTest", }) + @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 = "/serviceTest", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.POST) + default ResponseEntity createServiceTest(@Parameter(description = "The ServiceTest to be created" ,required=true ) @Valid @RequestBody ServiceTestCreate body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\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 \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"testMeasure\" : [ {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n }, {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n } ],\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\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 \"relatedService\" : {\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 },\r\n \"characteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"testSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"mode\" : \"mode\",\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"http://example.com/aeiou\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ServiceTest.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 ServiceTestApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a ServiceTest", operationId = "deleteServiceTest", description = "This operation deletes a ServiceTest entity.", tags={ "serviceTest", }) + @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 = "/serviceTest/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.DELETE) + default ResponseEntity deleteServiceTest(@Parameter(description = "Identifier of the ServiceTest",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ServiceTestApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "List or find ServiceTest objects", operationId = "listServiceTest", description = "This operation list or find ServiceTest entities" , tags={ "serviceTest", }) + @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 = "/serviceTest", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity> listServiceTest(@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("[ {\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 \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"testMeasure\" : [ {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n }, {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n } ],\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\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 \"relatedService\" : {\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 },\r\n \"characteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"testSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"mode\" : \"mode\",\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"http://example.com/aeiou\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}, {\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 \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"testMeasure\" : [ {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n }, {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n } ],\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\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 \"relatedService\" : {\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 },\r\n \"characteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"testSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"mode\" : \"mode\",\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"http://example.com/aeiou\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\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); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default ServiceTestApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates partially a ServiceTest", operationId = "patchServiceTest", description = "This operation updates partially a ServiceTest entity.", tags={ "serviceTest", }) + @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 = "/serviceTest/{id}", + produces = { "application/json;charset=utf-8" }, + consumes = { "application/json;charset=utf-8" }, + method = RequestMethod.PATCH) + default ResponseEntity patchServiceTest(@Parameter(description = "The ServiceTest to be updated" ,required=true ) @Valid @RequestBody ServiceTestUpdate body +,@Parameter(description = "Identifier of the ServiceTest",required=true) @PathVariable("id") String id +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\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 \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"testMeasure\" : [ {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n }, {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n } ],\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\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 \"relatedService\" : {\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 },\r\n \"characteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"testSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"mode\" : \"mode\",\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"http://example.com/aeiou\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ServiceTest.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 ServiceTestApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Retrieves a ServiceTest by ID", operationId = "retrieveServiceTest", description = "This operation retrieves a ServiceTest entity. Attribute selection is enabled for all first level attributes.", tags={ "serviceTest", }) + @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 = "/serviceTest/{id}", + produces = { "application/json;charset=utf-8" }, + method = RequestMethod.GET) + default ResponseEntity retrieveServiceTest(@Parameter(description = "Identifier of the ServiceTest",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("{\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 \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"testMeasure\" : [ {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n }, {\r\n \"metricDescription\" : \"metricDescription\",\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"captureDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@type\" : \"@type\",\r\n \"accuracy\" : 0.8008282,\r\n \"captureMethod\" : \"captureMethod\",\r\n \"ruleViolation\" : [ {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n }, {\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"appliedConsequence\" : [ {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"appliedAction\" : \"appliedAction\",\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"@baseType\" : \"@baseType\",\r\n \"tolerancePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"numberOfAllowedCrossing\" : 6,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\",\r\n \"conformanceTargetExact\" : \"conformanceTargetExact\"\r\n } ],\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"metricHref\" : \"metricHref\"\r\n } ],\r\n \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\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 \"relatedService\" : {\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 },\r\n \"characteristic\" : [ {\r\n \"characteristicRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"id\" : \"id\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"id\" : \"id\"\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 \"testSpecification\" : {\r\n \"@referredType\" : \"@referredType\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"id\" : \"id\",\r\n \"href\" : \"href\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"version\" : \"version\"\r\n },\r\n \"mode\" : \"mode\",\r\n \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"@baseType\" : \"@baseType\",\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"href\" : \"http://example.com/aeiou\",\r\n \"state\" : \"state\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", ServiceTest.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 ServiceTestApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestApiController.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..b7fb0378d7a8e69bde4af593b3c48661cfbf52b4 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestApiController.java @@ -0,0 +1,186 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.api; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.centrallog.client.CLevel; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.stm653.model.ServiceTest; +import org.etsi.osl.tmf.stm653.model.ServiceTestCreate; +import org.etsi.osl.tmf.stm653.model.ServiceTestUpdate; +import org.etsi.osl.tmf.stm653.reposervices.ServiceTestRepoService; +import org.etsi.osl.tmf.util.AddUserAsOwnerToRelatedParties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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.core.Authentication; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +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 = "2021-02-08T11:50:07.226173200+02:00[Europe/Athens]") +@Controller +@RequestMapping("/serviceTestManagement/v4/") +public class ServiceTestApiController implements ServiceTestApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + + private static final Logger log = LoggerFactory.getLogger(ServiceTestApiController.class); + + + @Autowired + ServiceTestRepoService serviceTestRepoService; + + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private CentralLogger centralLogger; + + @org.springframework.beans.factory.annotation.Autowired + public ServiceTestApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity createServiceTest(@Valid ServiceTestCreate serviceTest) { + try { + + serviceTest.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser( + SecurityContextHolder.getContext().getAuthentication().getName(), + SecurityContextHolder.getContext().getAuthentication().getName(), UserPartRoleType.OWNER, "", + serviceTest.getRelatedParty())); + + ServiceTest c = serviceTestRepoService + .addServiceTest(serviceTest); + + return new ResponseEntity(c, 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 deleteServiceTest(String id) { + try { + + return new ResponseEntity(serviceTestRepoService.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> listServiceTest(@Valid String fields, @Valid Integer offset, + @Valid Integer limit, + @Parameter(hidden = true) @Valid @RequestParam Map allParams) { + + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>( + serviceTestRepoService.findAll(myfields, allParams), HttpStatus.OK); + + } else { + + return new ResponseEntity>( + serviceTestRepoService.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("hasAnyAuthority('ROLE_ADMIN')" ) + @Override + public ResponseEntity patchServiceTest(@Valid ServiceTestUpdate serviceSpecification, String id) { + + ServiceTest c = serviceTestRepoService.updateServiceTest(id, serviceSpecification); + + return new ResponseEntity(c, HttpStatus.OK); + } + + @Override + public ResponseEntity retrieveServiceTest(String id, @Valid String fields) { + try { + + Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); + + if ( attr!=null) { + SecurityContextHolder.setContext( (SecurityContext) attr ); + } + if ( SecurityContextHolder.getContext().getAuthentication() != null ) { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + centralLogger.log( CLevel.INFO, "User " + authentication.getName() + " retrieve spec id: "+ id , compname ); + } else { + centralLogger.log( CLevel.INFO, "Anonymous retrieve spec id: "+ id, compname ); + } + + return new ResponseEntity( serviceTestRepoService.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/stm653/api/ServiceTestSpecificationApi.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestSpecificationApi.java new file mode 100644 index 0000000000000000000000000000000000000000..54f37a1c3d128e0ca1de55044bc7bd9e18b9a6d7 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestSpecificationApi.java @@ -0,0 +1,280 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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================================== + */ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.19). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package org.etsi.osl.tmf.stm653.api; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecification; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationCreate; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationUpdate; +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; +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.multipart.MultipartFile; +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; + +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2021-02-08T11:50:07.226173200+02:00[Europe/Athens]") +@Tag(name = "serviceTestSpecification", description = "the serviceTestSpecification API") +public interface ServiceTestSpecificationApi { + + Logger log = LoggerFactory.getLogger(ServiceTestSpecificationApi.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 ServiceTestSpecification", operationId = "createServiceTestSpecification", description = "This operation creates a ServiceTestSpecification entity." , tags = { + "serviceTestSpecification", }) + @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 = "/serviceTestSpecification", produces = { "application/json;charset=utf-8" }, consumes = { + "application/json;charset=utf-8" }, method = RequestMethod.POST) + default ResponseEntity createServiceTestSpecification( + @Parameter(description = "The ServiceTestSpecification to be created", required = true) @Valid @RequestBody ServiceTestSpecificationCreate body) { + + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Deletes a ServiceTestSpecification", operationId = "deleteServiceTestSpecification", description = "This operation deletes a ServiceTestSpecification entity.", tags = { + "serviceTestSpecification", }) + @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 = "/serviceTestSpecification/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.DELETE) + default ResponseEntity deleteServiceTestSpecification( + @Parameter(description = "Identifier of the ServiceTestSpecification", required = true) @PathVariable("id") String id) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ServiceTestSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "List or find ServiceTestSpecification objects", operationId = "listServiceTestSpecification", description = "This operation list or find ServiceTestSpecification entities" , tags = { + "serviceTestSpecification", }) + @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 = "/serviceTestSpecification", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity> listServiceTestSpecification( + @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( + "[ {\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"targetEntitySchema\" : {\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"specCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"charSpecRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"characteristicValueSpecification\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"charSpecRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"characteristicValueSpecification\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"entitySpecRelationship\" : [ {\r\n \"associationSpec\" : {\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 },\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"associationSpec\" : {\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 },\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"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 \"version\" : \"version\",\r\n \"relatedServiceSpecification\" : [ {\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 \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"video\",\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 \"@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 \"validFor\" : {\r\n \"startDateTime\" : \"1985-04-12T23:20:50.52Z\",\r\n \"endDateTime\" : \"1985-04-12T23:20:50.52Z\"\r\n },\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 \"testMeasureDefinition\" : [ {\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@type\" : \"@type\",\r\n \"captureFrequency\" : \"captureFrequency\",\r\n \"metricHref\" : \"metricHref\",\r\n \"metricDescription\" : \"metricDescription\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"captureMethod\" : \"captureMethod\",\r\n \"capturePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"thresholdRule\" : [ {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n }, {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n } ]\r\n }, {\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@type\" : \"@type\",\r\n \"captureFrequency\" : \"captureFrequency\",\r\n \"metricHref\" : \"metricHref\",\r\n \"metricDescription\" : \"metricDescription\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"captureMethod\" : \"captureMethod\",\r\n \"capturePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"thresholdRule\" : [ {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n }, {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n } ]\r\n } ],\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"serviceTestSpecRelationship\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"relationshipType\" : \"relationshipType\",\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 \"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 \"href\" : \"http://example.com/aeiou\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}, {\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"targetEntitySchema\" : {\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"specCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"charSpecRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"characteristicValueSpecification\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"charSpecRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"characteristicValueSpecification\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"entitySpecRelationship\" : [ {\r\n \"associationSpec\" : {\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 },\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"associationSpec\" : {\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 },\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"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 \"version\" : \"version\",\r\n \"relatedServiceSpecification\" : [ {\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 \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"video\",\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 \"@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 \"validFor\" : {\r\n \"startDateTime\" : \"1985-04-12T23:20:50.52Z\",\r\n \"endDateTime\" : \"1985-04-12T23:20:50.52Z\"\r\n },\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 \"testMeasureDefinition\" : [ {\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@type\" : \"@type\",\r\n \"captureFrequency\" : \"captureFrequency\",\r\n \"metricHref\" : \"metricHref\",\r\n \"metricDescription\" : \"metricDescription\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"captureMethod\" : \"captureMethod\",\r\n \"capturePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"thresholdRule\" : [ {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n }, {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n } ]\r\n }, {\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@type\" : \"@type\",\r\n \"captureFrequency\" : \"captureFrequency\",\r\n \"metricHref\" : \"metricHref\",\r\n \"metricDescription\" : \"metricDescription\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"captureMethod\" : \"captureMethod\",\r\n \"capturePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"thresholdRule\" : [ {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n }, {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n } ]\r\n } ],\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"serviceTestSpecRelationship\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"relationshipType\" : \"relationshipType\",\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 \"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 \"href\" : \"http://example.com/aeiou\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\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); + } + } + } else { + log.warn( + "ObjectMapper or HttpServletRequest not configured in default ServiceTestSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Updates partially a ServiceTestSpecification", operationId = "patchServiceTestSpecification", description = "This operation updates partially a ServiceTestSpecification entity." , tags = { + "serviceTestSpecification", }) + @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 = "/serviceTestSpecification/{id}", produces = { + "application/json;charset=utf-8" }, consumes = { + "application/json;charset=utf-8" }, method = RequestMethod.PATCH) + default ResponseEntity patchServiceTestSpecification( + @Parameter(description = "The ServiceTestSpecification to be updated", required = true) @Valid @RequestBody ServiceTestSpecificationUpdate body, + @Parameter(description = "Identifier of the ServiceTestSpecification", required = true) @PathVariable("id") String id) { + if (getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue( + "{\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"targetEntitySchema\" : {\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"specCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"charSpecRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"characteristicValueSpecification\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"charSpecRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"characteristicValueSpecification\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"entitySpecRelationship\" : [ {\r\n \"associationSpec\" : {\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 },\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"associationSpec\" : {\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 },\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"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 \"version\" : \"version\",\r\n \"relatedServiceSpecification\" : [ {\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 \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"video\",\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 \"@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 \"validFor\" : {\r\n \"startDateTime\" : \"1985-04-12T23:20:50.52Z\",\r\n \"endDateTime\" : \"1985-04-12T23:20:50.52Z\"\r\n },\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 \"testMeasureDefinition\" : [ {\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@type\" : \"@type\",\r\n \"captureFrequency\" : \"captureFrequency\",\r\n \"metricHref\" : \"metricHref\",\r\n \"metricDescription\" : \"metricDescription\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"captureMethod\" : \"captureMethod\",\r\n \"capturePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"thresholdRule\" : [ {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n }, {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n } ]\r\n }, {\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@type\" : \"@type\",\r\n \"captureFrequency\" : \"captureFrequency\",\r\n \"metricHref\" : \"metricHref\",\r\n \"metricDescription\" : \"metricDescription\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"captureMethod\" : \"captureMethod\",\r\n \"capturePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"thresholdRule\" : [ {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n }, {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n } ]\r\n } ],\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"serviceTestSpecRelationship\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"relationshipType\" : \"relationshipType\",\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 \"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 \"href\" : \"http://example.com/aeiou\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", + ServiceTestSpecification.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 ServiceTestSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + @Operation(summary = "Retrieves a ServiceTestSpecification by ID", operationId = "retrieveServiceTestSpecification", description = "This operation retrieves a ServiceTestSpecification entity. Attribute selection is enabled for all first level attributes." , tags = { + "serviceTestSpecification", }) + @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 = "/serviceTestSpecification/{id}", produces = { + "application/json;charset=utf-8" }, method = RequestMethod.GET) + default ResponseEntity retrieveServiceTestSpecification( + @Parameter(description = "Identifier of the ServiceTestSpecification", 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( + "{\r\n \"isBundle\" : true,\r\n \"lifecycleStatus\" : \"lifecycleStatus\",\r\n \"targetEntitySchema\" : {\r\n \"@type\" : \"@type\",\r\n \"@schemaLocation\" : \"@schemaLocation\"\r\n },\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"specCharacteristic\" : [ {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"charSpecRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"characteristicValueSpecification\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n }, {\r\n \"@type\" : \"@type\",\r\n \"@valueSchemaLocation\" : \"@valueSchemaLocation\",\r\n \"isUnique\" : true,\r\n \"description\" : \"description\",\r\n \"maxCardinality\" : 6,\r\n \"minCardinality\" : 1,\r\n \"regex\" : \"regex\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"charSpecRelationship\" : [ {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"relationshipType\" : \"relationshipType\",\r\n \"parentSpecificationId\" : \"parentSpecificationId\",\r\n \"name\" : \"name\",\r\n \"characteristicSpecificationId\" : \"characteristicSpecificationId\",\r\n \"parentSpecificationHref\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"characteristicValueSpecification\" : [ {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n }, {\r\n \"rangeInterval\" : \"rangeInterval\",\r\n \"isDefault\" : true,\r\n \"regex\" : \"regex\",\r\n \"valueTo\" : 5,\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@baseType\" : \"@baseType\",\r\n \"@type\" : \"@type\",\r\n \"valueType\" : \"valueType\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"value\" : { },\r\n \"valueFrom\" : 5\r\n } ],\r\n \"name\" : \"name\",\r\n \"id\" : \"id\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"extensible\" : true,\r\n \"configurable\" : true\r\n } ],\r\n \"entitySpecRelationship\" : [ {\r\n \"associationSpec\" : {\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 },\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"associationSpec\" : {\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 },\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"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 \"version\" : \"version\",\r\n \"relatedServiceSpecification\" : [ {\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 \"attachment\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"attachmentType\" : \"video\",\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 \"@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 \"validFor\" : {\r\n \"startDateTime\" : \"1985-04-12T23:20:50.52Z\",\r\n \"endDateTime\" : \"1985-04-12T23:20:50.52Z\"\r\n },\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 \"testMeasureDefinition\" : [ {\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@type\" : \"@type\",\r\n \"captureFrequency\" : \"captureFrequency\",\r\n \"metricHref\" : \"metricHref\",\r\n \"metricDescription\" : \"metricDescription\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"captureMethod\" : \"captureMethod\",\r\n \"capturePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"thresholdRule\" : [ {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n }, {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n } ]\r\n }, {\r\n \"metricName\" : \"metricName\",\r\n \"unitOfMeasure\" : \"unitOfMeasure\",\r\n \"@type\" : \"@type\",\r\n \"captureFrequency\" : \"captureFrequency\",\r\n \"metricHref\" : \"metricHref\",\r\n \"metricDescription\" : \"metricDescription\",\r\n \"@baseType\" : \"@baseType\",\r\n \"valueType\" : \"valueType\",\r\n \"name\" : \"name\",\r\n \"captureMethod\" : \"captureMethod\",\r\n \"capturePeriod\" : {\r\n \"amount\" : 1,\r\n \"units\" : \"units\"\r\n },\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"thresholdRule\" : [ {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n }, {\r\n \"consequence\" : [ {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n }, {\r\n \"repeatAction\" : true,\r\n \"@baseType\" : \"@baseType\",\r\n \"prescribeAction\" : \"prescribeAction\",\r\n \"@type\" : \"@type\",\r\n \"name\" : \"name\",\r\n \"description\" : \"description\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n } ],\r\n \"conformanceComparatorLower\" : \"conformanceComparatorLower\",\r\n \"conformanceComparatorUpper\" : \"conformanceComparatorUpper\",\r\n \"@type\" : \"@type\",\r\n \"description\" : \"description\",\r\n \"thresholdRuleSeverity\" : \"thresholdRuleSeverity\",\r\n \"@baseType\" : \"@baseType\",\r\n \"numberOfAllowedCrossing\" : 2,\r\n \"conformanceTargetUpper\" : \"conformanceTargetUpper\",\r\n \"name\" : \"name\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\",\r\n \"conformanceTargetLower\" : \"conformanceTargetLower\"\r\n } ]\r\n } ],\r\n \"lastUpdate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"name\" : \"name\",\r\n \"serviceTestSpecRelationship\" : [ {\r\n \"@referredType\" : \"@referredType\",\r\n \"role\" : \"role\",\r\n \"relationshipType\" : \"relationshipType\",\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 \"relationshipType\" : \"relationshipType\",\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 \"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 \"href\" : \"http://example.com/aeiou\",\r\n \"@schemaLocation\" : \"http://example.com/aeiou\"\r\n}", + ServiceTestSpecification.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 ServiceTestSpecificationApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Adds an attachment to a ServiceTestSpecification", operationId = "addAttachmentToServiceTestSpecification", + description = "This operation adds an attachment to a ServiceTestSpecification and updates partially a ServiceTestSpecification entity", tags={ "serviceTestSpecification", }) + @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 = "/serviceTestSpecification/{id}/attachment", + produces = { "application/json;charset=utf-8" }, + consumes = { "multipart/form-data" }, + method = RequestMethod.POST) + ResponseEntity addAttachmentToServiceTestSpecification( + @Parameter(description = "Identifier of the ServiceTestSpecification",required=true) @PathVariable("id") String id, + //@Parameter(description = "The Attachment object to be added" ,required=false ) @Valid @ModelAttribute("attachment") Attachment attachment, + @Parameter(description = "The Attachment file to be added" ,required=false, name = "afile" ) @Valid MultipartFile file, + HttpServletRequest request); + + @Operation(summary = "Get an attachment", operationId = "getAttachment", + description = "This operation gets an attachment", tags={ "serviceTestSpecification", }) + @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 = "/serviceTestSpecification/{id}/attachment/{attid}", + produces = MediaType.ALL_VALUE, + method = RequestMethod.GET) + ResponseEntity getAttachment( + @Parameter(description = "Identifier of the serviceTestSpecification",required=true) @PathVariable("id") String id, + @Parameter(description = "Identifier of the Attachment",required=true) @PathVariable("attid") String attid); + + + + @Operation(summary = "Get an attachment with filename", operationId = "getAttachmentWithFilename", + description = "This operation gets an attachment", tags={ "serviceTestSpecification", }) + @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 = "/serviceTestSpecification/{id}/attachment/{attid}/{afilename}", + produces = MediaType.ALL_VALUE , + method = RequestMethod.GET) + ResponseEntity getAttachmentWithFilename( + @Parameter(description = "Identifier of the serviceTestSpecification",required=true) @PathVariable("id") String id, + @Parameter(description = "Identifier of the Attachment",required=true) @PathVariable("attid") String attid, + @Parameter(description = "Identifier of the Filename",required=true) @PathVariable("afilename") String afilename); + + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestSpecificationApiController.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestSpecificationApiController.java new file mode 100644 index 0000000000000000000000000000000000000000..03c58f5aed888881e789979f22864be45ad55af1 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestSpecificationApiController.java @@ -0,0 +1,276 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.api; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.io.IOUtils; +import org.etsi.osl.centrallog.client.CLevel; +import org.etsi.osl.centrallog.client.CentralLogger; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecification; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationCreate; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationUpdate; +import org.etsi.osl.tmf.stm653.reposervices.ServiceTestSpecificationRepoService; +import org.etsi.osl.tmf.util.AddUserAsOwnerToRelatedParties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.CacheControl; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +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 = "2021-02-08T11:50:07.226173200+02:00[Europe/Athens]") +@Controller +@RequestMapping("/serviceTestManagement/v4/") +public class ServiceTestSpecificationApiController implements ServiceTestSpecificationApi { + + private static final Logger log = LoggerFactory.getLogger(ServiceTestSpecificationApiController.class); + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @Autowired + ServiceTestSpecificationRepoService serviceTestSpecificationRepoService; + + @Value("${spring.application.name}") + private String compname; + + @Autowired + private CentralLogger centralLogger; + + @org.springframework.beans.factory.annotation.Autowired + public ServiceTestSpecificationApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity createServiceTestSpecification( + @Valid ServiceTestSpecificationCreate serviceSpecification) { + + try { + + serviceSpecification.setRelatedParty(AddUserAsOwnerToRelatedParties.addUser( + SecurityContextHolder.getContext().getAuthentication().getName(), + SecurityContextHolder.getContext().getAuthentication().getName(), UserPartRoleType.OWNER, "", + serviceSpecification.getRelatedParty())); + + ServiceTestSpecification c = serviceTestSpecificationRepoService + .addServiceTestSpecification(serviceSpecification); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity deleteServiceTestSpecification(String id) { + + try { + + return new ResponseEntity(serviceTestSpecificationRepoService.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> listServiceTestSpecification(@Valid String fields, + @Valid Integer offset, @Valid Integer limit, + @Parameter(hidden = true) @Valid @RequestParam Map allParams) { + + try { + if (allParams != null) { + allParams.remove("fields"); + allParams.remove("offset"); + allParams.remove("limit"); + } else { + allParams = new HashMap<>(); + } + if ((fields == null) && (allParams.size() == 0)) { + + String myfields = "lastUpdate,lifecycleStatus"; + return new ResponseEntity>( + serviceTestSpecificationRepoService.findAll(myfields, allParams), HttpStatus.OK); + + } else { + + return new ResponseEntity>( + serviceTestSpecificationRepoService.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("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity patchServiceTestSpecification( + @Valid ServiceTestSpecificationUpdate serviceSpecification, String id) { + ServiceTestSpecification c = serviceTestSpecificationRepoService.updateServiceTestSpecification(id, serviceSpecification); + + return new ResponseEntity(c, HttpStatus.OK); + } + + + @Override + public ResponseEntity retrieveServiceTestSpecification(String id, @Valid String fields) { + + try { + + Object attr = request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); + + if ( attr!=null) { + SecurityContextHolder.setContext( (SecurityContext) attr ); + } + if ( SecurityContextHolder.getContext().getAuthentication() != null ) { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + centralLogger.log( CLevel.INFO, "User " + authentication.getName() + " retrieve spec id: "+ id , compname ); + } else { + centralLogger.log( CLevel.INFO, "Anonymous retrieve spec id: "+ id, compname ); + } + + return new ResponseEntity( serviceTestSpecificationRepoService.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); + } + + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity addAttachmentToServiceTestSpecification(String specid, + //@Valid @ModelAttribute("attachment") Attachment att, + @RequestParam(name = "afile") @Valid MultipartFile file, + HttpServletRequest request) { + try { + + //log.info("addAttachmentToServiceSpecification attachment=" + att.toString()); + log.info("addAttachmentToServiceTestSpecification file=" + file); + + //Attachment att = objectMapper.readValue(attachment, Attachment.class); + //log.info("addAttachmentToServiceSpecification att=" + att); + +// return new ResponseEntity( serviceSpecificationRepoService.findByUuid( id ), HttpStatus.OK); + Attachment c = serviceTestSpecificationRepoService.addAttachmentToServiceTest(specid, file, request.getRequestURI()); + + return new ResponseEntity(c, 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("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity getAttachment(String id, String attid) { + try { + Attachment att; + + att = serviceTestSpecificationRepoService.getAttachment( attid ); + + if ( att == null ) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + if ( att.getContent() == null ) { + return new ResponseEntity(HttpStatus.NOT_FOUND); + } + File file = new File( att.getContent() ); + Path path = Paths.get(file.getAbsolutePath()); + //ByteArrayResource resource = new ByteArrayResource(Files.readAllBytes(path)); + HttpHeaders headers = new HttpHeaders(); + InputStream in = new FileInputStream( file ); + + byte[] media = IOUtils.toByteArray(in); + headers.setCacheControl(CacheControl.noCache().getHeaderValue()); + headers.setContentType( MediaType. parseMediaType( att.getMimeType()) ); + + if ( att.getMimeType().contains("zip") || att.getMimeType().contains("gz")) { + headers.add( "Content-Disposition", "attachment; filename=" + file.getName());//remove this returns directly the object + } + + ResponseEntity responseEntity = new ResponseEntity<>(media, headers, HttpStatus.OK); + return responseEntity; + + + + + } catch (Exception e) { + log.error("Couldn't serialize response ByteArrayResource", e); + return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + + @PreAuthorize("hasAnyAuthority('ROLE_USER')" ) + @Override + public ResponseEntity getAttachmentWithFilename(String id, String attid, String afilename) { + + return getAttachment(id, attid); + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestSpecificationApiRouteBuilder.java b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestSpecificationApiRouteBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..f209cbafc0f915c54869c959c64631cb1c1e61a3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/api/ServiceTestSpecificationApiRouteBuilder.java @@ -0,0 +1,119 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.stm653.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.stm653.model.ServiceTestCreate; +import org.etsi.osl.tmf.stm653.model.ServiceTestUpdate; +import org.etsi.osl.tmf.stm653.reposervices.ServiceTestRepoService; +import org.etsi.osl.tmf.stm653.reposervices.ServiceTestSpecificationRepoService; +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 ServiceTestSpecificationApiRouteBuilder extends RouteBuilder { + + private static final transient Log logger = LogFactory.getLog(ServiceTestSpecificationApiRouteBuilder.class.getName()); + + @Value("${CATALOG_GET_SERVICETESTSPEC_BY_ID}") + private String CATALOG_GET_SERVICETESTSPEC_BY_ID = ""; + + + + @Value("${CATALOG_ADD_SERVICETEST}") + private String CATALOG_ADD_SERVICETEST = ""; + + + @Value("${CATALOG_UPD_SERVICETEST}") + private String CATALOG_UPD_SERVICETEST = ""; + + + @Value("${CATALOG_GET_SERVICETEST_BY_ID}") + private String CATALOG_GET_SERVICETEST_BY_ID = ""; + + + + @Autowired + ServiceTestSpecificationRepoService serviceTestSpecificationRepoService; + + + @Autowired + ServiceTestRepoService serviceTestRepoService; + + @Autowired + private ProducerTemplate template; + + @Override + public void configure() throws Exception { + + from( CATALOG_GET_SERVICETESTSPEC_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICETESTSPEC_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( serviceTestSpecificationRepoService, "findByUuidEager") + .marshal().json( JsonLibrary.Jackson, String.class) + .convertBodyTo( String.class ); + + + from( CATALOG_ADD_SERVICETEST ) + .log(LoggingLevel.INFO, log, CATALOG_ADD_SERVICETEST + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ServiceTestCreate.class, true) + .bean( serviceTestRepoService, "addServiceTest(${body})") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + + from( CATALOG_GET_SERVICETEST_BY_ID ) + .log(LoggingLevel.INFO, log, CATALOG_GET_SERVICETEST_BY_ID + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .bean( serviceTestRepoService, "getServiceTestEagerAsString") + .convertBodyTo( String.class ); + + from(CATALOG_UPD_SERVICETEST) + .log(LoggingLevel.INFO, log, CATALOG_UPD_SERVICETEST + " message received!") + .to("log:DEBUG?showBody=true&showHeaders=true") + .unmarshal().json( JsonLibrary.Jackson, ServiceTestUpdate.class, true) + .bean( serviceTestRepoService, "updateServiceTest(${header.serviceid}, ${body} )") + .marshal().json( JsonLibrary.Jackson) + .convertBodyTo( String.class ); + } + + + + 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/stm653/repo/ServiceTestRepository.java b/src/main/java/org/etsi/osl/tmf/stm653/repo/ServiceTestRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..0c508f7633f833bb3bdb4d680930409cc1fe9478 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/repo/ServiceTestRepository.java @@ -0,0 +1,44 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.stm653.model.ServiceTest; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface ServiceTestRepository extends CrudRepository,PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Optional findByName(String aName); + + List findByOrderByName(); + + + + +} + diff --git a/src/main/java/org/etsi/osl/tmf/stm653/repo/ServiceTestSpecificationRepository.java b/src/main/java/org/etsi/osl/tmf/stm653/repo/ServiceTestSpecificationRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..58aa1066f4d5e7eed0b66177b28f40c7d6699157 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/repo/ServiceTestSpecificationRepository.java @@ -0,0 +1,48 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.repo; + +import java.util.List; +import java.util.Optional; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecification; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.stereotype.Repository; + + +/** + * @author ctranoris + * + */ +@Repository +public interface ServiceTestSpecificationRepository extends CrudRepository,PagingAndSortingRepository { + + + Optional findByUuid(String id); + + Optional findByName(String aName); + + List findByOrderByName(); + + + + +} + diff --git a/src/main/java/org/etsi/osl/tmf/stm653/reposervices/ServiceTestRepoService.java b/src/main/java/org/etsi/osl/tmf/stm653/reposervices/ServiceTestRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..67131494b9df0556d1f8e8ad834c1ad44ccba5d3 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/reposervices/ServiceTestRepoService.java @@ -0,0 +1,340 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.reposervices; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.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.Any; +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.stm653.model.Characteristic; +import org.etsi.osl.tmf.stm653.model.CharacteristicRelationship; +import org.etsi.osl.tmf.stm653.model.ServiceTest; +import org.etsi.osl.tmf.stm653.model.ServiceTestCreate; +import org.etsi.osl.tmf.stm653.model.ServiceTestUpdate; +import org.etsi.osl.tmf.stm653.model.TestMeasure; +import org.etsi.osl.tmf.stm653.repo.ServiceTestRepository; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +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; + +/** + * @author ctranoris + * + */ +@Service +public class ServiceTestRepoService { + + private static final transient Log logger = LogFactory.getLog(ServiceTestRepoService.class.getName()); + + + @Autowired + ServiceTestRepository aServiceTestRepo; + + private SessionFactory sessionFactory; + + + @Autowired + ServiceRepoService serviceRepoService; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + public ServiceTestRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public ServiceTest addServiceTest(@Valid ServiceTestCreate serviceTest) { + + ServiceTest serviceSpec = new ServiceTest(); + serviceSpec = this.updateServiceTestDataFromAPIcall(serviceSpec, serviceTest); + serviceSpec = this.aServiceTestRepo.save(serviceSpec); + + return this.aServiceTestRepo.save(serviceSpec); + } + + + @Transactional + private ServiceTest updateServiceTestDataFromAPIcall(ServiceTest serviceT, + @Valid ServiceTestUpdate serviceUpd) { + + if (serviceUpd.getName() != null) { + serviceT.setName(serviceUpd.getName()); + } + + if (serviceUpd.getDescription() != null) { + serviceT.setDescription(serviceUpd.getDescription()); + + } + + + if (serviceUpd.getTestSpecification() != null ){ + serviceT.setTestSpecification( serviceUpd.getTestSpecification() ); + } + + + serviceT.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + + + + + List childCharacteristicsChanged = new ArrayList<>(); + if ( serviceUpd.getCharacteristic()!=null ) { + for (Characteristic n : serviceUpd.getCharacteristic()) { + + if ( serviceT.getCharacteristicByName( n.getName() )!= null ) { + + Characteristic origChar = serviceT.getCharacteristicByName( n.getName() ); + if ( ( origChar !=null ) && ( origChar.getValue() !=null ) && ( origChar.getValue().getValue() !=null )) { + if ( !origChar.getValue().getValue().equals(n.getValue().getValue()) ) { + if ( n.getName().contains("::") ) { + childCharacteristicsChanged.add(n); //the characteristic needs later to be propagated to its children + + + } + + } + } + + serviceT.getCharacteristicByName( n.getName() ).setValue( + new Any( n.getValue().getValue(), n.getValue().getAlias() ) + ); + } else { + serviceT.addCharacteristicItem(n); + } + + } + } + + /** + * Update RelatedParty list + */ + if (serviceUpd.getRelatedParty() != null) { + // reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (RelatedParty rp : serviceUpd.getRelatedParty()) { + + boolean idexists = false; + for (RelatedParty originalRP : serviceT.getRelatedParty()) { + if (originalRP.getId().equals(rp.getId())) { + idexists = true; + idAddedUpdated.put(originalRP.getId(), true); + break; + } + } + if (!idexists) { + serviceT.getRelatedParty().add(rp); + idAddedUpdated.put(rp.getId(), true); + } + } + List toRemove = new ArrayList<>(); + for (RelatedParty ss : serviceT.getRelatedParty()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (RelatedParty ar : toRemove) { + serviceT.getRelatedParty().remove(ar); + } + } + + + if (serviceUpd.getRelatedService() != null) { + serviceT.setRelatedService( (serviceUpd.getRelatedService() ) ); + + } + + + + if (serviceUpd.getTestMeasure() != null) { + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (TestMeasure ar : serviceUpd.getTestMeasure()) { + // find ServiceSpecRelationship by id and reload it here. + // we need the ServiceSpecRelationship model from spec models + boolean idexists = false; + for (TestMeasure orinalAtt : serviceT.getTestMeasure() ) { + if (orinalAtt.getMetricName().equals(ar.getMetricName())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getMetricName(), true); + break; + } + } + + if (!idexists) { + serviceT.getTestMeasure().add(ar); + idAddedUpdated.put(ar.getMetricName(), true); + + } + } + + List toRemove = new ArrayList<>(); + for (TestMeasure ss : serviceT.getTestMeasure()) { + if (idAddedUpdated.get(ss.getMetricName()) == null) { + toRemove.add(ss); + } + } + + for (TestMeasure ar : toRemove) { + serviceT.getTestMeasure().remove(ar); + } + + } + + return serviceT; + + } + + + /** + * update related service characteristics + * @param serviceT + */ + private void updateRelatedService(ServiceTest serviceT) { + + if (serviceT.getRelatedService() != null) { + + @Valid + ServiceUpdate servUpd = new ServiceUpdate(); + + for (Characteristic c : serviceT.getCharacteristic()) { + + org.etsi.osl.tmf.common.model.service.Characteristic newC = new org.etsi.osl.tmf.common.model.service.Characteristic(); + newC.setName( c.getName()); + newC.setValue( new Any( c.getValue()) ); + servUpd.addServiceCharacteristicItem( newC ); + } + serviceRepoService.updateService( serviceT.getRelatedService().getId() , servUpd, true, null, null); + } + + } + + public Void deleteByUuid(String id) { + Optional optionalCat = this.aServiceTestRepo.findByUuid(id); + ServiceTest s = optionalCat.get(); + if (s == null) { + return null; + } + + this.aServiceTestRepo.delete(s); + return null; + } + + public List findAll(String myfields, @Valid Map allParams) { + // this can be refactored properly in future (see for example implementation in ServiceSpecificationRepo) + return findAll(); + } + + public List findAll() { + return (List) this.aServiceTestRepo.findByOrderByName(); + } + + @Transactional + public ServiceTest updateServiceTest(String id, @Valid ServiceTestUpdate serviceSpecification) { + ServiceTest s = this.findByUuid(id); + if (s == null) { + return null; + } + ServiceTest serviceSpec = s; + serviceSpec = this.updateServiceTestDataFromAPIcall(serviceSpec, serviceSpecification); + + serviceSpec = this.aServiceTestRepo.save(serviceSpec); + + updateRelatedService( serviceSpec ); + + //serviceSpec = this.getServiceTestEager( serviceSpec.getId() ); + + return serviceSpec; + } + + + + public ServiceTest findByUuid(String id) { + Optional optionalCat = this.aServiceTestRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + public String getServiceTestEagerAsString(String id) throws JsonProcessingException { + ServiceTest s = this.getServiceTestEager(id); + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new Hibernate5JakartaModule()); + String res = mapper.writeValueAsString(s); + + return res; + } + + public ServiceTest getServiceTestEager(String id) { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); + ServiceTest s = null; + try { + s = (ServiceTest) session.get(ServiceTest.class, id); + if (s == null) { + return this.findByUuid(id);// last resort + } + + Hibernate.initialize(s.getRelatedParty()); + + Hibernate.initialize(s.getCharacteristic() ); + Hibernate.initialize(s.getTestSpecification() ); + Hibernate.initialize(s.getTestMeasure() ); + + for (Characteristic schar : s.getCharacteristic()) { + Hibernate.initialize(schar.getCharacteristicRelationship() ); + for (CharacteristicRelationship cr : schar.getCharacteristicRelationship() ) { + Hibernate.initialize(cr ); + } + + } + + tx.commit(); + } finally { + session.close(); + } + + return s; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/stm653/reposervices/ServiceTestSpecificationRepoService.java b/src/main/java/org/etsi/osl/tmf/stm653/reposervices/ServiceTestSpecificationRepoService.java new file mode 100644 index 0000000000000000000000000000000000000000..1989f43297068177c3c3a9d9415834a6a5b6c328 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/stm653/reposervices/ServiceTestSpecificationRepoService.java @@ -0,0 +1,473 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.stm653.reposervices; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.common.model.Attachment; +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.reposervices.AttachmentRepoService; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.stm653.model.CharacteristicSpecification; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecRelationship; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecification; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationCreate; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationUpdate; +import org.etsi.osl.tmf.stm653.repo.ServiceTestSpecificationRepository; +import org.etsi.osl.tmf.util.AttachmentUtil; +import org.hibernate.Hibernate; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import jakarta.persistence.EntityManagerFactory; +import jakarta.validation.Valid; + +/** + * @author ctranoris + * + */ +@Service +public class ServiceTestSpecificationRepoService { + + private static final transient Log logger = LogFactory.getLog(ServiceTestSpecificationRepoService.class.getName()); + + @Autowired + ServiceTestSpecificationRepository aServiceTestSpecificationRepo; + + private SessionFactory sessionFactory; + + + + @Autowired + AttachmentRepoService attachmentRepoService; + + + private static final String METADATADIR = System.getProperty("user.home") + File.separator + ".attachments" + + File.separator + "metadata" + File.separator; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + public ServiceTestSpecificationRepoService(EntityManagerFactory factory) { + if (factory.unwrap(SessionFactory.class) == null) { + throw new NullPointerException("factory is not a hibernate factory"); + } + this.sessionFactory = factory.unwrap(SessionFactory.class); + } + + public ServiceTestSpecification addServiceTestSpecification( + @Valid ServiceTestSpecificationCreate serviceServiceTestSpecification) { + + ServiceTestSpecification serviceSpec = new ServiceTestSpecification(); + serviceSpec = this.updateServiceTestSpecDataFromAPIcall(serviceSpec, serviceServiceTestSpecification); + serviceSpec = this.aServiceTestSpecificationRepo.save(serviceSpec); + + return this.aServiceTestSpecificationRepo.save(serviceSpec); + } + + private ServiceTestSpecification updateServiceTestSpecDataFromAPIcall(ServiceTestSpecification serviceSpec, + @Valid ServiceTestSpecificationUpdate serviceSpecUpd) { + + if (serviceSpecUpd.getName() != null) { + serviceSpec.setName(serviceSpecUpd.getName()); + } + + if (serviceSpecUpd.getDescription() != null) { + serviceSpec.setDescription(serviceSpecUpd.getDescription()); + + } + + if (serviceSpecUpd.isIsBundle() != null) { + serviceSpec.isBundle(serviceSpecUpd.isIsBundle()); + + } + + serviceSpec.setLastUpdate(OffsetDateTime.now(ZoneOffset.UTC)); + + if (serviceSpecUpd.getLifecycleStatus() != null) { + serviceSpec.setLifecycleStatusEnum(ELifecycle.getEnum(serviceSpecUpd.getLifecycleStatus())); + } + + if (serviceSpecUpd.getVersion() != null) { + serviceSpec.setVersion(serviceSpecUpd.getVersion()); + } + + /** + * Update Attachment list + */ + if (serviceSpecUpd.getAttachment() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (AttachmentRefOrValue ar : serviceSpecUpd.getAttachment()) { + // find attachmet by id and reload it here. + // we need the attachment model from resource spec models + boolean idexists = false; + for (AttachmentRefOrValue orinalAtt : serviceSpec.getAttachment()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + serviceSpec.getAttachment().add(ar); + idAddedUpdated.put(ar.getId(), true); + } + } + + List toRemove = new ArrayList<>(); + for (AttachmentRefOrValue ss : serviceSpec.getAttachment()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (AttachmentRefOrValue ar : toRemove) { + serviceSpec.getAttachment().remove(ar); + } + + } + + /** + * Update ServiceSpecCharacteristic list We need to compare by name, since IDs + * will not exist + */ + if (serviceSpecUpd.getSpecCharacteristic() != null) { + // reattach attachments fromDB + + Map idAddedUpdated = new HashMap<>(); + + for (CharacteristicSpecification charUpd : serviceSpecUpd.getSpecCharacteristic()) { + + boolean nameExists = false; + for (CharacteristicSpecification originalSpecChar : serviceSpec.getSpecCharacteristic()) { + if (originalSpecChar.getName().equals(charUpd.getName())) { + nameExists = true; + idAddedUpdated.put(originalSpecChar.getName(), true); + originalSpecChar.updateWith(charUpd); + break; + } + } + + if (!nameExists) { + serviceSpec.getSpecCharacteristic().add(new CharacteristicSpecification(charUpd)); + idAddedUpdated.put(charUpd.getName(), true); + } + + } + + List toRemove = new ArrayList<>(); + for (CharacteristicSpecification ss : serviceSpec.getSpecCharacteristic()) { + if (idAddedUpdated.get(ss.getName()) == null) { + toRemove.add(ss); + } + } + + for (CharacteristicSpecification serviceSpecCharacteristic : toRemove) { + serviceSpec.getSpecCharacteristic().remove(serviceSpecCharacteristic); + } + + } + + /** + * Update RelatedParty list + */ + if (serviceSpecUpd.getRelatedParty() != null) { + // reattach fromDB + Map idAddedUpdated = new HashMap<>(); + + for (RelatedParty rp : serviceSpecUpd.getRelatedParty()) { + + boolean idexists = false; + for (RelatedParty originalRP : serviceSpec.getRelatedParty()) { + if (originalRP.getId().equals(rp.getId())) { + idexists = true; + idAddedUpdated.put(originalRP.getId(), true); + break; + } + } + if (!idexists) { + serviceSpec.getRelatedParty().add(rp); + idAddedUpdated.put(rp.getId(), true); + } + } + List toRemove = new ArrayList<>(); + for (RelatedParty ss : serviceSpec.getRelatedParty()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (RelatedParty ar : toRemove) { + serviceSpec.getRelatedParty().remove(ar); + } + } + + /** + * Update ServiceSpecRelationship list + */ + + if (serviceSpecUpd.getServiceTestSpecRelationship() != null) { + + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ServiceTestSpecRelationship ar : serviceSpecUpd.getServiceTestSpecRelationship()) { + // find ServiceSpecRelationship by id and reload it here. + // we need the ServiceSpecRelationship model from spec models + boolean idexists = false; + for (ServiceTestSpecRelationship orinalAtt : serviceSpec.getServiceTestSpecRelationship()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + serviceSpec.getServiceTestSpecRelationship().add(ar); + idAddedUpdated.put(ar.getId(), true); + + } + } + + List toRemove = new ArrayList<>(); + for (ServiceTestSpecRelationship ss : serviceSpec.getServiceTestSpecRelationship()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (ServiceTestSpecRelationship ar : toRemove) { + serviceSpec.getServiceTestSpecRelationship().remove(ar); + } + + } + + TimePeriod tp = new TimePeriod(); + if (serviceSpecUpd instanceof ServiceTestSpecificationCreate) + if (((ServiceTestSpecificationCreate) serviceSpecUpd).getValidFor() != null) { + tp.setStartDateTime(((ServiceTestSpecificationCreate) serviceSpecUpd).getValidFor().getStartDateTime()); + tp.setEndDateTime(((ServiceTestSpecificationCreate) serviceSpecUpd).getValidFor().getEndDateTime()); + serviceSpec.setValidFor(tp); + } + + if (serviceSpecUpd.getRelatedServiceSpecification() != null) { + // reattach attachments fromDB + Map idAddedUpdated = new HashMap<>(); + + for (ServiceSpecificationRef ar : serviceSpecUpd.getRelatedServiceSpecification()) { + // find ServiceSpecRelationship by id and reload it here. + // we need the ServiceSpecRelationship model from spec models + boolean idexists = false; + for (ServiceSpecificationRef orinalAtt : serviceSpec.getRelatedServiceSpecification()) { + if (orinalAtt.getId().equals(ar.getId())) { + idexists = true; + idAddedUpdated.put(orinalAtt.getId(), true); + break; + } + } + + if (!idexists) { + serviceSpec.getRelatedServiceSpecification().add(ar); + idAddedUpdated.put(ar.getId(), true); + + } + } + + List toRemove = new ArrayList<>(); + for (ServiceSpecificationRef ss : serviceSpec.getRelatedServiceSpecification()) { + if (idAddedUpdated.get(ss.getId()) == null) { + toRemove.add(ss); + } + } + + for (ServiceSpecificationRef ar : toRemove) { + serviceSpec.getRelatedServiceSpecification().remove(ar); + } + + } + + return serviceSpec; + + } + + public ServiceTestSpecification findByUuidEager(String id) { + Session session = sessionFactory.openSession(); + Transaction tx = session.beginTransaction(); // instead of begin transaction, is it possible to continue? + ServiceTestSpecification dd = null; + try { + dd = session.get(ServiceTestSpecification.class, id); + if (dd == null) { + return this.findByUuid(id);// last resort + } + Hibernate.initialize(dd.getAttachment()); + Hibernate.initialize(dd.getRelatedParty()); + Hibernate.initialize(dd.getServiceTestSpecRelationship() ); + Hibernate.initialize(dd.getSpecCharacteristic()); + Hibernate.initialize(dd.getConstraint()); + Hibernate.initialize(dd.getEntitySpecRelationship() ); + Hibernate.initialize(dd.getTestMeasureDefinition() ); + + for (CharacteristicSpecification schar : dd.getSpecCharacteristic()) { + Hibernate.initialize(schar.getCharacteristicValueSpecification() ); + Hibernate.initialize(schar.getCharSpecRelationship()); + + } + Hibernate.initialize(dd.getRelatedServiceSpecification() ); + + tx.commit(); + } finally { + session.close(); + } + return dd; + } + + public List findAll() { + return (List) this.aServiceTestSpecificationRepo.findByOrderByName(); + } + + public Void deleteByUuid(String id) { + Optional optionalCat = this.aServiceTestSpecificationRepo.findByUuid(id); + ServiceTestSpecification s = optionalCat.get(); + if (s == null) { + return null; + } + + this.aServiceTestSpecificationRepo.delete(s); + return null; + } + + /** + * @param myfields + * @param allParams + * @return + */ + public List findAll(String myfields, @Valid Map allParams) { + // this can be refactored properly in future (see for example implementation in ServiceSpecificationRepo) + return findAll(); + } + + public ServiceTestSpecification updateServiceTestSpecification(String id, + @Valid ServiceTestSpecificationUpdate serviceServiceSpecification) { + + ServiceTestSpecification s = this.findByUuid(id); + if (s == null) { + return null; + } + ServiceTestSpecification serviceSpec = s; + serviceSpec = this.updateServiceTestSpecDataFromAPIcall(serviceSpec, serviceServiceSpecification); + + serviceSpec = this.aServiceTestSpecificationRepo.save(serviceSpec); + + + return this.aServiceTestSpecificationRepo.save(serviceSpec); + } + + public ServiceTestSpecification findByUuid(String id) { + Optional optionalCat = this.aServiceTestSpecificationRepo.findByUuid(id); + return optionalCat.orElse(null); + } + + public Attachment addAttachmentToServiceTest(String id, + //@Valid Attachment attachment, + @Valid MultipartFile afile, + String urlpath) { + Optional s = this.aServiceTestSpecificationRepo.findByUuid(id); + if (s.get() == null) { + return null; + } + + ServiceTestSpecification spec = s.get(); + Attachment att = new Attachment(); + att = this.attachmentRepoService.addAttachment(att); + att.setMimeType(afile.getContentType()); + + + String tempDir = METADATADIR + spec.getId() + "/attachments/" + att.getId() + File.separator; + + try { + Files.createDirectories(Paths.get(tempDir)); + String aFileNamePosted = afile.getOriginalFilename();// AttachmentUtil.getFileName(image.getHeaders()); + logger.info("aFileNamePosted = " + aFileNamePosted); + // If there is an icon name + if (!aFileNamePosted.equals("")) { + // Save the icon File + String targetfile = AttachmentUtil.saveFile(afile, tempDir); + logger.info("afile saved to = " + targetfile); + att.setContent(targetfile); + att.setName(aFileNamePosted); + // Save the file destination + urlpath = urlpath.replace("tmf-api/", ""); + att.setUrl( urlpath + "/" + att.getId() + "/" + + aFileNamePosted); + att = this.attachmentRepoService.updateAttachment( att ); + } + } catch (IOException e) { + e.printStackTrace(); + return null; + } + + AttachmentRefOrValue attref = new AttachmentRefOrValue(); + attref.setId(att.getId()); + attref.setDescription(att.getDescription()); + attref.setUrl(att.getUrl()); + attref.setName(att.getName()); + + spec.addAttachmentItem(attref); + this.aServiceTestSpecificationRepo.save(spec); + + + return att; + } + + public Attachment getAttachment(String attid) { + return this.attachmentRepoService.findByUuid( attid ); + } + + + + + +} diff --git a/src/main/java/org/etsi/osl/tmf/util/AddUserAsOwnerToRelatedParties.java b/src/main/java/org/etsi/osl/tmf/util/AddUserAsOwnerToRelatedParties.java new file mode 100644 index 0000000000000000000000000000000000000000..8ffcc465ea2fc5df31eb4b3266929b90f677a22a --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/util/AddUserAsOwnerToRelatedParties.java @@ -0,0 +1,72 @@ +/*- + * ========================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.util; + +import java.util.ArrayList; +import java.util.List; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import jakarta.validation.Valid; + +/** + * + * this class just has method to get a prtyrole + * + * @author ctranoris + * + */ +public class AddUserAsOwnerToRelatedParties { + + public static List addUser(String username, String userid, + UserPartRoleType prt, + String extendedInfo, + @Valid List relatedParty) { + List rpRes; + + if (relatedParty!=null) { + rpRes = relatedParty; + } else { + rpRes = new ArrayList(); + } + + + boolean nameFound = false; + for (RelatedParty relatedParty2 : rpRes) { + if (relatedParty2.getName().equals(username) + && relatedParty2.getRole().equals( prt.toString())) { + nameFound = true; + break; + } + } + + if (!nameFound) { + RelatedParty rp = new RelatedParty(); + rp.setId( userid ); + rp.setName(username); + rp.setRole(prt.toString()); + rp.setReferredType("SimpleUsername_Individual"); + rp.setExtendedInfo(extendedInfo); + rpRes.add(rp); + } + + return rpRes; + } + +} diff --git a/src/main/java/org/etsi/osl/tmf/util/AttachmentUtil.java b/src/main/java/org/etsi/osl/tmf/util/AttachmentUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..9f6d14e9320274bc574632621c3c7d950dfd2650 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/util/AttachmentUtil.java @@ -0,0 +1,106 @@ +/*- + * ========================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.util; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.springframework.web.multipart.MultipartFile; + +/** + * @author ctranoris + * + */ +public class AttachmentUtil { + + + + + /** + * @param att + * @param filePath + * @return + */ + public static String saveFile(MultipartFile att, String filePath) { + File file = new File(filePath + att.getOriginalFilename()); + try { + att.transferTo(file); + return file.getPath(); + + } catch (IllegalStateException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + +// DataHandler handler = att.getDataHandler(); +// try { +// InputStream stream = handler.getInputStream(); +// MultivaluedMap map = att.getHeaders(); +// File f = new File(filePath); +// OutputStream out = new FileOutputStream(f); +// +// int read = 0; +// byte[] bytes = new byte[1024]; +// while ((read = stream.read(bytes)) != -1) { +// out.write(bytes, 0, read); +// } +// stream.close(); +// out.flush(); +// out.close(); +// return f.getAbsolutePath(); +// +// } catch (Exception e) { +// e.printStackTrace(); +// } + return null; + } + + /** + * @param att + * @param filePath + * @return + * @throws IOException + */ + public static String saveFile(ByteArrayOutputStream att, String filePath) throws IOException { + + File f = new File(filePath); + FileOutputStream fos; + try { + fos = new FileOutputStream(f); + att.writeTo(fos); + fos.close(); + return f.getAbsolutePath(); + } catch (IOException ioe) { + // Handle exception here + ioe.printStackTrace(); + } finally { + } + + return null; + + } +} diff --git a/src/main/java/org/etsi/osl/tmf/util/KrokiClient.java b/src/main/java/org/etsi/osl/tmf/util/KrokiClient.java new file mode 100644 index 0000000000000000000000000000000000000000..e84bebe2e1dba025187fdbe89f434b15dfb03a83 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/util/KrokiClient.java @@ -0,0 +1,47 @@ +package org.etsi.osl.tmf.util; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.zip.Deflater; + +public class KrokiClient { + + + + public static String encodedGraph(String body) { + + String graph = body; + if ( body == null ) { + graph = "blockdiag {}"; + } + try { + byte[] gg = encode( graph ); + String s = new String( gg, StandardCharsets.UTF_8); + return s; + + } catch (IOException e) { + e.printStackTrace(); + } + + return null; + } + + + + private static byte[] encode(String decoded) throws IOException { + return Base64.getUrlEncoder().encode(compress(decoded.getBytes())); + } + + private static byte[] compress(byte[] source) throws IOException { + Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION); + deflater.setInput(source); + deflater.finish(); + + byte[] buffer = new byte[2048]; + int compressedLength = deflater.deflate(buffer); + byte[] result = new byte[compressedLength]; + System.arraycopy(buffer, 0, result, 0, compressedLength); + return result; + } +} diff --git a/src/main/java/org/etsi/osl/tmf/util/PrimitivesParser.java b/src/main/java/org/etsi/osl/tmf/util/PrimitivesParser.java new file mode 100644 index 0000000000000000000000000000000000000000..ca5a5da3e4c0772800eb817a203c5f1ea0765d81 --- /dev/null +++ b/src/main/java/org/etsi/osl/tmf/util/PrimitivesParser.java @@ -0,0 +1,560 @@ +/** + * @Author: Eduardo Santos + * @Date: 2024-05-30 12:49:06 + * @Last Modified by: Eduardo Santos + * @Last Modified time: 2024-05-31 13:27:02 + */ + + /*- + * ========================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.util; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.yaml.snakeyaml.Yaml; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.etsi.osl.model.nfv.NetworkServiceDescriptor; +import org.etsi.osl.model.nfv.ConstituentVxF; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * This class is responsible for parsing available primitives from a Network Service +* from its Network Service Descriptor (NSD) and Virtual Network Function Descriptor (VNFD). +*/ +public class PrimitivesParser { + + private static final transient Log logger = LogFactory.getLog(PrimitivesParser.class.getName()); + + public static Map cpdToVduMap = new HashMap(); + + + /** + * Extracts all available primitives from a given Network Service Descriptor (NSD). + * This method processes the NSD to retrieve and map its constituent VNF descriptors (VNFDs) and Virtual Deployment Units (VDUs), + * then extracts the configuration primitives associated with each VDU and VNF, returning a consolidated JSON object with all primitives. + * + * @param nsd The NetworkServiceDescriptor object containing the network service data. + * @return A JSONObject containing all the extracted primitives from the NSD. + */ + public static JSONObject extractPrimitives(NetworkServiceDescriptor nsd) { + JSONObject allPrimitives = new JSONObject(); + + try { + // Access the first element only, to handle the case where there are duplicate descriptor fields + ConstituentVxF vxf = nsd.getConstituentVxF().get(0); + + if (vxf.getVxfref() == null) { + throw new NullPointerException("vxf.getVxfref() is null"); + } + + JSONObject nsdJson = PrimitivesParser.processNSD(nsd); + JSONObject vnfdJson = PrimitivesParser.processVxF(vxf); + + JSONObject vnfs = PrimitivesParser.extractVNFIds(nsdJson); + + vnfs = PrimitivesParser.mapVDUsToVNFs(vnfdJson, vnfs); + + JSONObject vduPrimitives = PrimitivesParser.extractVDUPrimitives(vnfdJson, vnfs); + + allPrimitives = PrimitivesParser.extractVNFPrimitives(vnfdJson, vduPrimitives); + } catch (NullPointerException e) { + logger.error("Error extracting primitives: " + e.getMessage()); + e.printStackTrace(); + // allPrimitives is already initialized to an empty JSONObject + } catch (Exception e) { + logger.error("Error extracting primitives."); + e.printStackTrace(); + } + + return allPrimitives; + + } + + + /** + * Converts a NetworkServiceDescriptor's descriptor from YAML string to a JSONObject. + * This method utilizes the YAML library to parse the descriptor of the NetworkServiceDescriptor, + * converting it into a Map and then into a JSONObject for easier manipulation in Java. + * + * @param nsd The NetworkServiceDescriptor object containing the YAML string in its descriptor. + * @return A JSONObject representing the parsed YAML descriptor. + */ + public static JSONObject processNSD(NetworkServiceDescriptor nsd) { + // Parse the NSD descriptor from string to YAML + Yaml yaml = new Yaml(); + JSONObject nsdJson; + + Object obj = yaml.load(nsd.getDescriptor()); + + if ( obj instanceof ArrayList) { + // Parse the NSD descriptor from YAML to JSONObject + nsdJson = new JSONObject( (ArrayList)obj ); + + }else { + Map yamlMap = ( Map ) obj; + // Parse the NSD descriptor from YAML to JSONObject + nsdJson = new JSONObject(yamlMap); + } + + + return nsdJson; + } + + + /** + * Converts a VNF descriptor from JSON string to JSONObject. + * This method takes the JSON descriptor from a ConstituentVxF object, manipulates the string to ensure proper JSON format, + * and converts it into a JSONObject. + * + * @param vxf The ConstituentVxF object containing the JSON string of the VNF descriptor. + * @return A JSONObject representing the VNF descriptor. + */ + public static JSONObject processVxF(ConstituentVxF vxf) { + // Parse the VNF descriptor from JSON string to JSONObject + //JSONObject vnfdJson = new JSONObject(vxf.getVxfref().getDescriptor().substring(1, vxf.getVxfref().getDescriptor().length() - 1)); + + String descriptor = vxf.getVxfref().getDescriptor(); + JSONObject vnfdJson; + + // Check if the descriptor starts with a JSON array or object syntax + if (descriptor.trim().startsWith("[")) { + // It's JSON + vnfdJson = new JSONObject(descriptor.substring(1, descriptor.length() - 1)); + } else if (descriptor.trim().startsWith("{")) { + // It's JSON + vnfdJson = new JSONObject(descriptor); + } else{ + // It's YAML + Yaml yaml = new Yaml(); + Map yamlMap = yaml.load(descriptor); + + // Convert the Map to a JSONObject + vnfdJson = new JSONObject(yamlMap).getJSONObject("vnfd"); + } + + return vnfdJson; + } + + + /** + * Extracts VNF identifiers and their constituent CPD IDs from a NSD. + * This method serves as the orchestrator that calls other methods to handle specific parts of the JSON structure. + * + * @param nsdJson The JSONObject containing the NSD data. + * @return JSONObject containing an array of VNFs with their IDs and associated constituent CPD IDs. + */ + public static JSONObject extractVNFIds(JSONObject nsdJson) { + // JSONObject to hold the VNFs and their details + JSONObject vnfs = new JSONObject(); + + //JSONArray to store each VNF + JSONArray vnfsArray = new JSONArray(); + + // Attach the empty array to the JSONObject under the key "vnfs" + vnfs.put("vnfs", vnfsArray); + JSONArray nsdArray = null; + if ( nsdJson.has("nsd") ) { + nsdArray = nsdJson.getJSONObject("nsd").getJSONArray("nsd"); + } else { + nsdArray = new JSONArray(); + nsdArray.put(nsdJson); + } + + + // Assuming that there might be multiple 'nsd' entries, iterate over them + processNSDEntries(nsdArray, vnfsArray); + + return vnfs; + } + + + /** + * Processes each NSD entry. + * + * @param nsdArray The array of NSD entries. + * @param vnfsArray The array to store processed VNF data. + */ + private static void processNSDEntries(JSONArray nsdArray, JSONArray vnfsArray) { + for (int nsdIndex = 0; nsdIndex < nsdArray.length(); nsdIndex++) { + JSONArray nsdDf = nsdArray.getJSONObject(nsdIndex).getJSONArray("df"); + + processDeploymentFlavors(nsdDf, vnfsArray); + } + } + + + /** + * Processes each deployment flavor within an NSD. + * + * @param nsdDf The array of deployment flavors. + * @param vnfsArray The array to store processed VNF data. + */ + private static void processDeploymentFlavors(JSONArray nsdDf, JSONArray vnfsArray) { + for (int dfIndex = 0; dfIndex < nsdDf.length(); dfIndex++) { + JSONArray vnfProfilesArray = nsdDf.getJSONObject(dfIndex).getJSONArray("vnf-profile"); + + processVNFProfiles(vnfProfilesArray, vnfsArray); + } + } + + + /** + * Processes each VNF profile to extract the VNF details. + * + * @param vnfProfilesArray The array of VNF profiles. + * @param vnfsArray The array to store VNF data. + */ + private static void processVNFProfiles(JSONArray vnfProfilesArray, JSONArray vnfsArray) { + for (int vnfIndex = 0; vnfIndex < vnfProfilesArray.length(); vnfIndex++) { + // For each VNF, extract its id + JSONObject vnfProfile = vnfProfilesArray.getJSONObject(vnfIndex); + + extractVNFDetails(vnfProfile, vnfsArray); + } + } + + + /** + * Extracts details from each VNF profile and adds them to the VNFS array. + * + * @param vnfProfile The VNF profile JSONObject. + * @param vnfsArray The array to store VNF data. + */ + private static void extractVNFDetails(JSONObject vnfProfile, JSONArray vnfsArray) { + String vnfId = vnfProfile.getString("id"); + + // Create a new JSONObject for this VNF, storing its ID + JSONObject vnfObj = new JSONObject(); + + vnfObj.put("id", vnfId); + + // Extract virtual link connectivity information for each VNF + JSONArray virtualLinkConnectivityArray = vnfProfile.getJSONArray("virtual-link-connectivity"); + JSONArray constituentCpdIdArray = new JSONArray(); + + for (int vlcIndex = 0; vlcIndex < virtualLinkConnectivityArray.length(); vlcIndex++) { + // Extract and iterate over the constituent cpd ids for each virtual link connectivity + JSONArray constituentCpdIds = virtualLinkConnectivityArray.getJSONObject(vlcIndex).getJSONArray("constituent-cpd-id"); + + for (int cpdIndex = 0; cpdIndex < constituentCpdIds.length(); cpdIndex++) { + String constituentCpdId = constituentCpdIds.getJSONObject(cpdIndex).getString("constituent-cpd-id"); + + constituentCpdIdArray.put(constituentCpdId); + } + + // Associate the array of constituent cpd ids with the corresponding VNF + vnfObj.put("constituent-cpd-ids", constituentCpdIdArray); + } + vnfsArray.put(vnfObj); + } + + + /** + * Maps VDUs to VNFs based on the provided JSON representations + * + * @param vnfdJson JSON object representing the Virtual Network Function Descriptor (VNFD). + * @param vnfs JSON object representing the Virtual Network Functions (VNFs). + * @return JSON object with VNFs updated with VDU IDs. + */ + public static JSONObject mapVDUsToVNFs(JSONObject vnfdJson, JSONObject vnfs) { + buildCpdToVduMap(vnfdJson); + + return updateVNFsWithVDUIds(vnfs); + } + + + /** + * Builds a mapping of CPDs to VDU IDs based on the VNFD JSON. + * + * @param vnfdJson JSON object representing the VNFD. + */ + private static void buildCpdToVduMap(JSONObject vnfdJson) { + // Retrieve the array of external connection point descriptors from the VNFD + JSONArray extCpdArray = vnfdJson.optJSONArray("ext-cpd"); + + if (extCpdArray == null) return; // Early return if the array doesn't exist + + // Iterate through each connection point descriptor to map them to VDU ids + for (int i = 0; i < extCpdArray.length(); i++) { + JSONObject cpdEntry = extCpdArray.getJSONObject(i); + String id = cpdEntry.optString("id", null); // cpd id + JSONObject intCpd = cpdEntry.optJSONObject("int-cpd"); // VDU id linked to this cpd + + if (id != null && intCpd != null) { + String vduId = intCpd.optString("vdu-id", "Unknown"); + + // Map each CPD id to its corresponding VDU id + cpdToVduMap.put(id, vduId); + } + } + } + + + /** + * Updates VNF JSON objects with VDU IDs based on the mapping created by {@link #buildCpdToVduMap(JSONObject)}. + * + * @param vnfs JSON object representing the Virtual Network Functions (VNFs). + * @return JSON object with VNFs updated with VDU IDs. + */ + private static JSONObject updateVNFsWithVDUIds(JSONObject vnfs) { + // Modify vnfs JSON using the map + JSONArray vnfsArray = vnfs.optJSONArray("vnfs"); + + if (vnfsArray == null) return vnfs; // Early return if no VNFs found + + // Iterate through each VNF to replace "constituent-cpd-ids" with "vdu-ids" + for (int i = 0; i < vnfsArray.length(); i++) { + JSONObject vnf = vnfsArray.getJSONObject(i); + + updateVNFWithVDUIds(vnf); + } + return vnfs; + } + + + /** + * Updates a single VNF JSON object with VDU IDs by replacing "constituent-cpd-ids" with "vdu-ids". + * + * @param vnf JSON object representing a single VNF. + */ + private static void updateVNFWithVDUIds(JSONObject vnf) { + JSONArray cpdIds = vnf.optJSONArray("constituent-cpd-ids"); + if (cpdIds == null) return; // Early return if no cpd ids + + JSONArray vduIds = new JSONArray(); + + // Replace each cpd id with the corresponding VDU id + for (int j = 0; j < cpdIds.length(); j++) { + String cpdId = cpdIds.optString(j, null); + + if (cpdId != null) { + // Get the VDU ID associated with the CPD ID, or mark as "Unknown" if no mapping exists + String vduId = cpdToVduMap.getOrDefault(cpdId, "Unknown"); + + vduIds.put(vduId); + } + } + + // Update the VNF JSON object: replace "constituent-cpd-ids" with "vdu-ids" + vnf.put("vdu-ids", vduIds); + vnf.remove("constituent-cpd-ids"); + } + + + /** + * Extracts VNF primitives based on management connection points and updates the VNFs with the corresponding VDU configurations. + * + * @param vnfdJson The JSON object containing the VNFD data. + * @param vnfs The JSON object containing VNF configurations. + * @return JSONObject Updated JSON object with VNFs containing corresponding VDU configurations. + */ + public static JSONObject extractVNFPrimitives(JSONObject vnfdJson, JSONObject vnfs) { + // Extract the array of VNF configurations from the provided JSON object + JSONArray vnfsArray = vnfs.getJSONArray("vnfs"); + + // Retrieve the management connection point from the VNFD JSON + String vnfMgmtCp = vnfdJson.getString("mgmt-cp"); + + // Iterate through each VNF in the array + processVNFs(vnfsArray, vnfMgmtCp); + + return vnfs; + } + + + /** + * Process each VNF to check and update its configuration based on VDU management connection points. + * + * @param vnfsArray JSONArray of VNFs. + * @param vnfMgmtCp The management connection point identifier from VNFD. + */ + private static void processVNFs(JSONArray vnfsArray, String vnfMgmtCp) { + for (int i = 0; i < vnfsArray.length(); i++) { + // Get the VDU configurations for the current VNF + JSONArray vduConfigs = vnfsArray.getJSONObject(i).getJSONArray("vdu-configs"); + + // Iterate through each VDU configuration + processVDUConfigurations(vduConfigs, vnfsArray.getJSONObject(i), vnfMgmtCp); + } + } + + + /** + * Iterates through VDU configurations and checks for matches with the VNF's management connection point to update configuration primitives. + * + * @param vduConfigs JSONArray of VDU configurations for a VNF. + * @param vnf JSONObject of the current VNF. + * @param vnfMgmtCp The management connection point identifier. + */ + private static void processVDUConfigurations(JSONArray vduConfigs, JSONObject vnf, String vnfMgmtCp) { + for (int j = 0; j < vduConfigs.length(); j++) { + checkAndUpdateVNFConfiguration(vduConfigs.getJSONObject(j), vnf, vnfMgmtCp); + } + } + + + /** + * Checks if the VDU configuration matches the management connection point and updates the VNF configuration if it does. + * + * @param vduConfig JSONObject of the current VDU configuration. + * @param vnf JSONObject of the current VNF. + * @param vnfMgmtCp The management connection point identifier. + */ + private static void checkAndUpdateVNFConfiguration(JSONObject vduConfig, JSONObject vnf, String vnfMgmtCp) { + String vduConfigId = vduConfig.getString("id"); + + // Check each entry in the map for a matching management connection point + for (String key : cpdToVduMap.keySet()) { + + // If the VDU's external connection point equal the VNF's management connection point + // this means that the VDU is the VNF's management VDU, i.e., when invoking the + // VNF-level primitives, the invoked primitives will be the magagement VDU ones + if (key.equals(vnfMgmtCp) && cpdToVduMap.get(key).equals(vduConfigId)) { + // Update the VNF object with the configuration primitives from the correspondent management VDU + vnf.put("config-primitive", vduConfig.getJSONArray("config-primitive")); + } + } + } + + + /** + * Processes VNFD JSON to extract and map VDU primitives based on configurations, then updates VNFs JSON structure accordingly. + * + * @param vnfdJson The VNFD JSON object containing deployment flavors and operational configurations. + * @param vnfs The JSON object containing VNFs that will be updated with VDU configurations. + * @return JSONObject Updated VNFs JSON object with VDU configurations. + */ + public static JSONObject extractVDUPrimitives(JSONObject vnfdJson, JSONObject vnfs) { + JSONArray vnfsArray = vnfs.getJSONArray("vnfs"); + JSONArray dfs = vnfdJson.getJSONArray("df"); + + for (int i = 0; i < dfs.length(); i++) { + JSONObject vduToConfig = mapVDUConfigs(dfs.getJSONObject(i)); + updateVNFsWithVDUConfigs(vnfsArray, vduToConfig); + } + + return vnfs; + } + + + /** + * Maps each VDU ID to its config-primitives, excluding the 'execution-environment-ref' from the primitives. + * + * @param df The deployment flavor JSON object. + * @return JSONObject Mapping of VDU IDs to their config primitives. + */ + private static JSONObject mapVDUConfigs(JSONObject df) { + // Mapping from VDU id to config-primitives + JSONArray day1_2 = df.getJSONObject("lcm-operations-configuration") + .getJSONObject("operate-vnf-op-config") + .getJSONArray("day1-2"); + + if (day1_2 == null || day1_2.length() == 0) { + logger.error("Error: Day 1-2 configuration array is missing or empty."); + + // Return an empty JSONObject if no data is present + return new JSONObject(); + } + + JSONObject vduToConfig = new JSONObject(); + + for (int i = 0; i < day1_2.length(); i++) { + JSONObject vduConfig = day1_2.getJSONObject(i); + + vduToConfig.put(vduConfig.getString("id"), filterConfigPrimitives(vduConfig.getJSONArray("config-primitive"))); + } + + return vduToConfig; + } + + + /** + * Removes 'execution-environment-ref' from each config primitive and returns a filtered array of config primitives. + * + * @param configPrimitives The JSON array of config primitives. + * @return JSONArray The filtered array of config primitives. + */ + private static JSONArray filterConfigPrimitives(JSONArray configPrimitives) { + JSONArray filteredConfigPrimitives = new JSONArray(); + + // Remove execution-environment-ref from each config-primitive + for (int j = 0; j < configPrimitives.length(); j++) { + JSONObject primitive = configPrimitives.getJSONObject(j); + + primitive.remove("execution-environment-ref"); + filteredConfigPrimitives.put(primitive); + } + + return filteredConfigPrimitives; + } + + + /** + * Updates each VNF in the vnfsArray with the mapped VDU configurations. + * + * @param vnfsArray The JSON array of VNFs to update. + * @param vduToConfig The mapping of VDU IDs to their filtered config primitives. + */ + private static void updateVNFsWithVDUConfigs(JSONArray vnfsArray, JSONObject vduToConfig) { + // Append the filtered config-primitive to each VDU in the VNFs JSON and remove vdu-ids + JSONObject vnf; + for (int i = 0; i < vnfsArray.length(); i++) { + vnf = vnfsArray.getJSONObject(i); + + updateVNFWithVDUConfig(vnf, vduToConfig); + } + } + + + /** + * Updates a single VNF with VDU configurations using provided mappings. + * + * @param vnf The JSON object of the VNF to update. + * @param vduToConfig The mapping of VDU IDs to their filtered config primitives. + */ + private static void updateVNFWithVDUConfig(JSONObject vnf, JSONObject vduToConfig) { + JSONArray vduIds = vnf.getJSONArray("vdu-ids"); + JSONArray vduConfigs = new JSONArray(); + + JSONObject vduConfig; + for (int j = 0; j < vduIds.length(); j++) { + String vduId = vduIds.getString(j); + vduConfig = new JSONObject(); + + vduConfig.put("id", vduId); + vduConfig.put("config-primitive", vduToConfig.getJSONArray(vduId)); + vduConfigs.put(vduConfig); + } + + vnf.put("vdu-configs", vduConfigs); + // Removing the 'vdu-ids' key after updating + vnf.remove("vdu-ids"); + } +} + diff --git a/src/main/resources/application-testing.yml b/src/main/resources/application-testing.yml new file mode 100644 index 0000000000000000000000000000000000000000..b9e89cc5de12f717197a1d0ce97062dad6113315 --- /dev/null +++ b/src/main/resources/application-testing.yml @@ -0,0 +1,167 @@ +server: + port: 13082 + servlet: + context-path : /tmf-api/ +spring: + config: + activate: + on-profile: "testing" + application: + name: openslice-service-catalog-management-api-testing + datasource: + url: jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 + password: sa + username: sa + jpa: + database-platform: org.hibernate.dialect.H2Dialect + hibernate: + ddl-auto: create-drop + hbm2ddl.auto: create-drop + properties: + hibernate: + globally_quoted_identifiers: true + globally_quoted_identifiers_skip_column_definitions: true + show-sql: false + generate-ddl: true + + # Embedded ActiveMQ Configuration Example + activemq: + broker-url: vm://embedded?broker.persistent=false,useShutdownHook=false + in-memory: true + non-blocking-redelivery: true + pool: + block-if-full: true + block-if-full-timeout: -1 + create-connection-on-startup: true + enabled: false + expiry-timeout: 0 + idle-timeout: 30000 + max-connections: 1 + maximum-active-session-per-connection: 500 + reconnect-on-exception: true + time-between-expiration-check: -1 + use-anonymous-producers: true + # Spring JMS Settings + jms: + listener: + acknowledge-mode: auto + auto-startup: true + concurrency: 5 + max-concurrency: 10 + pub-sub-domain: false + template: + default-destination: + delivery-mode: non_persistent + priority: 100 + qos-enabled: true + receive-timeout: 1000 + time-to-live: 36000 + +logging: + level: + root: INFO + org.springframework: INFO + org.hibernate.SQL: INFO + org.hibernate.type.descriptor.sql.BasicBinder: INFO + pattern: + console: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" + file: "%d %p %c{1.} [%t] %m%n" + + +swagger: + authserver: http://localhost/auth/realms/openslice + clientid: "osapiWebClientId" + clientsecret: "secret" + +kroki: + serverurl: http://localhost:8000 + +oauthsign: + key: "XXX" + +#QUEUE MESSAGES +CATALOG_GET_SERVICEORDERS: "jms:queue:CATALOG.GET.SERVICEORDERS" +CATALOG_GET_SERVICEORDER_BY_ID: "jms:queue:CATALOG.GET.SERVICEORDER_BY_ID" +CATALOG_ADD_SERVICEORDER: "jms:queue:CATALOG.ADD.SERVICEORDER" +CATALOG_UPD_SERVICEORDER_BY_ID: "jms:queue:CATALOG.UPD.SERVICEORDER_BY_ID" +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_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" +CATALOG_UPD_SERVICE: "jms:queue:CATALOG.UPD.SERVICE" +CATALOG_GET_SERVICE_BY_ID: "jms:queue:CATALOG.GET.SERVICE" +CATALOG_GET_SERVICE_BY_ORDERID: "jms:queue:CATALOG.GET.SERVICE_BY_ORDERID" +CATALOG_SERVICE_QUEUE_ITEMS_GET: "jms:queue:CATALOG.SERVICEQUEUEITEMS.GET" +CATALOG_SERVICE_QUEUE_ITEM_UPD: "jms:queue:CATALOG.SERVICEQUEUEITEM.UPDATE" +CATALOG_SERVICE_QUEUE_ITEM_DELETE: "jms:queue:CATALOG.SERVICEQUEUEITEM.DELETE" +CATALOG_GET_PARTNER_ORGANIZATON_BY_ID: "jms:queue:CATALOG.GET.PARTNER_ORGANIZATION_BY_ID" +CATALOG_UPDATE_PARTNER_ORGANIZATION: "jms:queue:CATALOG.UPD.PARTNER_ORGANIZATION" +CATALOG_SERVICES_TO_TERMINATE: "jms:queue:CATALOG.GET.SERVICETOTERMINATE" +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" + +#ALARMS +ALARMS_ADD_ALARM: "jms:queue:ALARMS.ADD.ALARM" +ALARMS_UPDATE_ALARM: "jms:queue:ALARMS.UPDATE.ALARM" +ALARMS_GET_ALARM: "jms:queue:ALARMS.GET.ALARM" + +#EVENT TOPICS IN Message Bus +EVENT_SERVICE_CREATE: "jms:topic:EVENT.SERVICE.CREATE" +EVENT_SERVICE_STATE_CHANGED: "jms:topic:EVENT.SERVICE.STATECHANGED" +EVENT_SERVICE_DELETE: "jms:topic:EVENT.SERVICE.DELETE" +EVENT_SERVICE_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.SERVICE.ATTRCHANGED" +EVENT_SERVICE_ORDER_CREATE: "jms:topic:EVENT.SERVICEORDER.CREATE" +EVENT_SERVICE_ORDER_STATE_CHANGED: "jms:topic:EVENT.SERVICEORDER.STATECHANGED" +EVENT_SERVICE_ORDER_DELETE: "jms:topic:EVENT.SERVICEORDER.DELETE" +EVENT_SERVICE_ORDER_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.SERVICEORDER.ATTRCHANGED" +EVENT_CUSTOMER_CREATE: "jms:topic:EVENT.CUSTOMER.CREATE" +EVENT_CUSTOMER_CHANGED: "jms:topic:EVENT.CUSTOMER.CHANGE" +EVENT_INDIVIDUAL_CREATE: "jms:topic:EVENT.INDIVIDUAL.CREATE" +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" + +#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" + +#RESOURCES MESSAGES +CATALOG_ADD_RESOURCE: "jms:queue:CATALOG.ADD.RESOURCE" +CATALOG_UPD_RESOURCE: "jms:queue:CATALOG.UPD.RESOURCE" +CATALOG_UPDADD_RESOURCE: "jms:queue:CATALOG.UPDADD.RESOURCE" +CATALOG_GET_RESOURCE_BY_ID: "jms:queue:CATALOG.GET.RESOURCE" +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" +EVENT_RESOURCE_CREATE: "jms:topic:EVENT.RESOURCE.CREATE" +EVENT_RESOURCE_STATE_CHANGED: "jms:topic:EVENT.RESOURCE.STATECHANGED" +EVENT_RESOURCE_DELETE: "jms:topic:EVENT.SERVICE.RESOURCE" +EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.RESOURCE.ATTRCHANGED" +CATALOG_RESOURCES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" + +#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" + + +#SERVICE_TEST +CATALOG_GET_SERVICETESTSPEC_BY_ID: "jms:queue:CATALOG.GET.SERVICETESTSPEC_BY_ID" +CATALOG_ADD_SERVICETEST: "jms:queue:CATALOG.ADD.SERVICETEST" +CATALOG_UPD_SERVICETEST: "jms:queue:CATALOG.UPD.SERVICETEST" +CATALOG_GET_SERVICETEST_BY_ID: "jms:queue:CATALOG.GET.SERVICETEST" + +#NS ACTIONS +NFV_CATALOG_NSACTIONS_SCALE: "jms:queue:NSACTIONS.SCALE" +NFV_CATALOG_NS_LCMCHANGED: "jms:topic:NFV_CATALOG_NS_LCMCHANGED" + +#RESERVATION_API +RESERVATION_CREATE: "jms:queue:RESERVATION.ADD" +RESERVATION_AVAILABILITY_CHECK: "jms:queue:RESERVATION.AVAILABILITYCHECK" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..fb8fddc20895d76086621d9810638e9ebfbe9502 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,203 @@ +origins: http://localhost,http://localhost:8888,http://localhost:13082,http://127.0.0.1:13082,https://localhost, +permit-all: /tmf-api/** + + +server: + port: 13082 + servlet: + context-path : /tmf-api + error: + include-message: always + ssl: + enabled: false + +springdoc: + version: '@springdoc.version@' + writer-with-default-pretty-printer: true + swagger-ui: + display-request-duration: true + groups-order: ASC + operationsSorter: method + disable-swagger-default-url: true + use-root-path: true + oauth: + client-id: osapiWebClientId + clientsecret: "secret" + use-pkce-with-authorization-code-grant: false + oAuthFlow: + authorizationUrl: http://keycloak:8080/auth/realms/openslice/protocol/openid-connect/auth + tokenUrl: http://keycloak:8080/auth/realms/openslice/protocol/openid-connect/token + show-actuator: true + +spring-addons: + issuers: + - uri: http://keycloak:8080/auth/realms/openslice + username-json-path: $.preferred_username + claims: + - jsonPath: $.realm_access.roles + - jsonPath: $.resource_access.*.roles + +spring: + config: + activate: + on-profile: "default" + application: + name: openslice-service-catalog-management-api + datasource: + url: jdbc:mysql://localhost:13306/ostmfdb?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC + password: letmein + username: root + hikari: + minimumIdle: 2 + maximumPoolSize: 40 + idleTimeout: 120000 + connectionTimeout: 400000 + leakDetectionThreshold: 100000 + jpa: + database-platform: org.etsi.osl.tmf.LocalMysqlDialect + hibernate: + ddl-auto: update + show-sql: false + generate-ddl: true + properties.hibernate.current_session_context_class: org.springframework.orm.hibernate5.SpringSessionContext + properties: + hibernate: + connection: + characterEncoding: utf-8 + CharSet: utf-8 + useUnicode: true + servlet: + multipart.max-file-size: 10MB + multipart.max-request-size: 10MB + activemq: + brokerUrl: tcp://localhost:61616?jms.watchTopicAdvisories=false + user: artemis + password: artemis + pool: + enabled: true + max-connections: 100 + packages: + trust-all: true + security: + oauth2: + resourceserver: + jwt: + issuer-uri: http://keycloak:8080/auth/realms/openslice + jwk-set-uri: http://keycloak:8080/auth/realms/openslice/.well-known/openid-configuration + + +logging: + level: + root: INFO + portal.api: INFO + org.etsi.osl.tmf.*: DEBUG + org.springframework: INFO + org.apache.camel: INFO + com.zaxxer.hikari: INFO + pattern: + console: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" + file: "%d %p %c{1.} [%t] %m%n" + + + + +kroki: + serverurl: http://localhost:8000 + +oauthsign: + key: "EK97Y7Y9WPGG1MEG" + +#QUEUE MESSAGES +CATALOG_GET_SERVICEORDERS: "jms:queue:CATALOG.GET.SERVICEORDERS" +CATALOG_GET_SERVICEORDER_BY_ID: "jms:queue:CATALOG.GET.SERVICEORDER_BY_ID" +CATALOG_ADD_SERVICEORDER: "jms:queue:CATALOG.ADD.SERVICEORDER" +CATALOG_UPD_SERVICEORDER_BY_ID: "jms:queue:CATALOG.UPD.SERVICEORDER_BY_ID" +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_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" +CATALOG_UPD_SERVICE: "jms:queue:CATALOG.UPD.SERVICE" +CATALOG_GET_SERVICE_BY_ID: "jms:queue:CATALOG.GET.SERVICE" +CATALOG_GET_SERVICE_BY_ORDERID: "jms:queue:CATALOG.GET.SERVICE_BY_ORDERID" +CATALOG_SERVICE_QUEUE_ITEMS_GET: "jms:queue:CATALOG.SERVICEQUEUEITEMS.GET" +CATALOG_SERVICE_QUEUE_ITEM_UPD: "jms:queue:CATALOG.SERVICEQUEUEITEM.UPDATE" +CATALOG_SERVICE_QUEUE_ITEM_DELETE: "jms:queue:CATALOG.SERVICEQUEUEITEM.DELETE" +CATALOG_GET_PARTNER_ORGANIZATON_BY_ID: "jms:queue:CATALOG.GET.PARTNER_ORGANIZATION_BY_ID" +CATALOG_UPDATE_PARTNER_ORGANIZATION: "jms:queue:CATALOG.UPD.PARTNER_ORGANIZATION" +CATALOG_SERVICES_TO_TERMINATE: "jms:queue:CATALOG.GET.SERVICETOTERMINATE" +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" + +#ALARMS +ALARMS_ADD_ALARM: "jms:queue:ALARMS.ADD.ALARM" +ALARMS_UPDATE_ALARM: "jms:queue:ALARMS.UPDATE.ALARM" +ALARMS_GET_ALARM: "jms:queue:ALARMS.GET.ALARM" + +#EVENT TOPICS IN Message Bus +EVENT_SERVICE_CREATE: "jms:topic:EVENT.SERVICE.CREATE" +EVENT_SERVICE_STATE_CHANGED: "jms:topic:EVENT.SERVICE.STATECHANGED" +EVENT_SERVICE_DELETE: "jms:topic:EVENT.SERVICE.DELETE" +EVENT_SERVICE_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.SERVICE.ATTRCHANGED" +EVENT_SERVICE_ORDER_CREATE: "jms:topic:EVENT.SERVICEORDER.CREATE" +EVENT_SERVICE_ORDER_STATE_CHANGED: "jms:topic:EVENT.SERVICEORDER.STATECHANGED" +EVENT_SERVICE_ORDER_DELETE: "jms:topic:EVENT.SERVICEORDER.DELETE" +EVENT_SERVICE_ORDER_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.SERVICEORDER.ATTRCHANGED" +EVENT_CUSTOMER_CREATE: "jms:topic:EVENT.CUSTOMER.CREATE" +EVENT_CUSTOMER_CHANGED: "jms:topic:EVENT.CUSTOMER.CHANGE" +EVENT_INDIVIDUAL_CREATE: "jms:topic:EVENT.INDIVIDUAL.CREATE" +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" + +#QUEUE MESSSAGES WITH VNFNSD CATALOG +NFV_CATALOG_GET_NSD_BY_ID: "jms:queue:NFVCATALOG.GET.NSD_BY_ID" + +#MISC +GET_USER_BY_USERNAME: "jms:queue:GET.USER_BY_USERNAME" + +#RESOURCES MESSAGES +CATALOG_ADD_RESOURCE: "jms:queue:CATALOG.ADD.RESOURCE" +CATALOG_UPD_RESOURCE: "jms:queue:CATALOG.UPD.RESOURCE" +CATALOG_UPDADD_RESOURCE: "jms:queue:CATALOG.UPDADD.RESOURCE" +CATALOG_GET_RESOURCE_BY_ID: "jms:queue:CATALOG.GET.RESOURCE" +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" +EVENT_RESOURCE_CREATE: "jms:topic:EVENT.RESOURCE.CREATE" +EVENT_RESOURCE_STATE_CHANGED: "jms:topic:EVENT.RESOURCE.STATECHANGED" +EVENT_RESOURCE_DELETE: "jms:topic:EVENT.SERVICE.RESOURCE" +EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED: "jms:topic:EVENT.RESOURCE.ATTRCHANGED" +CATALOG_RESOURCES_OF_PARTNERS: "jms:queue:CATALOG.GET.SERVICESOFPARTNERS" + +#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" + + +#SERVICE_TEST +CATALOG_GET_SERVICETESTSPEC_BY_ID: "jms:queue:CATALOG.GET.SERVICETESTSPEC_BY_ID" +CATALOG_ADD_SERVICETEST: "jms:queue:CATALOG.ADD.SERVICETEST" +CATALOG_UPD_SERVICETEST: "jms:queue:CATALOG.UPD.SERVICETEST" +CATALOG_GET_SERVICETEST_BY_ID: "jms:queue:CATALOG.GET.SERVICETEST" + +#NS ACTIONS +NFV_CATALOG_NSACTIONS_SCALE: "jms:queue:NSACTIONS.SCALE" +NFV_CATALOG_NS_LCMCHANGED: "jms:topic:NFV_CATALOG_NS_LCMCHANGED" + +#RESERVATION_API +RESERVATION_CREATE: "jms:queue:RESERVATION.ADD" +RESERVATION_AVAILABILITY_CHECK: "jms:queue:RESERVATION.AVAILABILITYCHECK" + +--- + + diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt new file mode 100644 index 0000000000000000000000000000000000000000..74229cd400fb31f76673214d76c0256f438e4ccc --- /dev/null +++ b/src/main/resources/banner.txt @@ -0,0 +1,11 @@ + ___ ____ _ _ + / _ \ _ __ ___ _ __ / ___|| (_) ___ ___ + | | | | '_ \ / _ \ '_ \\___ \| | |/ __/ _ \ + | |_| | |_) | __/ | | |___) | | | (_| __/ + \___/| .__/ \___|_| |_|____/|_|_|\___\___| + |_| + __ __________________ + / / __ __ / __/_ __/ __/ _/ + / _ \/ // / / _/ / / _\ \_/ / + /_.__/\_, / /___/ /_/ /___/___/ + /___/ \ No newline at end of file diff --git a/src/main/resources/gst.json b/src/main/resources/gst.json new file mode 100644 index 0000000000000000000000000000000000000000..246026d825a0bfe37fdebf938c1daa81c7a672df --- /dev/null +++ b/src/main/resources/gst.json @@ -0,0 +1,3504 @@ +{ + "name": "GST External", + "description": "GST external example", + "version": "5.0.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + "name": "Availability", + "configurable": false, + "description": "(Communication service) availability: percentage value of the amount of time the end-to-end communication service is delivered according to an agreed QoS, divided by the amount of time the system is expected to deliver the end-to-end service according to the specification in a specific area, see also 3GPP TS 22.261", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "percent", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "95", + "alias": "High availability" + } + } + + ] + }, + { + "name": "Area of Service", + "configurable": false, + "description": "This attribute specifies the area where the UEs can access a particular network slice. Therefore, the attribute specifies the list of the countries where the service will be provided. The list is specific to NSPs and their roaming agreements. In case the list comprises more than one entry, roaming agreements between the HPMN and the VPMNs are required.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } , + { + "role": "Region specification", + "name": "Area of Service: Region specification", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "Country", + "alias": "ISO 3166-1 Alpha-2 country codes" + } + } + + ] + }, + { + "name": "Area of Service: Region specification", + "configurable": false, + "description": "For every single country listed in the area of service attribute it needs to be indicated if the service will be provided in the whole country or just in part of the country. If the NSC requires a specific location, this attribute can be used to specify the regions of the country where the service will be provided. It needs to be completed for every country listed in the Area of service attribute. The list of regions is specific for each country and the way to define these regions is the decision of the NSC and NSP.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "Full Country" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Local Region A" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Local Region B" + } + } + + ] + }, + { + "name": "Delay tolerance", + "configurable": false, + "description": "Provide the NSC with service delivery flexibility, especially for the vertical services that are not chasing a high system performance. For instance, the service will be delivered once the mobile system has sufficient resources or during the off-peak hours. For this type of traffic, it is not too critical how long it takes to deliver the amount of data, e.g. within hours, days, weeks, etc.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "Not supported" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Supported" + } + } + ] + }, + { + "name": "Deterministic communication", + "description": "This attribute defines if the network slice supports deterministic communication for.", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Performance", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" }, + { + "role": "Availabilty", + "name": "Deterministic communication: Availabilty", + "relationshipType": "dependency" + }, + { + "role": "Periodicity", + "name": "Deterministic communication: Periodicity", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Deterministic communication: Availabilty", + "configurable": false, + "description": "Availability describes if the network slice supports deterministic communication.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Performance", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "Not supported" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Supported" + } + } + ] + }, + { + "name": "Deterministic communication: Periodicity", + "configurable": false, + "description": "Periodicity provides a list of periodicities supported by the network slice.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: This parameter is present when the “Availability” is set to 1.", + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Performance", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Seconds", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "0" + } + } + ] + }, + { + "name": "Downlink throughput per network slice", + "description": "This attribute relates to the aggregated data rate in downlink for all UEs together in the network slice (this is not per UE).", + "serviceSpecCharRelationship": [ + { + "role": "Guaranteed downlink throughput", + "name": "Downlink throughput per network slice: Guaranteed downlink throughput", + "relationshipType": "dependency" + }, + { + "role": "Additional downlink GBR QoS flows", + "name": "Downlink throughput per network slice: Additional downlink GBR QoS flows", + "relationshipType": "dependency" + }, + { + "role": "Maximum downlink throughput", + "name": "Downlink throughput per network slice: Maximum downlink throughput", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Downlink throughput per network slice: Guaranteed downlink throughput quota", + "configurable": false, + "description": "This parameter describes the guaranteed throughput/data rate supported by the network slice for the aggregate of all GBR QoS flows in downlink belonging to the set of all UEs using the network slice. Not including this parameter or if the value is 0, best effort traffic is expected where no minimum throughput is guaranteed.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "kbps", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "0" + } + } + ] + }, + { + "name": "Downlink throughput per network slice: Additional downlink GBR QoS flows", + "configurable": false, + "description": "Additional downlink GBR QoS flows.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "No additional downlink GBR QoS flows allowed" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Additional downlink GBR QoS flows allowed" + } + } + + ] + }, + { + "name": "Downlink throughput per network slice: Maximum downlink throughput", + "configurable": false, + "description": "This parameter defines the maximum data rate supported by the network slice for all UEs together in downlink.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: Either maximum downlink throughput per network slice or Maximum downlink throughput per UE shall be present", + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "kbps", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0" + } + } + ] + }, + { + "name": "Downlink maximum throughput per UE", + "configurable": false, + "description": "This attribute describes the maximum data rate supported by the network slice per UE in downlink. The attribute is comprised of a list of Service Category parameters with the associated Maximum Downlink Throughput per UE value.", + "serviceSpecCharRelationship": [ + { + "role": "Service category", + "name": "Downlink maximum throughput per UE: Service category", + "relationshipType": "dependency" + }, + { + "role": "Maximum downlink throughput per UE value", + "name": "Downlink maximum throughput per UE: Maximum downlink throughput per UE value", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Downlink maximum throughput per UE: Service category", + "configurable": false, + "description": "This parameter defines a service category which may be assigned to certain groups of devices using the network slice. If present, it shall be associated with a Maximum Downlink Throughput Value parameter.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: Attribute must be present if service is supported requiring guaranteed downlink throughput", + "valueType": "TEXT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "Service Category" + } + } + ] + }, + { + "name": "Downlink maximum throughput per UE: Maximum downlink throughput per UE value", + "configurable": false, + "description": "This parameter defines the Maximum Downlink Throughput per UE value. This may be associated with a Service Category parameter.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: Either maximum downlink throughput per network slice or Maximum downlink throughput per UE shall be present", + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Performance", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "kbps", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "50000" + } + } + ] + }, + { + "name": "Energy efficiency", + "description": "This attribute describes whether the network slice supports the energy efficiency KPI. The energy efficiency is evaluated only when the network is running.", + "serviceSpecCharRelationship": [ + { + "role": "Network slice energy efficiency", + "name": "Energy efficiency: Network slice energy efficiency", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Energy efficiency: Network slice energy efficiency", + "configurable": false, + "description": "", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Bit / Joule", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "40", + "alias": "(Urban area)" + } + } + ] + }, + { + "name": "Group communication support", + "configurable": false, + "description": "This parameter describes which type of group communication is provided by the network slice. ", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "not available" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Single Cell Point to Multipoint (SCPTM)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Broadcast/Multicast" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Broadcast/Multicast + SC-PTM" + } + } + ] + }, + { + "name": "Isolation level: Isolation", + "configurable": false, + "description": "Isolation is one of the key expectations of network slicing. A network slice instance may be fully or partly, logically and/or physically, isolated from another network slice instance. ", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { + "role": "Physical Isolation", + "name": "Isolation level: Physical Isolation", + "relationshipType": "dependency" + }, + { + "role": "Logical Isolation", + "name": "Isolation level: Logical Isolation", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "No Isolation" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Physical Isolation" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Logical Isolation" + } + } + ] + }, + { + "name": "Isolation level: Physical Isolation", + "configurable": false, + "description": "Physical network slices are physically separated (e.g. different rack, different hardware, different location, etc.). Process and threads isolation, Physical memory isolation, Physical network isolation", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: This parameter must be present when Isolation is set to 1.", + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "Process and threads Isolation" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Physical memory Isolation" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Physical network isolation" + } + } + ] + }, + { + "name": "Isolation level: Logical Isolation", + "configurable": false, + "description": "Logical network slices are logically separated. Virtual resources isolation a network slice has access to specific range of resources that do not overlap with other network slices (e.g. VM isolation). Network functions isolation NF (Network Function) is dedicated to the NSC, but virtual resources are shared. Tenant/Service Isolation NSC data are isolated from other NSCs, but virtual resources and NFs are shared", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: ", + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Virtual resource isolation" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Network Function isolation" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Tenant/Service isolation" + } + } + ] + }, + { + "name": "Maximum supported packet size", + "configurable": false, + "description": "This attribute describes the maximum packet size supported by the network slice and may be important for URLLC (Ultra-Reliable Low Latency Communication) and MIoT (Massive IoT), or to indicate a supported maximum transmission unit (MTU).", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Performance", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Bytes", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1500" + } + } + ] + }, + { + "name": "Mission critical support", + "configurable": false, + "description": "Mission-critical (MC) leads to a priority of the network slice relative to others, for C-plane (Control Plane) and U-plane (User Plane) decisions. This is relative to a customer provider relationship and to a PLMN (Public land Mobile Network)", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { + "role": "Mission-critical capability support", + "name": "Mission critical support: Mission-critical capability support", + "relationshipType": "dependency" + }, + { + "role": "Mission-critical service support", + "name": "Mission critical support: Mission-critical service support", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "non-mission-critical" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "mission-critical" + } + } + ] + }, + { + "name": "Mission critical support: Mission-critical capability support", + "configurable": false, + "description": "Mission-critical (MC) leads to a priority of the network slice relative to others, for C-plane (Control Plane) and U-plane (User Plane) decisions. This is relative to a customer provider relationship and to a PLMN (Public land Mobile Network)", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: Conditional: Specifies capabilities available to support mission-critical services. More than one capability may be supported at once. This parameter is optional when Mission critical support is set to 1 (mission-critical slice)", + "valueType": "ARRAY", + + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Inter-user prioritization" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Pre-emption" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Local control" + } + } + ] + }, + { + "name": "Mission critical support: Mission-critical service support", + "configurable": false, + "description": "This attribute specifies whether or not the network slice supports mission-critical push-to-talk (MCPTT), mission-critical data (MCData)], mission-critical video (MCVideo), Isolated E-UTRAN Operation for Public Safety (IOPS), or mission-critical interworking", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: This attribute must be present when Mission critical support is set to 1.", + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "MCPTT" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "MCData" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "MCVideo" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "IOPS" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "MC interworking" + } + } + ] + }, + { + "name": "MMTel support", + "configurable": false, + "description": "This attribute describes whether the network slice supports IP Multimedia Subsystem (IMS) and Multimedia Telephony Service MMTel. This parameter describes whether the GSMA PRD IR.92 0 compliant MMTel deployment is supported in the network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "Not supported" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Supported" + } + } + ] + }, + { + "name": "NB-IoT support", + "configurable": false, + "description": "This parameter describes whether NB-IoTis supported in the network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "Not supported" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Supported" + } + } + ] + }, + { + "name": "Network functions owned by Network Slice Customer", + "configurable": false, + "description": "A NSC can own some network functions. This attribute provides a list of network functions to be provided by the NSC. If the list is empty, or this attribute is not included, the NSC is not providing any network function relevant for the network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "UPF", + "alias": "UPF" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "UDM/AUSF", + "alias": "UDM/AUSF" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "AF", + "alias": "AF" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "PCF", + "alias": "PCF" + } + } + ] + }, + { + "name": "Maximum number of PDU sessions", + "configurable": false, + "description": "This attribute describes the maximum number of concurrent PDU supported by the network slice as specified by the Maximum number of PDU sessions parameter. If the network slice also requires taking into account PDN connections that can be handed over to the 5GS while the UEs are in the EPS, this is specified in the optional attribute EPS counting required. If the parameter EPS counting required is missing, then no counting happens of any PDN connections in EPS", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: Either Number of connections or Number of terminals shall be present", + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "10000", + "alias": "PDU sessions" + } + } + ] + }, + { + "name": "Maximum number of PDU sessions: EPS counting required", + "configurable": false, + "description": "If this parameter indicates that EPS counting is required, the PDU sessions counting shall also take into account the PDN connections in the EPS connected to an APN that maps to a DNN/S-NSSAI of the network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "", + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "no" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "yes" + } + } + ] + }, + { + "name": "Maximum number of UEs", + "configurable": false, + "description": "This attribute describes the maximum number of UEs that can use the network slice simultaneously as specified by the Maximum number of UEs parameter. If the network slice also requires taking into account UEs using PDN connections that can be handed over to the 5GS while they are in the EPS, this is specified in the optional attribute EPS counting required. If the parameter EPS counting required is missing, then no counting of UEs happens while they are in EPS", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: Either Number of connections or Number of terminals shall be present", + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "10000", + "alias": "terminals" + } + } + ] + }, + { + "name": "Maximum number of UEs: EPS counting required", + "configurable": false, + "description": "If this parameter indicates that EPS counting is required, the UE counting shall also take intoaccount the UEs in the EPS with at least one PDN connection in the network slice, i.e. it is required to count the UEs that have at least one PDU session connected to an APN that maps to a DNN/S-NSSAI of the network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "", + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "no" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "yes" + } + } + ] + }, + { + "name": "Performance monitoring", + "configurable": false, + "description": "This attribute provides the capability for NSC and NOP to monitor Key Quality Indicators (KQIs) and Key Performance Indicators (KPIs). KQIs reflect the end-to-end service performance and quality while KPIs reflect the performance of the network", + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "role": "Availability", + "name": "Performance monitoring: Availability", + "relationshipType": "dependency" + }, + { + "role": "Monitoring sample frequency", + "name": "Performance monitoring: Monitoring sample frequency", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Performance monitoring: Availability", + "configurable": false, + "description": "This parameter contains a list of KQIs and KPIs available for monitoring. If the list is empty this attribute is not available in the network slice and the other parameters might be ignored", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "None" + } + } + ] + }, + { + "name": "Performance monitoring: Monitoring sample frequency", + "configurable": false, + "description": "This parameter describes how often the KQIs and KPIs are monitored.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "per second" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "per minute" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "per hour" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "conditional, e.g. in case a defined threshold is crossed" + } + } + ] + }, + { + "name": "Performance prediction", + "configurable": false, + "description": "This attribute defines the capability to allow the mobile system to predict the network and service status. Predictive QoS (Quality of Service) can be done for various Key Quality Indicators (KQIs) and Key Performance Indicators (KPIs). KQIs reflect the end-to-end service performance and quality, while KPIs reflect the performance of the network. The prediction is done for a specific point of time in the future and for a specific geolocation.", + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "role": "Availability", + "name": "Performance prediction: Availability", + "relationshipType": "dependency" + }, + { + "role": "Prediction frequency", + "name": "Performance prediction: Prediction frequency", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Performance prediction: Availability", + "configurable": false, + "description": "This parameter contains a list of KQIs and KPIs available for prediction. If the list is empty, the attribute is not available in the network slice and the other parameters might be ignored", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Throughput" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Latency" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Service Request Success Rate" + } + } + ] + }, + { + "name": "Performance prediction: Prediction frequency", + "configurable": false, + "description": "This parameter describes how often KQIs and KPIs prediction values are provided", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "per second" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "per minute" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "per hour" + } + } + ] + }, + { + "name": "Positioning support", + "configurable": false, + "description": "This attribute describes if the network slice provides geo-localization methods or supporting methods.", + "regex": null, + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { + "role": "Availability", + "name": "Positioning support: Availability", + "relationshipType": "dependency" + }, + { + "role": "Prediction frequency", + "name": "Positioning support: Prediction frequency", + "relationshipType": "dependency" + }, + { + "role": "Prediction frequency", + "name": "Positioning support: Accuracy", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Positioning support: Availability", + "configurable": false, + "description": "This parameter describes if this attribute is provided by the network slice and contains a list of positioning methods provided by the slice. If the list is empty this attribute is not available in the network slice and the other parameters might be ignored", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "CID" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "E-CID (LTE and NR)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "OTDOA (LTE and NR)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "RF fingerprinting" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "5", + "alias": "AECID" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "6", + "alias": "Hybrid positioning" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "7", + "alias": "NET-RTK" + } + } + ] + }, + { + "name": "Positioning support: Prediction frequency", + "configurable": false, + "description": "This parameter describes how often location information is provided. This parameter simply defines how often the customer is allowed to request location information. This is not related to the time it takes to determine the location, which is a characteristic of the positioning method.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "per second" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "per minute)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "per hour" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "conditional, e.g. in case a specific area is entered or left" + } + } + ] + }, + { + "name": "Positioning support: Accuracy", + "configurable": false, + "description": "This parameter describes the accuracy of the location information. Accuracy depends on the respective positioning solution applied in the network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "meter", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "0.01", + "alias": "+/- 0.01m" + } + } + ] + }, + { + "name": "Radio spectrum", + "configurable": false, + "description": "Defines the radio spectrum supported by the network slice. This is important information, as some terminals might be restricted in terms of frequencies to be used.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "ARRAY", + + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "n1", + "alias": "UL: 1920 MHz – 1980 MHz DL: 2110 MHz – 2170 MHz FDD" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "n77", + "alias": "UL: 3300 MHz – 4200 MHz DL: 3300 MHz – 4200 MHz TDD" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "n78", + "alias": "UL: 3300 MHz – 3800 MHz DL: 3300 MHz – 3800 MHz TDD" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "n79", + "alias": "UL: 4400 MHz – 5000 MHz DL: 4400 MHz – 5000 MHz TDD" + } + } + ] + }, + { + "name": "Root cause investigation", + "configurable": false, + "description": "Root cause investigation is the capability provided to NSC to understand or investigate the root cause of network service performance degradation or failure", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "not available" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "passive investigation" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "active investigation" + } + } + ] + }, + { + "name": "Session and Service Continuity support", + "configurable": false, + "description": "The attribute defines the continuity of a Protocol Data Unit (PDU) session. The following three Session and Service Continuity (SSC) modes are specified: SSC mode 1 - the network preserves the connectivity service provided to the UE (the IP address is preserved), SSC mode 2 - the network may release the connectivity service delivered to the UE and release the corresponding PDU Session (the network may release IP address(es) that had been allocated to the UE), SSC mode 3 - changes to the user plane can be visible to the UE, while the network ensures that the UE suffers no loss of connectivity service (the IP address is not preserved in this mode when the PDU Session Anchor changes), None – UE loses the connectivity service", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "none" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "SSC mode 1" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "SSC mode 2" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "SSC mode 3" + } + } + ] + }, + { + "name": "Simultaneous use of the network slice", + "configurable": false, + "description": "This attribute describes whether a network slice can be simultaneously used by a UE together with other network slices and if so, with which other classes of network slices. The attribute is comprised of a list of Service Category Parameters with the associated Simultaneous Use Class parameter value.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "Can be used with any slice" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Can be used with slices with same SST value" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Can be used with any slice with same SD value" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Cannot be used with another slice" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "operator defined class" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "5", + "alias": "operator defined class" + } + } + ] + }, + { + "name": "Simultaneous use of the network slice: Service category", + "configurable": false, + "description": "This parameter defines a service category which may be assigned to a UE. If present, it shall be associated with a Simultaneous Use Class parameter value", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: Attribute must be present if service is supported requiring Simultaneous Use Class", + "valueType": "TEXT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "Service Category" + } + } + ] + }, + { + "name": "Slice quality of service", + "configurable": false, + "description": "some of these parameters 3GPP has already defined standard values [1]. By preselecting a 5G QoS Identifier (5QI) these parameters will automatically be filled out with the standardised values", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { + "role": "3GPP 5QI", + "name": "Slice quality of service parameters: 3GPP 5QI", + "relationshipType": "dependency" + }, + { + "role": "Resource Type", + "name": "Slice quality of service parameters: Resource Type", + "relationshipType": "dependency" + }, + { + "role": "Priority Level", + "name": "Slice quality of service parameters: Priority Level", + "relationshipType": "dependency" + }, + { + "role": "Packet Delay Budget", + "name": "Slice quality of service parameters: Packet Delay Budget", + "relationshipType": "dependency" + }, + { + "role": "Packet Error Rate", + "name": "Slice quality of service parameters: Packet Error Rate", + "relationshipType": "dependency" + }, + { + "role": "Averaging Window", + "name": "Slice quality of service parameters: Averaging Window", + "relationshipType": "dependency" + }, + { + "role": "Maximum Data Burst Volume", + "name": "Slice quality of service parameters: Maximum Data Burst Volume", + "relationshipType": "dependency" + }, + { + "role": "Maximum Packet Loss Rate", + "name": "Slice quality of service parameters: Maximum Packet Loss Rate", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Slice quality of service parameters: 3GPP 5QI", + "configurable": false, + "description": "A 5QI is a scalar used as a reference to 5G QoS characteristics defined in clause [1], i.e. access node-specific parameters that control QoS forwarding treatment for the QoS Flow (e.g. scheduling weights, admission thresholds, queue management thresholds, link layer protocol configuration, etc.). 3GPP has already defined standardized 5QI to QoS characteristics mapping. See 5QI value in the table of GNST", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "1", + "alias": "Conversational Voice" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "2", + "alias": "Conversational Video (Live Streaming)" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "3", + "alias": "Real Time Gaming, V2X messages Electricity distribution – medium voltage, Process automation - monitoring" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "4", + "alias": "Non- Conversational Video (Buffered Streaming)" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "5", + "alias": "IMS Signalling" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "6", + "alias": "Video (Buffered Streaming) TCP-based (e.g., www, email, chat, ftp, p2p file sharing, progressive video, etc.)" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "7", + "alias": "Voice, Video (Live Streaming) Interactive Gaming" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "8", + "alias": "Video (Buffered Streaming) TCP-based (e.g., www, email, chat, ftp, p2p file sharing, progressive video, etc.)" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "9", + "alias": "Video (Buffered Streaming) TCP-based (e.g., www, email, chat, ftp, p2p file sharing, progressive video, etc.)" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "65", + "alias": "Mission Critical user plane Push To Talk voice (e.g., MCPTT)" + } + } + ] + }, + { + "name": "Slice quality of service parameters: Resource Type", + "configurable": false, + "description": "The Resource Type determines if dedicated network resources related QoS Flow-level Guaranteed Flow Bit Rate (GFBR) value are permanently allocated [1]. This value needs to be provided for each customised 5QI value selected.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional:", + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "0", + "alias": "GBR (Mission Critical Video user plane)" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "1", + "alias": "Delay critical GBR (Intelligent Transport Systems)" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "2", + "alias": "Non-GBR (Voice, AR)" + } + } + ] + }, + { + "name": "Slice quality of service parameters: Priority Level", + "configurable": false, + "description": "The Priority level associated with 5G QoS characteristics indicates a priority in scheduling resources among QoS Flows. The Priority level shall be used to differentiate between QoS Flows of the same UE, and it shall also be used to differentiate between QoS Flows from different UEs. Once all QoS requirements up to GFBR are fulfilled for all the Guaranteed Bit Rate (GBR) QoS Flows, the Priority Level may also be used to distribute resources between GBR QoS Flows (for rates above GFBR up to MFBR, Maximum Flow Bit Rate) and non- GBR QoS Flows, in an implementation specific manner. The lowest Priority level value corresponds to the highest Priority [1]. This value needs to be provided for each customised 5QI value selected..", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional:", + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "Seconds", + "valueType": "FLOAT", + "value": { + "value": "10", + "alias": "IMS signalling" + } + } + ] + }, + { + "name": "Slice quality of service parameters: Packet Delay Budget", + "configurable": false, + "description": "The Packet Delay Budget (PDB) defines an upper bound for the time that a packet may be delayed between the UE and the UPF, that terminates the N6 interface. For a certain 5QI the value of the PDB is the same in UL (Uplink) and DL (Downlink). In the case of 3GPP access, the PDB is used to support the configuration of scheduling and link layer functions (e.g. the setting of scheduling priority weights and HARQ (Hybrid Automatic Repeat request) target operating points).", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional:", + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "Seconds", + "valueType": "FLOAT", + "value": { + "value": "20000", + "alias": "Cooperative driving" + } + } + ] + }, + { + "name": "Slice quality of service parameters: Packet Error Rate", + "configurable": false, + "description": "The Packet Error Rate (PER) defines an upper bound for the rate of PDUs (e.g. IP packets) that have been processed by the sender but that are not successfully delivered by the corresponding receiver. The purpose of the PER is to allow for the appropriate link layer, protocol configurations (e.g. RLC and HARQ in RAN of a 3GPP access). For all 5QIs the value of the PER is the same in UL and DL. For GBR QoS Flows with Delay critical GBR resource type, a packet which is delayed more than PDB (but which complies with the GFBR and MDBV (Maximum Data Burst Volume) requirements) is counted as lost, and included in the PER. This value needs to be provided for each customised 5QI value selected.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional:", + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "N/A", + "valueType": "FLOAT", + "value": { + "value": "0.000001", + "alias": "mission critical data" + } + } + ] + }, + { + "name": "Slice quality of service parameters: Averaging Window", + "configurable": false, + "description": "Each GBR QoS Flow shall be associated with an Averaging window. The Averaging window represents the duration over which the GFBR and MFBR shall be calculated (e.g. in the (R)AN, UPF, UE). (see clause 5.7.3.6 of 3GPP TS 23.501 [1]).", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "millisecond", + "valueType": "FLOAT", + "value": { + "value": "01", + "alias": "" + } + } + ] + }, + { + "name": "Slice quality of service parameters: Maximum Data Burst Volume", + "configurable": false, + "description": "Each GBR QoS Flow with Delay-critical resource type shall be associated with a Maximum Data Burst Volume (MDBV). MDBV denotes the largest amount of data that the 5G-AN is required to serve within a period of 5G-AN PDB (i.e. 5G-AN part of the PDB) (see clause 5.7.3.7 of 3GPP TS 23.501 [1]).", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "Bytes", + "valueType": "INTEGER", + "value": { + "value": "0", + "alias": "" + } + } + ] + }, + { + "name": "Slice quality of service parameters: Maximum Packet Loss Rate", + "configurable": false, + "description": "The Maximum Packet Loss Rate (UL, DL) indicates the maximum rate for lost packets of the QoS flow that can be tolerated in the uplink (UL) and downlink (DL) direction.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "Percentage", + "valueType": "INTEGER", + "value": { + "value": "0", + "alias": "" + } + } + ] + }, + { + "name": "Support for non-IP traffic", + "configurable": false, + "description": "This attribute provides non-IP Session support (Ethernet session and forwarding support) of communication devices", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "0", + "alias": "not supported" + } + },{ + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "1", + "alias": "supported" + } + } + ] + }, + + { + "name": "Supported device velocity", + "configurable": false, + "description": "Maximum speed supported by the network slice at which a defined QoS and seamless transfer between TRxPs (Transmission Reception Point(s)), which may belong to different deployment layers and/or radio access technologies (multi-layer /-RAT), can be achieved.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Performance", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "Kilometres per hour (km/h)", + "valueType": "INTEGER", + "value": { + "value": "1", + "alias": "Stationary: 0 km/h" + } + }, + { + "unitOfMeasure": "Kilometres per hour (km/h)", + "valueType": "INTEGER", + "value": { + "value": "2", + "alias": "Pedestrian: 0 km/h to 10 km/h" + } + }, + { + "unitOfMeasure": "Kilometres per hour (km/h)", + "valueType": "INTEGER", + "value": { + "value": "3", + "alias": "Vehicular: 10 km/h to 120 km/h" + } + }, + { + "unitOfMeasure": "Kilometres per hour (km/h)", + "valueType": "INTEGER", + "value": { + "value": "4", + "alias": "High speed vehicular: 120 km/h to 500 km/h" + } + } + ] + }, + { + "name": "Synchronicity", + "configurable": false, + "description": "This attribute provides synchronicity of communication devices. Two cases are most important in this context: Synchronicity between a base station and a mobile device and Synchronicity between mobile devices.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { + "role": "Availability", + "name": "Synchronicity: Availability", + "relationshipType": "dependency" + }, + { + "role": "Accuracy", + "name": "Synchronicity: Accuracy", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Synchronicity: Availability", + "configurable": false, + "description": "The synchronicity between devices over PC5 in absence of the network is not in scope of this attribute.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "0", + "alias": "not available" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "1", + "alias": "between BS and UE" + } + }, + { + "unitOfMeasure": "N/A", + "valueType": "INTEGER", + "value": { + "value": "2", + "alias": "between BS and UE & UE and UE" + } + } + ] + }, + { + "name": "Synchronicity: Accuracy", + "configurable": false, + "description": "This parameter describes the accuracy of the synchronicity..", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "seconds", + "valueType": "FLOAT", + "value": { + "value": "0,0000001", + "alias": "" + } + } + ] + }, + { + "name": "UE density", + "configurable": false, + "description": "This attribute describes the maximum number of connected and/or accessible devices per unit area (per km2) supported by the network slice.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "Number per km2", + "valueType": "INTEGER", + "value": { + "value": "10000", + "alias": "devices per km2" + } + } + ] + }, + { + "name": "Uplink throughput per network slice", + "configurable": false, + "description": "The achievable data rate of the network slice instance in uplink that is available ubiquitously across the coverage area of the network slice.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" }, + { + "role": "Guaranteed uplink throughput", + "name": "Uplink throughput per network slice: Guaranteed uplink throughput", + "relationshipType": "dependency" + }, + { + "role": "Maximum uplink throughput", + "name": "Uplink throughput per network slice: Maximum uplink throughput", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Uplink throughput per network slice: Additional uplink GBR QoS flows", + "configurable": false, + "description": "This attribute describes the guaranteed data rate supported by the network slice in uplink. There are services (e.g. emergency services) where guaranteed uplink throughput is required.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "kbps", + "valueType": "INTEGER", + "value": { + "value": "0", + "alias": "not specified" + } + } + ] + }, + { + "name": "Uplink throughput per network slice: Maximum uplink throughput", + "configurable": false, + "description": "This attribute describes the guaranteed data rate supported by the network slice in uplink. There are services (e.g. emergency services) where guaranteed uplink throughput is required.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: Either Maximum uplink throughput per network slice or Maximum uplink throughput per slice shall be present. ", + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "unitOfMeasure": "kbps", + "valueType": "INTEGER", + "value": { + "value": "10000", + "alias": "10 Mbps" + } + } + ] + }, + { + "name": "Uplink maximum throughput per UE", + "configurable": false, + "description": "", + "serviceSpecCharRelationship": [ + { + "role": "Guaranteed uplink throughput", + "name": "Uplink maximum throughput per UE: Maximum Uplink Throughput per UE value", + "relationshipType": "dependency" + }, + { + "role": "Maximum uplink throughput", + "name": "Uplink maximum throughput per UE: Service category", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Uplink maximum throughput per UE: Maximum Uplink Throughput per UE value", + "configurable": false, + "description": "This parameter defines the Maximum Uplink Throughput per UE value. This may be associated with a Service Category parameter.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional:", + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "kbps", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "not specified" + } + } + ] + }, + { + "name": "Uplink maximum throughput per UE: Service category", + "configurable": false, + "description": "This parameter defines a service category which may be assigned to certain groups of devices using the network slice. If present, it shall be associated with a Maximum Uplink Throughput Value parameter.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional: Either Maximum uplink throughput per network slice or Maximum uplink throughput per UE must be present", + "valueType": "TEXT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "Service Category" + } + } + ] + }, + { + "name": "User management openness", + "configurable": false, + "description": "This attribute describes the capability for the NSC to manage their users or groups of users’ network services and corresponding requirements. For instance, if NSC Y orders a network slice which is capable to support X users of Y, then Y should be capable to decide which X users could use this network slice. Hence, Y could manage the users, in terms of add, modify or delete users to receive network services provided by the specific network slice.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "Operational", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "not supported" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "supported" + } + } + ] + }, + { + "name": "Data network access", + "description": "For each Supported data network list value in the Supported data networks attribute (see clause 3.4.39). This attribute defines how the network slice supported data networks handle the user data.", + "serviceSpecCharRelationship": [ + { + "role": "Data access", + "name": "Data network access: Data access per data network", + "relationshipType": "dependency" + }, + { + "role": "Tunnelling mechanism", + "name": "Data network access: Tunnelling mechanism", + "relationshipType": "dependency" + } + ] + }, + { + "name": "Data network access: Data access per data network", + "configurable": false, + "description": "TThe options for a specific Supported data network are as follows: Direct access to the Internet, Termination in a private network (e.g. via tunnelling mechanism such as L2TP, VPN Virtual Private Network, tunnel, etc.), All data traffic stays local to an operator network and the devices do not have access to the Internet or private network", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "Direct internet access" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Termination in the private network" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Local traffic (no internet access)" + } + } + ] + }, + { + "name": "Data network access: Tunnelling mechanism", + "configurable": false, + "description": "The attribute defines the tunnelling mechanism; how the user data can be delivered to the external private data network. 3GPP TS 29.561 [12] lists the interworking with data networks and tunnelling mechanism used", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Conditional:This parameter is present if User data Access is 1(Termination in the private network).", + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "L2TP Tunnel" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "GRE Tunnel" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "VPN Tunnel" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Label based routing" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "Other" + } + } + ] + }, + { + "name": "V2X communication mode", + "configurable": false, + "description": "This parameter describes if the V2X communication mode is supported by the network slice.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "NO" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "YES-EUTRA" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "YES- NR" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "YES -NR and E-UTRA" + } + } + ] + }, + { + "name": "Latency from (last) UPF to Application Server", + "configurable": false, + "description": "This optional attribute specifies maximum or worst case one-way latency between UPF and application server offered by the slice. This does not include latency introduced by the application server. In the case of chained UPFs, this refers to the last UPF (in the chain) towards the application server. This attribute extends what is covered by the 3GPP QoS PDB attribute (see GST QoS attribute) which is only between UE and UPF. This is an optional attribute for network slices that offer latency objectives between UPF and application server residing within the operator network", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Performance", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "second", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "" + } + } + ] + }, + { + "name": "Network Slice Specific Authentication and Authorization (NSSAA) Required", + "configurable": false, + "description": "This attribute specifies whether for the Network Slice, devices need to be also authenticated and authorized by a AAA server using additional credentials different than the ones used for the primary authentication (see Rel-16 of 3GPP TS 23.501 [1] clause 5.15.10 for a definition of the Network Slice Specific Authentication and Authorization feature).", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "Not supported" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Supported" + } + } + ] + }, + { + "name": "Multimedia Priority Service", + "configurable": false, + "description": "Multimedia Priority Service (MPS) leads to priority of traffic relative to other traffic.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "Non-MPS" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "MPS" + } + } + ] + }, + { + "name": "Multimedia Priority Service: Multimedia Priority Service capability support", + "configurable": false, + "description": "This parameter specifies what capabilities are available to support MPS. More than one capability may be supported at once. This parameter must be present if Multimedia Priority Service support is set to MPS.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "User prioritization" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Pre-emption" + } + } + ] + }, + { + "name": "Multimedia Priority Service: Multimedia Priority Service support", + "configurable": false, + "description": "This parameter specifies whether or not the network slice supports MPS for MMTel voice, MPS for MMTel video, and/or MPS for Data as specified in 3GPP TS 22.153 [31].", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "ARRAY", + + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" }, + { "name": "KPI", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "ARRAY", + "validFor": null, + "value": { + "value": "0", + "alias": "MPS for MMTel voice" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "ARRAY", + "validFor": null, + "value": { + "value": "1", + "alias": "MPS for MMTel video" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "ARRAY", + "validFor": null, + "value": { + "value": "2", + "alias": "MPS for Data" + } + } + ] + }, + { + "name": "Supported data network", + "configurable": false, + "description": "This attribute describes the data networks the network slice provides access to. The attribute is comprised of a list of Service category parameters with the associated network or networks list. If no Service category parameters are present, all UEs in the network slice are associated with the same network or list of networks.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "DataNetwork1, DataNetwork2", + "alias": "Service category 1" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "DataNetwork1", + "alias": "Service category 2" + } + } + + ] + }, + { + "name": "Supported data network: Service category", + "configurable": false, + "description": "This parameter defines a service category which may be assigned to a UE. If present, it shall be associated with a Supported data networks list parameter.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "", + "valueType": "TEXT", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "tag" }, + { "name": "Functional", "role": "tag", "relationshipType": "tag" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "Service Category" + } + } + ] + } + ], + "serviceSpecRelationship": [ + ], + "targetServiceSchema": null +} diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..10bfe7c85e6f2abbfd785c345f37df1e65c903b3 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + app.log + + + logs/archived/app.%d{yyyy-MM-dd}.%i.log + + 10MB + + 20GB + + 60 + + + + %d %p %c{1.} [%t] %m%n + + + + + + + + + + + diff --git a/src/main/resources/resourceSpecifications/gnodeb.openslice.io.json b/src/main/resources/resourceSpecifications/gnodeb.openslice.io.json new file mode 100644 index 0000000000000000000000000000000000000000..b503a2ef98c788d73a223975869fc34e6fbfd049 --- /dev/null +++ b/src/main/resources/resourceSpecifications/gnodeb.openslice.io.json @@ -0,0 +1,253 @@ +{ + "name": "gnodeb.openslice.io", + "category": "gNB", + "description": "The resource specification which describes a gNodeB", + "version": "0.2.0", + "isBundle": false, + "@type": "PhysicalResourceSpecification", + "attachment": [], + "relatedParty": [], + "resourceSpecCharacteristic": [ + { + "name": "Name", + "configurable": true, + "description": "This attribute specifies the alias of the gNodeB", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "resourceSpecCharRelationship": null, + "resourceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": null + } + ] + }, + { + "name": "Server", + "configurable": false, + "description": "This attribute specifies the server where the gNodeB is accessible from.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "resourceSpecCharRelationship": null, + "resourceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "localhost", + "alias": "Local network" + } + } + ] + }, + { + "name": "IP", + "configurable": false, + "description": "This attribute specifies the IP of the gNodeB.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "resourceSpecCharRelationship": null, + "resourceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "localhost", + "alias": "Local network" + } + } + ] + }, + { + "name": "GtpInterface", + "configurable": false, + "description": "This attribute specifies the IP of the gtp interface of the gNodeB.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "resourceSpecCharRelationship": null, + "resourceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "localhost", + "alias": "Local network" + } + } + ] + }, + { + "name": "Vendor", + "configurable": true, + "description": "This attribute specifies the vendor of the gNodeB", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "resourceSpecCharRelationship": null, + "resourceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": null + } + ] + }, + { + "name": "VendorModuleType", + "configurable": true, + "description": "This attribute specifies the vendor module type of the gNodeB", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "resourceSpecCharRelationship": null, + "resourceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": null + } + ] + }, + { + "name": "SoftwareVersion", + "configurable": true, + "description": "This attribute specifies the software version of the gNodeB", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "resourceSpecCharRelationship": null, + "resourceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": null + } + ] + }, + { + "name": "Location", + "configurable": true, + "description": "This attribute specifies the location of the gNodeB via its longtitude and latitude", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT", + "resourceSpecCharRelationship": null, + "resourceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "TEXT", + "validFor": null, + "value": { + "value": "[ -90.0715, 29.9510 ]", + "alias": "Local (outdoor)" + } + } + ] + }, + { + "name": "Coverage", + "configurable": true, + "description": "This attribute specifies the coverage area of the gNodeB", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + "resourceSpecCharacteristicValue": [ + { + "isDefault": true, + "valueType": "SMALLINT", + "value": { + "value": "1", + "alias": "Picocell (outdoor)" + } + }, + { + "isDefault": false, + "valueType": "SMALLINT", + "value": { + "value": "2", + "alias": "Nanocell (indoor)" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/resourceSpecifications/osm-tenant.openslice.io.json b/src/main/resources/resourceSpecifications/osm-tenant.openslice.io.json new file mode 100644 index 0000000000000000000000000000000000000000..a4f069b6c5657383953152afdd3b27944de66eb0 --- /dev/null +++ b/src/main/resources/resourceSpecifications/osm-tenant.openslice.io.json @@ -0,0 +1,212 @@ +{ + "name": "osm-tenant.openslice.io", + "category": "OSMTenant", + "description": "This Resource Specification is used to add a new MANO Provider", + "version": "0.2.0", + "isBundle": false, + "@type": "LogicalResourceSpecification", + "attachment": [], + "relatedParty": [], + "resourceSpecCharacteristic": [ + { + "name": "Name", + "configurable": true, + "description": "The alias of the MANO Provider as it will be seen in the platform", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "Description", + "configurable": true, + "description": "The description of the MANO Provider as it will be seen in the platform", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "SupportedManoPlatform", + "configurable": true, + "description": "", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + "resourceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BOOLEAN", + "validFor": null, + "value": { + "value": "OSMvSEVEN", + "alias": "OSMvSEVEN" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BOOLEAN", + "validFor": null, + "value": { + "value": "OSMvEIGHT", + "alias": "OSMvEIGHT" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BOOLEAN", + "validFor": null, + "value": { + "value": "OSMvNINE", + "alias": "OSMvNINE" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BOOLEAN", + "validFor": null, + "value": { + "value": "OSMvTEN", + "alias": "OSMvTEN" + } + } + ] + }, + { + "name": "ApiUrlEndpoint", + "configurable": true, + "description": "The API URL Endpoint of the MANO Provider", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "BasicAuthHeader", + "configurable": true, + "description": "The authorization basic header", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "Username", + "configurable": true, + "description": "The username used to access the MANO Provider", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "Password", + "configurable": true, + "description": "The password used to access the MANO Provider", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "Project", + "configurable": true, + "description": "The project for which the MANO Provider is intended to be used", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "EnabledForOnBoarding", + "configurable": true, + "description": "", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "BOOLEAN", + "resourceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BOOLEAN", + "validFor": null, + "value": { + "value": false, + "alias": "false" + } + } + ] + }, + { + "name": "EnabledForSync", + "configurable": true, + "description": "", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "BOOLEAN", + "resourceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BOOLEAN", + "validFor": null, + "value": { + "value": false, + "alias": "false" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/resourceSpecifications/vim-account.openslice.io.json b/src/main/resources/resourceSpecifications/vim-account.openslice.io.json new file mode 100644 index 0000000000000000000000000000000000000000..48910d0e7209b5d9bcef0b1a483673abf7d38de1 --- /dev/null +++ b/src/main/resources/resourceSpecifications/vim-account.openslice.io.json @@ -0,0 +1,276 @@ +{ + "name": "vim-account.openslice.io.json", + "category": "VIMAccount", + "description": "This Resource Specification is used to describe an OSM Project's VIM account", + "version": "0.2.0", + "isBundle": true, + "@type": "LogicalResourceSpecification", + + "relatedParty": [], + "resourceSpecCharacteristic": [ + { + "name": "Name", + "configurable": true, + "description": "The alias of the OSM Project's VIM account", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "Description", + "configurable": true, + "description": "The description of the OSM Project's VIM account", + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "vimProjectOrTenantName", + "configurable": true, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "vimURL", + "configurable": true, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "vimUsername", + "configurable": true, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "vimPassword", + "configurable": true, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "Type", + "configurable": true, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + "resourceSpecCharacteristicValue": [ + { + "value": { + "value": "Openstack" + }, + "value": { + "value": "AWS" + }, + "value": { + "value": "VMware vCD" + }, + "value": { + "value": "OpenVIM" + }, + "value": { + "value": "OpenNebula" + }, + "value": { + "value": "Azure" + } + } + ] + }, + { + "name": "totalRAM", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "usedRAM", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "totalVCPUs", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "usedVCPUs", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "totalInstances", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "usedInstances", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "totalVolumes", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "usedVolumes", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "totalVolumeSnapshots", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "usedVolumeSnapshots", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "totalVolumeStorage", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "freeVolumeStorage", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "totalNetworks", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "usedNetworks", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "totalSubnets", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "usedSubnets", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + }, + { + "name": "schemaType", + "configurable": false, + "extensible": null, + "isUnique": false, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "TEXT" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/vinnisb/vinnisb-exposure-L1.json b/src/main/resources/vinnisb/vinnisb-exposure-L1.json new file mode 100644 index 0000000000000000000000000000000000000000..505ff575f73b2847cda78e730bcbdc3588dad7b8 --- /dev/null +++ b/src/main/resources/vinnisb/vinnisb-exposure-L1.json @@ -0,0 +1,54 @@ +{ + "name": "VINNI-SB Service Exposure Level 1", + "description": "VINNI-SB Service Exposure Level 1", + "version": "0.1.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + "name": "Exposure Level", + "configurable": false, + "description": "expose management capabilities of 5G-VINNI facility towards an authorised CSC.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { + "name": "Exposure Level", + "role": "tag", + "relationshipType": "tag" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Level 1" + } + } + ] + } + + ], + "serviceSpecRelationship": [ + ], + "targetServiceSchema": null +} diff --git a/src/main/resources/vinnisb/vinnisb-exposure-L2.json b/src/main/resources/vinnisb/vinnisb-exposure-L2.json new file mode 100644 index 0000000000000000000000000000000000000000..05441d72f2de772601a76280ebaec887ab262e01 --- /dev/null +++ b/src/main/resources/vinnisb/vinnisb-exposure-L2.json @@ -0,0 +1,54 @@ +{ + "name": "VINNI-SB Service Exposure Level 2", + "description": "VINNI-SB Service Exposure Level 2", + "version": "0.1.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + "name": "Exposure Level", + "configurable": false, + "description": "expose management capabilities of 5G-VINNI facility towards an authorised CSC.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { + "name": "Exposure Level", + "role": "tag", + "relationshipType": "tag" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Level 2" + } + } + ] + } + + ], + "serviceSpecRelationship": [ + ], + "targetServiceSchema": null +} diff --git a/src/main/resources/vinnisb/vinnisb-exposure-L3.json b/src/main/resources/vinnisb/vinnisb-exposure-L3.json new file mode 100644 index 0000000000000000000000000000000000000000..2026bdd2e5a17e890c778365b13889ba15d08387 --- /dev/null +++ b/src/main/resources/vinnisb/vinnisb-exposure-L3.json @@ -0,0 +1,54 @@ +{ + "name": "VINNI-SB Service Exposure Level 3", + "description": "VINNI-SB Service Exposure Level 3", + "version": "0.1.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + "name": "Exposure Level", + "configurable": false, + "description": "expose management capabilities of 5G-VINNI facility towards an authorised CSC.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { + "name": "Exposure Level", + "role": "tag", + "relationshipType": "tag" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Level 3" + } + } + ] + } + + ], + "serviceSpecRelationship": [ + ], + "targetServiceSchema": null +} diff --git a/src/main/resources/vinnisb/vinnisb-exposure-L4.json b/src/main/resources/vinnisb/vinnisb-exposure-L4.json new file mode 100644 index 0000000000000000000000000000000000000000..94b3ef1a0d33e0e51048f99f510557bd0a5dc2b7 --- /dev/null +++ b/src/main/resources/vinnisb/vinnisb-exposure-L4.json @@ -0,0 +1,54 @@ +{ + "name": "VINNI-SB Service Exposure Level 4", + "description": "VINNI-SB Service Exposure Level 4", + "version": "0.1.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + "name": "Exposure Level", + "configurable": false, + "description": "expose management capabilities of 5G-VINNI facility towards an authorised CSC.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { + "name": "Exposure Level", + "role": "tag", + "relationshipType": "tag" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "Level 4" + } + } + ] + } + + ], + "serviceSpecRelationship": [ + ], + "targetServiceSchema": null +} diff --git a/src/main/resources/vinnisb/vinnisb-monitoring.json b/src/main/resources/vinnisb/vinnisb-monitoring.json new file mode 100644 index 0000000000000000000000000000000000000000..2a1051c3770fb23c704ee4dce23298c22e314733 --- /dev/null +++ b/src/main/resources/vinnisb/vinnisb-monitoring.json @@ -0,0 +1,74 @@ +{ + "name": "VINNI-SB Service Monitoring", + "description": "VINNI-SB Service Monitoring", + "version": "0.1.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + + "name": "On-demand monitoring support", + "configurable": false, + "description": "indicates if the CSC is allowed or not to request new monitoring information at run-time.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "name": "Monitoring", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.MON_1", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "No" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Yes" + } + } + ] + } + + ], + "serviceSpecRelationship": [ + ], + "targetServiceSchema": null +} diff --git a/src/main/resources/vinnisb/vinnisb-req.json b/src/main/resources/vinnisb/vinnisb-req.json new file mode 100644 index 0000000000000000000000000000000000000000..a59551903287b024a72b29845109afa7925a1173 --- /dev/null +++ b/src/main/resources/vinnisb/vinnisb-req.json @@ -0,0 +1,2495 @@ +{ + "name": "VINNI-SB Service Requirements", + "description": "VINNI-SB Service Requirements", + "version": "0.1.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + "name": "Peak data rate", + "configurable": false, + "description": "It is defined as the highest theoretical data rate achievable for a single device located at the best location within a cell, assuming error-free transmission conditions (i.e. excluding overhead and retransmitted data packets) when all available radio resources for the corresponding link direction are utilized.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "DL peak data rate", + "name": "Peak data rate: DL peak data rate", + "relationshipType": "dependency" + }, + { + "role": "UL peak data rate", + "name": "Peak data rate: UL peak data rate", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "Peak data rate: UL peak data rate", + "configurable": false, + "description": "the maximum achievable upstream throughput one single device under ideal conditions.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_1A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Gbps", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "1", + "alias": "" + } + } + ] + }, + { + "name": "Peak data rate: DL peak data rate", + "configurable": false, + "description": "the maximum achievable downstream throughput at IP layer of one single device under ideal conditions.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_1B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Gbps", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "1.0", + "alias": "" + } + } + ] + }, + { + "name": "User data rate", + "configurable": false, + "description": "the user experienced data rate required for the device to get a quality experience that is assumed to be enough for the considered use case.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "DL user data rate", + "name": "User data rate: DL user data rate", + "relationshipType": "dependency" + }, + { + "role": "UL user data rate", + "name": "User data rate: UL user data rate", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "User data rate: DL user data rate", + "configurable": false, + "description": "describes the experienced downstream throughput at IP layer of one single device, generated at N6 interface and measured at the device side.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_2A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Mbps", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "100.0", + "alias": "" + } + } + ] + }, + { + "name": "User data rate: UL user data rate", + "configurable": false, + "description": "describes the experienced upstream throughput one single device transmitting the IP packets up to the N6 interface.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_2B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Mbps", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "100.0", + "alias": "" + } + } + ] + }, + { + "name": "Area traffic density", + "configurable": false, + "description": "the total traffic throughput (i.e. number of correctly received bits of IP packets per time interval) per area unit.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "DL area traffic density", + "name": "Area traffic density: DL area traffic density", + "relationshipType": "dependency" + }, + { + "role": "UL area traffic density", + "name": "Area traffic density: UL area traffic density", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "Area traffic density: DL area traffic density", + "configurable": false, + "description": "the total throughput per area unit in the downstream direction.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_3A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Gbps/km2", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "1.0", + "alias": "" + } + } + ] + }, + { + "name": "Area traffic density: UL area traffic density", + "configurable": false, + "description": "the total throughput per area unit in the upstream direction.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_3B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Gbps/km2", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "1.0", + "alias": "" + } + } + ] + }, + { + "name": "5G Quality of Service (QoS)", + "configurable": false, + "description": "It represents a set of typical QoS parameters that are relevant for traffic handling in 3GPP networks, from Rel-15 onwards.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "One-way latency", + "name": "5G Quality of Service (QoS): One-way latency", + "relationshipType": "dependency" + }, + { + "role": "E2E latency", + "name": "5G Quality of Service (QoS): E2E latency", + "relationshipType": "dependency" + }, + { + "role": "Jitter", + "name": "5G Quality of Service (QoS): Jitter", + "relationshipType": "dependency" + }, + { + "role": "DL Packet loss rate", + "name": "5G Quality of Service (QoS): DL Packet loss rate", + "relationshipType": "dependency" + }, + { + "role": "UL Packet loss rate", + "name": "5G Quality of Service (QoS): UL Packet loss rate", + "relationshipType": "dependency" + }, + { + "role": "DL Packet size", + "name": "5G Quality of Service (QoS): DL Packet size", + "relationshipType": "dependency" + }, + { + "role": "UL Packet size:", + "name": "5G Quality of Service (QoS): UL Packet size:", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "5G Quality of Service (QoS): One-way latency", + "configurable": false, + "description": "it is the time it takes for a IP packet to travel from a device to a destination node.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_4A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "ms", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "10", + "alias": "" + } + } + ] + }, + { + "name": "5G Quality of Service (QoS): E2E latency", + "configurable": false, + "description": "the time it takes for a IP packet to travel from a device to a destination node considering the Round Trip Time (RTT).", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_4B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "ms", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "10", + "alias": "" + } + } + ] + }, + { + "name": "5G Quality of Service (QoS): Jitter", + "configurable": false, + "description": "it is the highest deviation in the latency value that can be acceptable for the targeted use case.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_4C", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "ms", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "10", + "alias": "" + } + } + ] + }, + { + "name": "5G Quality of Service (QoS): DL Packet loss rate", + "configurable": false, + "description": "it is the percentage of lost packets to the total number of packets sent in the DL direction.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_4D", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "%", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "10", + "alias": "" + } + } + ] + }, + { + "name": "5G Quality of Service (QoS): UL Packet loss rate", + "configurable": false, + "description": "it is the percentage of lost packets to the total number of packets sent in the UL direction.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_4E", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "%", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "10", + "alias": "" + } + } + ] + }, + { + "name": "5G Quality of Service (QoS): DL Packet size", + "configurable": false, + "description": "specifies the maximum packet size to be supported by the considered use case in the DL direction.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_4F", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Bytes", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "8", + "alias": "" + } + } + ] + }, + { + "name": "5G Quality of Service (QoS): UL Packet size", + "configurable": false, + "description": "specifies the maximum packet size to be supported by the considered use case in the UL direction.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_4G", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Bytes", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "8", + "alias": "" + } + } + ] + }, + { + "name": "Availability", + "configurable": false, + "description": "It is an indicator that represents the risk of service outage in terms of the acceptable level of unplanned downtime.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_5", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "%", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "99.99", + "alias": "" + } + } + ] + }, + { + "name": "Reliability", + "configurable": false, + "description": "It is an indicator that represents the risk of service misbehaviour within the time constraints required for the targeted use case.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_6", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "%", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "99.99", + "alias": "" + } + } + ] + }, + { + "name": "Service deployment time", + "configurable": false, + "description": "It is the time it takes the CSP to set up the network slice service (instance), with the network level guarantees specified in P.PERF_1 and P.PERF_6. This parameter measures the time that passes from service ordering (i.e. a CSC issue a service order to the CSP) to service operational readiness (i.e. the network slice service is ready to be used by the CSC). During this time, NSI day-0 (i.e. instantiation)4 and day-1 (configuration) operations shall be performed, and testing framework shall be configured accordingly.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_7", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "min", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "10", + "alias": "" + } + } + ] + }, + { + "name": "Deployment option", + "configurable": false, + "description": "The specification of this parameter allows selecting how the 3GPP network architecture will be deployed as part of the network slice service.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_1", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "Legacy" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Rel-15 NSA (Option 3)" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Rel-15 SA (Option 2)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Other (to be defined)" + } + } + ] + }, + { + "name": "Access technology", + "configurable": false, + "description": "The specification of this parameter allows selecting the technologies to be supported by the network slice service for the access part.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_2", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "LTE" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "NR" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Other (specific for 5G-VINNI facility site)" + } + } + ] + }, + { + "name": "Predominant device type", + "configurable": false, + "description": "This parameter lists the type of devices that can be attached to the 5G-VINNI service the CSP will provide to a CSC.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_3", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "UE" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "CPE" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Sensor" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Vehicle" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "Factory actuator" + } + } + ] + }, + { + "name": "Radio spectrum", + "configurable": false, + "description": "This parameter provides a list of the spectrum bands that can be supported by the offered service.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "LTE operating bands", + "name": "Radio spectrum: LTE operating bands", + "relationshipType": "dependency" + }, + { + "role": "NR operating bands", + "name": "Radio spectrum: NR operating bands", + "relationshipType": "dependency" + }, + { + "role": "Other bands", + "name": "Radio spectrum: Other bands", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "Radio spectrum: LTE operating bands", + "configurable": false, + "description": "assuming option 0 has been selected for P.FUNC_2, this parameter list the LTE-defined spectrum bands [22] that can be supported by the network slice service.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.FUNC_2 -> if set to 1, P.FUNC_4A shall be omitted.", + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_4A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "STRING", + "validFor": null, + "value": { + "value": "n77", + "alias": "" + } + } + ] + }, + { + "name": "Radio spectrum: NR operating bands", + "configurable": false, + "description": "assuming option 1 has been selected for P.FUNC_2, this parameter list the NR-defined spectrum bands [23] that can be supported by the network slice service.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.FUNC_2 -> if set to , P.FUNC_4B shall be omitted.", + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_4B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "STRING", + "validFor": null, + "value": { + "value": "n77", + "alias": "" + } + } + ] + }, + { + "name": "Radio spectrum: Other bands", + "configurable": false, + "description": "allows listing bands that do not match LTE or NR, either because they are based on other access technologies (e.g. NB-IoT, LTE-M, satellite access and FWA) or because they are part of vertical-owned spectrum.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.FUNC_2 -> only if set to 2 ", + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_4C", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "STRING", + "validFor": null, + "value": { + "value": "n77", + "alias": "" + } + } + ] + }, + { + "name": "Isolation", + "configurable": false, + "description": "Isolation constitutes the cornerstone for service delivery in multi-tenant environments such as 5G-VINNI, where NSIs intended for multiple CSCs will be deployed and operated on top of a shared infrastructure.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "Isolation support", + "name": "Isolation: Isolation support", + "relationshipType": "dependency" + }, + { + "role": "Isolation support", + "name": "Isolation support: Isolation type", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "Isolation: Isolation support", + "configurable": false, + "description": "allows specifying if isolation is required/desired for the network slice service the CSP delivers to CSC.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_5A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "No" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Yes" + } + } + ] + }, + { + "name": "Isolation support: Isolation type", + "configurable": false, + "description": "allows specifying if isolation is required/desired for the network slice service the CSP delivers to CSC.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.FUNC_2 -> only if set to 2 ", + "valueType": "ARRAY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_5B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "No isolation" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Logical isolation" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "2", + "alias": "Physical isolation" + } + } + ] + }, + { + "name": "Value-added functionality", + "configurable": false, + "description": "This parameter includes the list of advanced features that the CSP can include as part of the network slice service offered to the CSC, providing it with an enriched functionality.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "3rd party VNF hosting", + "name": "Value-added functionality: 3rd party VNF hosting", + "relationshipType": "dependency" + }, + { + "role": "Positioning", + "name": "Value-added functionality: Positioning", + "relationshipType": "dependency" + }, + { + "role": "Distributed data fabric", + "name": "Value-added functionality: Distributed data fabric", + "relationshipType": "dependency" + }, + { + "role": "Security-as-a-Service (SECaaS)", + "name": "Value-added functionality: Security-as-a-Service (SECaaS)", + "relationshipType": "dependency" + }, + { + "role": "Monitoring-as-a-service (MaaS)", + "name": "Value-added functionality: Monitoring-as-a-service (MaaS)", + "relationshipType": "dependency" + }, + { + "role": "Testing-as-a-service (TaaS)", + "name": "Value-added functionality: Testing-as-a-service (TaaS)", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "Value-added functionality: 3rd party VNF hosting", + "configurable": false, + "description": "allows a CSC to bring his own VNFs and attach them to the default service topology , expanding/modifying it to get a value-added network slice service.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_6A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "No" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Yes" + } + } + ] + }, + { + "name": "Value-added functionality: Positioning", + "configurable": false, + "description": "it is the ability to provide geo-localisation methods as part of the network slice.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_6B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "No" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Yes" + } + } + ] + }, + { + "name": "Value-added functionality: Distributed data fabric", + "configurable": false, + "description": "it is the ability to provide data fabric functionality as part of the provided network slice.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_6C", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "No" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Yes" + } + } + ] + }, + { + "name": "Value-added functionality: Security-as-a-Service (SECaaS)", + "configurable": false, + "description": "it is the ability to provide automated infrastructure security to CSC, as part of the offered slice service.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_6D", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "No" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Yes" + } + } + ] + }, + { + "name": "Value-added functionality: Monitoring-as-a-service (MaaS)", + "configurable": false, + "description": "allows a CSC to consume 5G-VINNI telemetry services for performance/fault activities at run-time.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_6E", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "No" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Yes" + } + } + ] + }, + { + "name": "Value-added functionality: Testing-as-a-service (TaaS)", + "configurable": false, + "description": "allows a CSC to consume capabilities from the 5G-VINNI testing framework for trialling and KPI validation purposes.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_6F", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "No" + } + }, + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Yes" + } + } + ] + }, + { + "name": "Positioning", + "configurable": false, + "description": "This parameter includes the list of advanced features that the CSP can include as part of the network slice service offered to the CSC, providing it with an enriched functionality.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "Positioning accuracy", + "name": "Positioning: Positioning accuracy", + "relationshipType": "dependency" + }, + { + "role": "Measurement frequency", + "name": "Positioning: Measurement frequency", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "Positioning: Positioning accuracy", + "configurable": false, + "description": "specifies the accuracy required for positioning in meters. This parameter specifies an upper bound in the error between estimated position and actual position. High-precision positioning might be very important for some verticals, not only working in in-door environments, but also in outdoor.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.FUNC_6B -> if set to “0”, P.F_9A shall be omitted", + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_8A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "cm", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "100", + "alias": "" + } + } + ] + }, + { + "name": "Positioning: Measurement frequency", + "configurable": false, + "description": "specifies how often the location information is provided.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.FUNC_6B-> if set to “0”, P.F_9B shall be omitted.", + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Functionallity", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.FUNC_8B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "ms", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1000", + "alias": "" + } + } + ] + }, + { + "name": "Number of devices", + "configurable": false, + "description": "It is defined as the maximum number of devices that can be subscribed to the network slice service", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_1", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "ms", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "10", + "alias": "" + } + } + ] + }, + { + "name": "Device density", + "configurable": false, + "description": "It is defined as the number of devices per area unit that can maintain active connections with the network slice service. With active connection, we mean that devices are able to exchange data with the network.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "INTEGER", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_2", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "devices/km^2", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1000", + "alias": "" + } + } + ] + }, + { + "name": "Coverage profile", + "configurable": false, + "description": "specifies the geographical areas where the devices can access the network slice service.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "Facility sites", + "name": "Coverage profile: Facility sites", + "relationshipType": "dependency" + }, + { + "role": "Coverage area", + "name": "Coverage profile: Coverage area", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "Coverage profile: Facility sites", + "configurable": false, + "description": "define the list of sites capable of supporting the deployment of the network slice service.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_3A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "Oslo (Norway)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Martlesham (UK)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Madrid (Spain)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "Patras (Greece)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "Aveiro (Portugal)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "5", + "alias": "Berlin (Germany)" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "6", + "alias": "Munich (Germany)" + } + } + ] + }, + { + "name": "Coverage profile: Coverage area", + "configurable": false, + "description": "defines the spatial boundaries where network slice service will provide coverage with a quality that is enough for the targeted use case. This quality is expressed through edge cell coverage probability, a safety factor used to determine the guaranteed level of probability (e.g. 90%, 95%, 99%) of a successful radio communication of any device placed within the specified coverage area.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_3B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "GSP, km", + "valueFrom": null, + "valueTo": null, + "valueType": "STRING", + "validFor": null, + "value": { + "value": "{}", + "alias": "" + } + } + ] + }, + { + "name": "Mobility", + "configurable": false, + "description": "Mobility refers to the ability of providing seamless service experiences to devices while moving. It can be defined as the maximum device speed at which a certain QoS (specified in P.PERF_4) can be achieved.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_4", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "Stationary: 0 km/h" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Pedestrian: 0-10 km/h" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Vehicular: 10-120 km/h" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "High speed vehicular: 120-500 km/h" + } + } + ] + }, + { + "name": "Service lifetime", + "configurable": false, + "description": "It provides information on some aspects that deserve attention during the lifetime of a network slice service.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "role": "Service duration (start-end)", + "name": "Service lifetime: Service duration (start-end)", + "relationshipType": "dependency" + }, + { + "role": "Service deactivation-activation support", + "name": "Service lifetime: Service deactivation-activation support", + "relationshipType": "dependency" + }, + { + "role": "Periodicity type", + "name": "Service lifetime: Periodicity type", + "relationshipType": "dependency" + }, + { + "role": "Daily service deactivation-activation", + "name": "Service lifetime: Daily service deactivation-activation", + "relationshipType": "dependency" + }, + { + "role": "Monthly service deactivation-activation", + "name": "Service lifetime: Monthly service deactivation-activation", + "relationshipType": "dependency" + } + ], + "serviceSpecCharacteristicValue": [ + + ] + }, + { + "name": "Service lifetime: Service duration (start-end)", + "configurable": false, + "description": "allows CSC to specify when it wants the service running, and when it can be decommissioned. The duration for a network slice service can be highly variable, ranging from short-lived services (e.g. an uRLLC slice service provided to public safety for disaster management) to long-lasting services (e.g. an eMBB slice service provided to a MVNO.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "STRING", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_5A", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "[mm-dd-yyyy hh:mm, mm-dd-yyyy hh:mm]", + "valueFrom": null, + "valueTo": null, + "valueType": "STRING", + "validFor": null, + "value": { + "value": "", + "alias": "" + } + } + ] + }, + { + "name": "Service lifetime: Service deactivation-activation support", + "configurable": false, + "description": "indicates if service deactivation-activation operations (i.e. once deactivated, the service is activated again) is allowed throughout the service duration.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_5B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "Not supported" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Supported without periodicity" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Supported with periodicity" + } + } + ] + }, + { + "name": "Service lifetime: Periodicity type", + "configurable": false, + "description": "assuming “supported with periodicity” is selected for P.NO_5B, this parameter allows specifying if the periodicity for deactivation-activation is programmed on a daily basis (e.g. service operative during the day, and deactivated at night), weekly basis (e.g. service operative from Monday to Friday, and deactivated for the weekend) or monthly basis", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.NO_5C-> if not set to “1”, P.NO_5E shall be omitted", + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_5C", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "0", + "alias": "Daily basis" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "Weekly basis" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "Monthly basis" + } + } + ] + }, + { + "name": "Service lifetime: Daily service deactivation-activation", + "configurable": false, + "description": "allows programming the time interval the service shall remain deactivated (from hh:mm to hh:mm) every day.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.NO_5C-> if not set to “0”, P.NO_5D shall be omitted.", + "valueType": "STRING", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_5D", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "[hh:mm, hh:mm]", + "valueFrom": null, + "valueTo": null, + "valueType": "STRING", + "validFor": null, + "value": { + "value": "", + "alias": "" + } + } + ] + }, + { + "name": "Service lifetime: Weekly service deactivation-activation", + "configurable": false, + "description": "allows programming the time interval the service shall remain deactivated (from dd hh:mm to dd hh:mm) every week.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.NO_5C-> if not set to “1”, P.NO_5E shall be omitted.", + "valueType": "STRING", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_5E", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "[dd hh:mm, dd hh:mm]", + "valueFrom": null, + "valueTo": null, + "valueType": "STRING", + "validFor": null, + "value": { + "value": "", + "alias": "" + } + } + ] + }, + { + "name": "Service lifetime: Monthly service deactivation-activation", + "configurable": false, + "description": "allows programming the time interval the service shall remain deactivated (from mm-dd-yyyy hh:mm to mm-dd-yyyy hh:mm) every month.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": "Yes: P.NO_5C-> if not set to “2”, P.NO_5F shall be omitted.", + "valueType": "STRING", + "serviceSpecCharRelationship": [ + { + "name": "Network Optimisation", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.NO_5F", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "[mm-dd hh:mm, mm-dd hh:mm]", + "valueFrom": null, + "valueTo": null, + "valueType": "STRING", + "validFor": null, + "value": { + "value": "", + "alias": "" + } + } + ] + } + ], + "serviceSpecRelationship": [ + ], + "targetServiceSchema": null +} diff --git a/src/main/resources/vinnisb/vinnisb-testing.json b/src/main/resources/vinnisb/vinnisb-testing.json new file mode 100644 index 0000000000000000000000000000000000000000..d3f39eb3c6443648bd0c7b1fa690fa44c35709f1 --- /dev/null +++ b/src/main/resources/vinnisb/vinnisb-testing.json @@ -0,0 +1,112 @@ +{ + "name": "VINNI-SB Service Testing", + "description": "VINNI-SB Service Tetsting", + "version": "0.1.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + + "name": "On-demand TaaS support", + "configurable": false, + "description": "if yes, it means that the CSC can modify/update test campaigns at run-time.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "BINARY", + "serviceSpecCharRelationship": [ + { + "name": "Monitoring", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.TEST_1", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "0", + "alias": "Raw" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "BINARY", + "validFor": null, + "value": { + "value": "1", + "alias": "Aggregated" + } + } + ] + }, + { + "name": "DL peak data rate", + "configurable": false, + "description": "the maximum achievable downstream throughput at IP layer of one single device under ideal conditions.", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 0, + "regex": null, + "valueType": "FLOAT", + "serviceSpecCharRelationship": [ + { + "name": "Performance", + "role": "tag", + "relationshipType": "tag" + }, + { + "name": "P.PERF_1B", + "role": "identifier", + "relationshipType": "identifier" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "Gbps", + "valueFrom": null, + "valueTo": null, + "valueType": "FLOAT", + "validFor": null, + "value": { + "value": "1.0", + "alias": "" + } + } + ] + } + ], + "serviceSpecRelationship": [ + ], + "targetServiceSchema": null +} diff --git a/src/main/resources/vinnisb/vinnisb.json b/src/main/resources/vinnisb/vinnisb.json new file mode 100644 index 0000000000000000000000000000000000000000..6e977008f8d5c8021ac6849e6bbbbadd797ecef6 --- /dev/null +++ b/src/main/resources/vinnisb/vinnisb.json @@ -0,0 +1,95 @@ +{ + "name": "VINNI-SB Template", + "description": "VINNI-SB template", + "version": "0.1.0", + "isBundle": true, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + "name": "5G-VINNI Service Type", + "configurable": false, + "description": "The service type is a parameter that identifies the type of communication services the slice is designed to support", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "SET", + "serviceSpecCharRelationship": [ + { + "name": "Service Type", + "role": "tag", + "relationshipType": "tag" + } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "1", + "alias": "eMBB" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "2", + "alias": "uRLLC" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "3", + "alias": "mIoT" + } + }, + { + "isDefault": false, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "INTEGER", + "validFor": null, + "value": { + "value": "4", + "alias": "Customised" + } + } + ] + } + ], + "serviceSpecRelationship": [ + ], + "targetServiceSchema": null +} diff --git a/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..df10383d21e92755af3a08e5f41653dc8fdc7b2e --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/AlarmManagementIntegrationTest.java @@ -0,0 +1,276 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.services.api; + +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.IOException; +import java.io.UnsupportedEncodingException; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; + +import org.apache.camel.ProducerTemplate; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.am642.model.AffectedService; +import org.etsi.osl.tmf.am642.model.Alarm; +import org.etsi.osl.tmf.am642.model.AlarmCreate; +import org.etsi.osl.tmf.am642.model.AlarmStateType; +import org.etsi.osl.tmf.am642.model.AlarmType; +import org.etsi.osl.tmf.am642.model.AlarmUpdate; +import org.etsi.osl.tmf.am642.model.Comment; +import org.etsi.osl.tmf.am642.model.PerceivedSeverityType; +import org.etsi.osl.tmf.am642.model.ProbableCauseType; +import org.etsi.osl.tmf.am642.reposervices.AlarmRepoService; +import org.etsi.osl.tmf.JsonUtils; + +import org.junit.Before; +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.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; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class AlarmManagementIntegrationTest { + + private static final transient Log logger = LogFactory.getLog(AlarmManagementIntegrationTest.class.getName()); + + @Autowired + private MockMvc mvc; + + @Autowired + AlarmRepoService alarmRepoService; + + @Autowired + private WebApplicationContext context; + + + @Autowired + private ProducerTemplate template; + + @Value("${ALARMS_ADD_ALARM}") + private String ALARMS_ADD_ALARM =""; + + @Value("${ALARMS_UPDATE_ALARM}") + private String ALARMS_UPDATE_ALARM =""; + + @Value("${ALARMS_GET_ALARM}") + private String ALARMS_GET_ALARM =""; + + @Before + public void setup() { + mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build(); + } + + @WithMockUser(username = "osadmin", roles = { "ADMIN", "USER" }) + @Test + public void testAlarmCreateAndUpdate() throws UnsupportedEncodingException, IOException, Exception { + + AlarmCreate a = new AlarmCreate(); + a.setPerceivedSeverity(PerceivedSeverityType.warning.name()); + a.setState(AlarmStateType.raised.name()); + a.setAckState("unacknowledged"); + a.setAlarmRaisedTime(OffsetDateTime.now(ZoneOffset.UTC).toString()); + a.setSourceSystemId("NFVO"); + a.setAffectedService(new ArrayList<>()); + a.setAlarmDetails("details..."); + a.setAlarmType(AlarmType.qualityOfServiceAlarm.name()); + a.setIsRootCause(true); + a.setProbableCause(ProbableCauseType.resourceAtOrNearingCapacity.name()); + a.reportingSystemId("OSA"); + + Comment comment = new Comment(); + comment.setComment("test"); + a.addCommentItem(comment ); + + AffectedService as = new AffectedService(); + as.setId("aServiceID"); + as.setType("Service"); + a.getAffectedService().add(as); + String response = mvc + .perform(MockMvcRequestBuilders.post("/alarmManagement/v4/alarm") + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson(a))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("alarmDetails", is("details..."))).andExpect(status().isOk()).andReturn() + .getResponse().getContentAsString(); + + assertThat(alarmRepoService.findAll().size()).isEqualTo(1); + + Alarm alarm = JsonUtils.toJsonObj(response, Alarm.class); + assertThat(alarm.getAckState()).isEqualTo("unacknowledged"); + assertThat(alarm.getSourceSystemId()).isEqualTo("NFVO"); + assertThat(alarm.getPerceivedSeverity()).isEqualTo(PerceivedSeverityType.warning.name()); + assertThat(alarm.getAlarmType()).isEqualTo(AlarmType.qualityOfServiceAlarm.name()); + assertThat(alarm.getAlarmRaisedTime() ).isNotNull(); + assertThat(alarm.getComment().size() ).isEqualTo(1); + + AlarmUpdate aupd = new AlarmUpdate(); + aupd.setAckState("acknowledged"); + aupd.setAckSystemId("OSA"); + aupd.setPerceivedSeverity(PerceivedSeverityType.warning.name()); + aupd.setState(AlarmStateType.updated.name()); + comment = new Comment(); + comment.setComment("test"); + aupd.addCommentItem(comment ); + + response = mvc + .perform(MockMvcRequestBuilders.patch("/alarmManagement/v4/alarm/" + alarm.getId() ) + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(aupd))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("alarmDetails", is("details..."))).andExpect(status().isOk()).andReturn() + .getResponse().getContentAsString(); + + assertThat(alarmRepoService.findAll().size()).isEqualTo(1); + + alarm = JsonUtils.toJsonObj(response, Alarm.class); + assertThat(alarm.getAckState()).isEqualTo("acknowledged"); + assertThat(alarm.getState()).isEqualTo( AlarmStateType.updated.name() ); + assertThat(alarm.getSourceSystemId()).isEqualTo("NFVO"); + assertThat(alarm.getAckSystemId()).isEqualTo("OSA"); + assertThat(alarm.getPerceivedSeverity()).isEqualTo(PerceivedSeverityType.warning.name()); + assertThat(alarm.getAlarmType()).isEqualTo(AlarmType.qualityOfServiceAlarm.name()); + assertThat(alarm.getComment().size() ).isEqualTo(2); + + aupd = new AlarmUpdate(); + aupd.setState(AlarmStateType.cleared.name()); + aupd.setAckSystemId("OSA"); + aupd.setPerceivedSeverity(PerceivedSeverityType.cleared.name()); + response = mvc + .perform(MockMvcRequestBuilders.patch("/alarmManagement/v4/alarm/" + alarm.getId() ) + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(aupd))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("alarmDetails", is("details..."))).andExpect(status().isOk()).andReturn() + .getResponse().getContentAsString(); + + assertThat(alarmRepoService.findAll().size()).isEqualTo(1); + + alarm = JsonUtils.toJsonObj(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()); + + } + + + @WithMockUser(username = "osadmin", roles = { "ADMIN", "USER" }) + @Test + public void testAlarmCreateAndUpdateRoutes() throws IOException { + AlarmCreate a = new AlarmCreate(); + a.setPerceivedSeverity(PerceivedSeverityType.warning.name()); + a.setState(AlarmStateType.raised.name()); + a.setAckState("unacknowledged"); + a.setAlarmRaisedTime(OffsetDateTime.now(ZoneOffset.UTC).toString()); + a.setSourceSystemId("NFVO"); + a.setAffectedService(new ArrayList<>()); + a.setAlarmDetails("details..."); + a.setAlarmType(AlarmType.qualityOfServiceAlarm.name()); + a.setIsRootCause(true); + a.setProbableCause(ProbableCauseType.resourceAtOrNearingCapacity.name()); + a.reportingSystemId("OSA"); + + AffectedService as = new AffectedService(); + as.setId("aServiceID"); + as.setType("Service"); + a.getAffectedService().add(as); + + String body = JsonUtils.toJsonString(a); + Object response = template.requestBody( ALARMS_ADD_ALARM, body); + + assertThat( response).isInstanceOf( String.class); + Alarm alarm = JsonUtils.toJsonObj( (String)response, Alarm.class); + assertThat(alarm.getAckState()).isEqualTo("unacknowledged"); + assertThat(alarm.getSourceSystemId()).isEqualTo("NFVO"); + assertThat(alarm.getPerceivedSeverity()).isEqualTo(PerceivedSeverityType.warning.name()); + assertThat(alarm.getAlarmType()).isEqualTo(AlarmType.qualityOfServiceAlarm.name()); + + + AlarmUpdate aupd = new AlarmUpdate(); + aupd.setAckState("acknowledged"); + aupd.setAckSystemId("OSA"); + aupd.setPerceivedSeverity(PerceivedSeverityType.warning.name()); + aupd.setState(AlarmStateType.updated.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.getState()).isEqualTo( AlarmStateType.updated.name() ); + assertThat(alarm.getSourceSystemId()).isEqualTo("NFVO"); + assertThat(alarm.getAckSystemId()).isEqualTo("OSA"); + 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()); + + + + assertThat(alarmRepoService.findAll().size()).isEqualTo(1); + + } + + +} diff --git a/src/test/java/org/etsi/osl/services/api/CustomerIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/CustomerIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..48d79bb7d8ec00c3ceda4bd864f73c581bb4f390 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/CustomerIntegrationTest.java @@ -0,0 +1,204 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.services.api; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.is; +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.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.cm629.model.Customer; +import org.etsi.osl.tmf.cm629.model.CustomerCreate; +import org.etsi.osl.tmf.cm629.model.CustomerUpdate; +import org.etsi.osl.tmf.cm629.service.CustomerRepoService; +import org.etsi.osl.tmf.pm632.model.ContactMedium; +import org.etsi.osl.tmf.pm632.model.MediumCharacteristic; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.JsonUtils; + +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.transaction.annotation.Transactional; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class CustomerIntegrationTest { + + + private static final transient Log logger = LogFactory.getLog( CustomerIntegrationTest.class.getName()); + + + @Autowired + private MockMvc mvc; + + + @Autowired + CustomerRepoService customerRepoService; + + +// @Autowired +// private WebApplicationContext context; +// +// +// @Before +// public void setup() { +// mvc = MockMvcBuilders +// .webAppContextSetup(context).dispatchOptions(true) +// .apply( SecurityMockMvcConfigurers.springSecurity()) +// .build(); +// } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void addCustomer() throws Exception { + + CustomerCreate cc = new CustomerCreate(); + cc.setName("A Customer"); + RelatedParty engagedParty = new RelatedParty(); + engagedParty.name("An Organization"); + engagedParty.setUuid(UUID.randomUUID().toString()); + cc.setEngagedParty(engagedParty ); + + List contactMediums = new ArrayList<>(); + ContactMedium cm = new ContactMedium(); + contactMediums.add(cm); + cm.setMediumType("email"); + cm.setPreferred(true); + MediumCharacteristic medChar = new MediumCharacteristic(); + medChar.setEmailAddress( "test@openslice.io" ); + cm.setCharacteristic(medChar); + cc.setContactMedium(contactMediums ); + + + + String response = mvc.perform(MockMvcRequestBuilders.post("/customerManagement/v4/customer") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( cc ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("A Customer"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( customerRepoService.findAll().size() ).isEqualTo( 1 ); + + Customer respc = JsonUtils.toJsonObj( response, Customer.class); + assertThat( respc.getContactMedium().stream().findFirst().get().getMediumType() ).isEqualTo("email"); + assertThat( respc.getContactMedium().stream().findFirst().get().getCharacteristic().getEmailAddress() ).isEqualTo("test@openslice.io"); + + + CustomerUpdate cu = new CustomerUpdate(); + cu.setEngagedParty( respc.getEngagedParty() ); + cm = new ContactMedium(); + cm.setMediumType("phone"); + medChar = new MediumCharacteristic(); + medChar.setPhoneNumber("555000"); + cm.setCharacteristic(medChar); + contactMediums = new ArrayList<>(); + for (ContactMedium contactMedium : respc.getContactMedium()) { + contactMediums.add(contactMedium); + } + contactMediums.add(cm); + cu.setContactMedium(contactMediums); + + String responseUpd = mvc.perform(MockMvcRequestBuilders.patch("/customerManagement/v4/customer/" + respc.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( cu ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("A Customer"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( customerRepoService.findAll().size() ).isEqualTo( 1 ); + + respc = JsonUtils.toJsonObj( responseUpd, Customer.class); + + assertThat( respc.getContactMedium().size() ).isEqualTo(2); + + String responseGet = mvc.perform(MockMvcRequestBuilders.get("/customerManagement/v4/customer") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( cc ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andReturn().getResponse().getContentAsString(); + + + List respcs = JsonUtils.toJsonObj( responseGet, ArrayList.class); + + assertThat( respcs.size() ).isEqualTo( 1 ); + + + responseGet = mvc.perform(MockMvcRequestBuilders.get("/customerManagement/v4/customer/" + respc.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( cc ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("A Customer"))) + .andReturn().getResponse().getContentAsString(); + + + respc = JsonUtils.toJsonObj( responseGet, Customer.class); + + + + String responseDel = mvc.perform(MockMvcRequestBuilders + .delete("/customerManagement/v4/customer/" + respc.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( cu ) )) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( customerRepoService.findAll().size() ).isEqualTo( 0 ); + + } + +} diff --git a/src/test/java/org/etsi/osl/services/api/LCMRulesIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/LCMRulesIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..760adbe5106d64d181b31d17ba4f1d4ff445eed3 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/LCMRulesIntegrationTest.java @@ -0,0 +1,215 @@ +package org.etsi.osl.services.api; + +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.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; +import org.etsi.osl.tmf.lcm.model.ELCMRulePhase; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecification; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationCreate; +import org.etsi.osl.tmf.lcm.model.LCMRuleSpecificationUpdate; +import org.etsi.osl.tmf.lcm.reposervices.LCMRuleSpecificationRepoService; +import org.etsi.osl.tmf.JsonUtils; + +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; + +@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 LCMRulesIntegrationTest { + + private static final transient Log logger = LogFactory.getLog( LCMRulesIntegrationTest.class.getName()); + + + @Autowired + private MockMvc mvc; + + @Autowired + private WebApplicationContext context; + + + @Autowired + LCMRuleSpecificationRepoService lcmRuleSpecificationRepoService; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + + public void addLCMRule() throws Exception { + + + LCMRuleSpecificationCreate c = new LCMRuleSpecificationCreate(); + c.setName("NewT"); + c.setLcmrulephase( ELCMRulePhase.AFTER_ACTIVATION.getValue() ); + c.setCode("CODE"); + c.setContent("CONTENT"); + c.setServiceSpecs( new ArrayList<>()); + ServiceSpecificationRef specref = new ServiceSpecificationRef(); + specref.setId("0x0x1"); + specref.setName("SPECREF"); + c.getServiceSpecs().add(specref ); + + String response = mvc.perform(MockMvcRequestBuilders.post("/lcmrulesmanagement/v1/lcmRuleSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( c ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("NewT"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( lcmRuleSpecificationRepoService.findAll().size() ).isEqualTo( 1 ); + + LCMRuleSpecification resp = JsonUtils.toJsonObj(response, LCMRuleSpecification.class); + assertThat( resp.getContent() ).isEqualTo( "CONTENT" ); + assertThat( resp.getServiceSpecs().size() ).isEqualTo( 1 ); + assertThat( resp.getServiceSpecs().stream().findFirst().get().getName() ).isEqualTo( "SPECREF" ); + + + //we will add now a new rule to service + LCMRuleSpecificationCreate c2 = new LCMRuleSpecificationCreate(); + c2.setName("NewT2"); + c2.setLcmrulephase( ELCMRulePhase.PRE_PROVISION.getValue() ); + c2.setCode("CODE2"); + c2.setContent("CONTENT2"); + c2.setServiceSpecs( new ArrayList<>()); + c2.getServiceSpecs().add(specref ); + + String response2 = mvc.perform(MockMvcRequestBuilders.post("/lcmrulesmanagement/v1/lcmRuleSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( c2 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("NewT2"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( lcmRuleSpecificationRepoService.findAll().size() ).isEqualTo( 2 ); + LCMRuleSpecification resp2 = JsonUtils.toJsonObj(response2, LCMRuleSpecification.class); + assertThat( resp2.getContent() ).isEqualTo( "CONTENT2" ); + + assertThat( lcmRuleSpecificationRepoService.findAll().size() ).isEqualTo( 2 ); + for (LCMRuleSpecification iterable_element : lcmRuleSpecificationRepoService.findAll()) { + logger.info( iterable_element ); + + } + List rules = lcmRuleSpecificationRepoService.findByServiceSpecificationRefIdAndPhase("0x0x1", ELCMRulePhase.PRE_PROVISION.getValue()); + assertThat( rules.size() ).isEqualTo( 1 ); + rules = lcmRuleSpecificationRepoService.findByServiceSpecificationRefIdAndPhase("0x0x1", ELCMRulePhase.AFTER_ACTIVATION.getValue()); + assertThat( rules.size() ).isEqualTo( 1 ); + + //attach same rule on other spec + + LCMRuleSpecificationUpdate cu1 = new LCMRuleSpecificationUpdate(); + cu1.setServiceSpecs( new ArrayList<>()); + cu1.setLcmrulephase( resp.getLcmrulephase() ); + cu1.getServiceSpecs().addAll(resp.getServiceSpecs()); + ServiceSpecificationRef specref2 = new ServiceSpecificationRef(); + specref2.setId("0x0x2"); + specref2.setName("SPECREF2"); + cu1.getServiceSpecs().add(specref2 ); + + + String response3 = mvc.perform(MockMvcRequestBuilders.patch("/lcmrulesmanagement/v1/lcmRuleSpecification/"+resp.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( cu1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("NewT"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + resp = JsonUtils.toJsonObj(response3, LCMRuleSpecification.class); + assertThat( lcmRuleSpecificationRepoService.findAll().size() ).isEqualTo( 2 ); + + rules = lcmRuleSpecificationRepoService.findByServiceSpecificationRefIdAndPhase("0x0x1", ELCMRulePhase.AFTER_ACTIVATION.getValue()); + assertThat( rules.size() ).isEqualTo( 1 ); + rules = lcmRuleSpecificationRepoService.findByServiceSpecificationRefIdAndPhase("0x0x2", ELCMRulePhase.AFTER_ACTIVATION.getValue()); + assertThat( rules.size() ).isEqualTo( 1 ); + + for (LCMRuleSpecification iterable_element : lcmRuleSpecificationRepoService.findAll()) { + logger.info( iterable_element ); + + } + +// rules = lcmRuleSpecificationRepoService.findByServiceSpecificationRefId("0x0x1"); +// assertThat( rules.size() ).isEqualTo( 2 ); +// assertThat( resp.getServiceSpecificationRefs().size() ).isEqualTo( 2 ); +// rules = lcmRuleSpecificationRepoService.findByServiceSpecificationRefId("0x0x2"); +// assertThat( rules.size() ).isEqualTo( 1 ); + + + //delete rule from spec + + LCMRuleSpecificationUpdate cu2 = new LCMRuleSpecificationUpdate(); + cu2.setServiceSpecs( new ArrayList<>()); + cu2.getServiceSpecs().addAll( resp.getServiceSpecs()); + assertThat( cu2.getServiceSpecs().size() ).isEqualTo( 2 ); + cu2.getServiceSpecs().remove(0); + + String response4 = mvc.perform(MockMvcRequestBuilders.patch("/lcmrulesmanagement/v1/lcmRuleSpecification/"+resp.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( cu2 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("NewT"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + resp = JsonUtils.toJsonObj(response4, LCMRuleSpecification.class); + assertThat( resp.getServiceSpecs().size() ).isEqualTo( 1 ); + + assertThat( lcmRuleSpecificationRepoService.findAll().size() ).isEqualTo( 2 ); + +// rules = lcmRuleSpecificationRepoService.findByServiceSpecificationRefId("0x0x1"); +// assertThat( rules.size() ).isEqualTo( 1 ); +// rules = lcmRuleSpecificationRepoService.findByServiceSpecificationRefId("0x0x2"); +// assertThat( rules.size() ).isEqualTo( 1 ); + + } + +} diff --git a/src/test/java/org/etsi/osl/services/api/PartyManagementIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/PartyManagementIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a328d446a66d81fa3e942f21e42402674ca041db --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/PartyManagementIntegrationTest.java @@ -0,0 +1,268 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2020 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.services.api; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.is; +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.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.Any; + +import org.etsi.osl.tmf.pm632.model.Characteristic; +import org.etsi.osl.tmf.pm632.model.ContactMedium; +import org.etsi.osl.tmf.pm632.model.Individual; +import org.etsi.osl.tmf.pm632.model.IndividualCreate; +import org.etsi.osl.tmf.pm632.model.MediumCharacteristic; +import org.etsi.osl.tmf.pm632.model.Organization; +import org.etsi.osl.tmf.pm632.model.OrganizationCreate; +import org.etsi.osl.tmf.pm632.reposervices.IndividualRepoService; +import org.etsi.osl.tmf.pm632.reposervices.OrganizationRepoService; +import org.etsi.osl.tmf.JsonUtils; + +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.test.web.servlet.setup.SecurityMockMvcConfigurers; +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; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class PartyManagementIntegrationTest { + + + private static final transient Log logger = LogFactory.getLog( PartyManagementIntegrationTest.class.getName()); + + + @Autowired + private MockMvc mvc; + + @Autowired + IndividualRepoService individualRepoService; + + @Autowired + OrganizationRepoService organizationRepoService; +// +// @Autowired +// private FilterChainProxy filterChainProxy; +// +// @Autowired +// private WebApplicationContext wac; +// +// @Before +// public void setUp() { +// MockitoAnnotations.initMocks(this); +// this.mvc = MockMvcBuilders.webAppContextSetup(wac).dispatchOptions(true).addFilters(filterChainProxy).build(); +// } + + @Autowired + private WebApplicationContext context; + + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context).dispatchOptions(true) + .apply( SecurityMockMvcConfigurers.springSecurity()) + .build(); + } + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void addIndividual() throws Exception { + + IndividualCreate ic = new IndividualCreate(); + ic.setFamilyName("A Customer"); + + List contactMediums = new ArrayList<>(); + ContactMedium cm = new ContactMedium(); + contactMediums.add(cm); + cm.setMediumType("email"); + cm.setPreferred(true); + MediumCharacteristic medChar = new MediumCharacteristic(); + medChar.setEmailAddress( "test@openslice.io" ); + cm.setCharacteristic(medChar); + ic.setContactMedium(contactMediums ); + + String response = mvc.perform(MockMvcRequestBuilders.post("/party/v4/individual") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( ic ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("familyName", is("A Customer"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( individualRepoService.findAll().size() ).isEqualTo( 1 ); + + + Individual responseIndv = JsonUtils.toJsonObj(response, Individual.class); + assertThat( responseIndv.getContactMedium().stream().findFirst().get().getCharacteristic().getEmailAddress()).isEqualTo("test@openslice.io"); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void addOrganization() throws Exception { + + OrganizationCreate oc = new OrganizationCreate(); + oc.setName("An Organization"); + + List contactMediums = new ArrayList<>(); + ContactMedium cm = new ContactMedium(); + contactMediums.add(cm); + cm.setMediumType("email"); + cm.setPreferred(true); + MediumCharacteristic medChar = new MediumCharacteristic(); + medChar.setEmailAddress( "test@openslice.io" ); + cm.setCharacteristic(medChar); + oc.setContactMedium(contactMediums ); + + + Characteristic partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_BASEURL"); + partyCharacteristicItem.value( new Any( "http://portal.openslice.io" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_CLIENTREGISTRATIONID"); + partyCharacteristicItem.value( new Any( "authOpensliceProvider" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_OAUTH2CLIENTID"); + partyCharacteristicItem.value( new Any( "osapiWebClientId" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_OAUTH2CLIENTSECRET"); + partyCharacteristicItem.value( new Any( "secret" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_OAUTH2SCOPES"); + partyCharacteristicItem.value( new Any( "admin;read" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_OAUTH2TOKENURI"); + partyCharacteristicItem.value( new Any( "http://portal.openslice.io/osapi-oauth-server/oauth/token" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_USERNAME"); + partyCharacteristicItem.value( new Any( "admin" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_PASSWORD"); + partyCharacteristicItem.value( new Any( "openslice" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_SERVICE_CATALOG_URLS"); + partyCharacteristicItem.value( new Any( "" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_SERVICE_CATEGORY_URLS"); + partyCharacteristicItem.value( new Any( "" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("EXTERNAL_TMFAPI_SERVICE_ORDER_URLS"); + partyCharacteristicItem.value( new Any( "" )); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + + partyCharacteristicItem = new Characteristic(); + partyCharacteristicItem.setName("API2"); + partyCharacteristicItem.setValue( new Any("apiendpoint2")); + oc.addPartyCharacteristicItem(partyCharacteristicItem ); + + String response = mvc.perform(MockMvcRequestBuilders.post("/party/v4/organization") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( oc ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("An Organization"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( organizationRepoService.findAll().size() ).isEqualTo( 1 ); + + + Organization responseOrg = JsonUtils.toJsonObj(response, Organization.class); + assertThat( responseOrg.getContactMedium().stream().findFirst().get().getCharacteristic().getEmailAddress()).isEqualTo("test@openslice.io"); + assertThat( responseOrg.getPartyCharacteristic().size()).isEqualTo(12); + + + String resp = organizationRepoService.getPartnerOrganizationsWithAPI(); + + Class> clazz = (Class) List.class; + List orgz = mapJsonToObjectList( new Organization(), (String)resp, Organization.class ); + + assertThat( orgz.size() ).isEqualTo( 1 ); + assertThat( orgz.get(0).getPartyCharacteristic().size() ).isEqualTo( 12 ); + } + + protected static List mapJsonToObjectList(T typeDef,String json,Class clazz) throws Exception + { + List list; + ObjectMapper mapper = new ObjectMapper(); + System.out.println(json); + TypeFactory t = TypeFactory.defaultInstance(); + list = mapper.readValue(json, t.constructCollectionType(ArrayList.class,clazz)); + +// System.out.println(list); +// System.out.println(list.get(0).getClass()); + return list; + } + +} diff --git a/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fc2b66ebe395c7e0757ea686fa97a90a760f85de --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ProductCatalogIntegrationTest.java @@ -0,0 +1,354 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.services.api; + +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.util.UUID; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.pcm620.model.BundledProductOffering; +import org.etsi.osl.tmf.pcm620.model.Catalog; +import org.etsi.osl.tmf.pcm620.model.CatalogCreate; +import org.etsi.osl.tmf.pcm620.model.CatalogUpdate; +import org.etsi.osl.tmf.pcm620.model.Category; +import org.etsi.osl.tmf.pcm620.model.CategoryCreate; +import org.etsi.osl.tmf.pcm620.model.CategoryRef; +import org.etsi.osl.tmf.pcm620.model.CategoryUpdate; +import org.etsi.osl.tmf.pcm620.model.ProductOffering; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingCreate; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceCreate; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingPriceRef; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingRef; +import org.etsi.osl.tmf.pcm620.model.ProductOfferingTerm; +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.model.ResourceCandidateRef; +import org.etsi.osl.tmf.pcm620.model.SLARef; +import org.etsi.osl.tmf.pcm620.model.ServiceCandidateRef; +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.JsonUtils; + +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; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class) +//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ProductCatalogIntegrationTest { + + private static final transient Log logger = LogFactory.getLog(ProductCatalogIntegrationTest.class.getName()); + + @Autowired + private MockMvc mvc; + + @Autowired + ProductCatalogRepoService catalogRepoService; + + @Autowired + ProductCategoryRepoService categRepoService; + + @Autowired + ProductOfferingRepoService productOfferingRepoService; + + + @Autowired + ProductOfferingPriceRepoService productOfferingPriceRepoService; + + + @Autowired + ProductSpecificationRepoService productSpecificationRepoService; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build(); + } + + @WithMockUser(username = "osadmin", roles = { "ADMIN", "USER" }) + @Test + public void testProductCatalog() throws Exception { + File scatalog = new File("src/test/resources/testProductCatalog.txt"); + InputStream in = new FileInputStream(scatalog); + String resvxf = IOUtils.toString(in, "UTF-8"); + + CatalogCreate scc = JsonUtils.toJsonObj(resvxf, CatalogCreate.class); + scc.setVersion("1.1"); + String response = mvc + .perform(MockMvcRequestBuilders.post("/productCatalogManagement/v4/catalog") + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(scc))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Product Catalog"))).andExpect(status().isOk()).andReturn() + .getResponse().getContentAsString(); + + assertThat(catalogRepoService.findAll().size()).isEqualTo(1); + + Catalog responsesCatalog = JsonUtils.toJsonObj(response, Catalog.class); + assertThat(responsesCatalog.getName()).isEqualTo("Test Product Catalog"); + assertThat(responsesCatalog.getVersion()).isEqualTo("1.1"); + + assertThat(responsesCatalog.getCategoryObj().size()).isEqualTo(0); + + /** + * add category + */ + + File scat = new File("src/test/resources/testProductCategory.txt"); + in = new FileInputStream(scat); + String sc = IOUtils.toString(in, "UTF-8"); + + CategoryCreate scategcreate = JsonUtils.toJsonObj(sc, CategoryCreate.class); + scategcreate.setVersion("1.2"); + + response = mvc + .perform(MockMvcRequestBuilders.post("/productCatalogManagement/v4/category") + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(scategcreate))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Product Category 2"))).andExpect(status().isOk()).andReturn() + .getResponse().getContentAsString(); + + assertThat(categRepoService.findAll().size()).isEqualTo(1); + + Category responsesCateg = JsonUtils.toJsonObj(response, Category.class); + assertThat(responsesCateg.getName()).isEqualTo("Test Product Category 2"); + assertThat(responsesCateg.getVersion()).isEqualTo("1.2"); + + + + + + /** + * update catalog with category + */ + CatalogUpdate scu = new CatalogUpdate(); + scu.setName("A new Name"); + scu.setVersion("1.3"); + CategoryRef categoryItem = new CategoryRef(); + categoryItem.setId(responsesCateg.getId()); + + scu.addCategoryItem(categoryItem); + response = mvc + .perform( + MockMvcRequestBuilders.patch("/productCatalogManagement/v4/catalog/" + responsesCatalog.getId()) + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(scu))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("A new Name"))).andExpect(status().isOk()).andReturn().getResponse() + .getContentAsString(); + + assertThat(catalogRepoService.findAll().size()).isEqualTo(1); + + responsesCatalog = JsonUtils.toJsonObj(response, Catalog.class); + assertThat(responsesCatalog.getName()).isEqualTo("A new Name"); + assertThat(responsesCatalog.getVersion()).isEqualTo("1.3"); + + assertThat(responsesCatalog.getCategoryObj().size()).isEqualTo(1); + assertThat(responsesCatalog.getCategoryRefs().get(0).getName()).isEqualTo("Test Product Category 2"); + + /** + * Product Offering + */ + File sspec = new File("src/test/resources/testProductOfferingSpec.json"); + in = new FileInputStream(sspec); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ProductOfferingCreate sspeccr = JsonUtils.toJsonObj(sspectext, ProductOfferingCreate.class); + + ProductOfferingPriceRef productOfferingPriceItem = new ProductOfferingPriceRef(); + productOfferingPriceItem.setId(UUID.randomUUID().toString()); + productOfferingPriceItem.setName("a productOfferingPriceItem"); + sspeccr.addProductOfferingPriceItem(productOfferingPriceItem); + + ProductSpecificationCharacteristicValueUse prodSpecCharValueUseItem = new ProductSpecificationCharacteristicValueUse(); + prodSpecCharValueUseItem.setName("A test prodSpecCharValueUseItem"); + ProductSpecificationCharacteristicValue productSpecCharacteristicValueItem = new ProductSpecificationCharacteristicValue(); + productSpecCharacteristicValueItem.setUnitOfMeasure("meters"); + prodSpecCharValueUseItem.addProductSpecCharacteristicValueItem(productSpecCharacteristicValueItem); + sspeccr.addProdSpecCharValueUseItem(prodSpecCharValueUseItem); + + ServiceCandidateRef serviceCandidateRef = new ServiceCandidateRef(); + serviceCandidateRef.setId(UUID.randomUUID().toString()); + serviceCandidateRef.setName("a serviceCandidateRef"); + sspeccr.setServiceCandidate(serviceCandidateRef); + + ResourceCandidateRef aResourceCandidateRef = new ResourceCandidateRef(); + aResourceCandidateRef.setId(UUID.randomUUID().toString()); + aResourceCandidateRef.setName("a ResourceCandidateRef"); + sspeccr.setResourceCandidate(aResourceCandidateRef); + + SLARef aSLARef = new SLARef(); + aSLARef.setId(UUID.randomUUID().toString()); + aSLARef.setName("a SLARef"); + sspeccr.setServiceLevelAgreement(aSLARef); + + ProductOfferingTerm aProductOfferingTerm = new ProductOfferingTerm(); + aProductOfferingTerm.setName("a ProductOfferingTerm"); + sspeccr.addProductOfferingTermItem(aProductOfferingTerm); + + BundledProductOffering aBundledProductOffering = new BundledProductOffering(); + aBundledProductOffering.setId(UUID.randomUUID().toString()); + aBundledProductOffering.setName("a BundledProductOffering"); + sspeccr.addBundledProductOfferingItem(aBundledProductOffering); + + ProductSpecificationRef aProductSpecificationRef = new ProductSpecificationRef(); + aProductSpecificationRef.setId(UUID.randomUUID().toString()); + aProductSpecificationRef.setName("a aProductSpecificationRef"); + sspeccr.setProductSpecification(aProductSpecificationRef); + + // byte[] s = JsonUtils.toJson( sspeccr ); + + response = mvc + .perform(MockMvcRequestBuilders.post("/productCatalogManagement/v4/productOffering") + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(sspeccr))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Product offering Spec"))).andExpect(status().isOk()).andReturn() + .getResponse().getContentAsString(); + assertThat(productOfferingRepoService.findAll().size()).isEqualTo(1); + ProductOffering responsesProdOff = JsonUtils.toJsonObj(response, ProductOffering.class); + assertThat(responsesProdOff.getUuid()).isNotNull(); + assertThat(responsesProdOff.getId()).isEqualTo( responsesProdOff.getUuid() ); + assertThat(responsesProdOff.getName()).isEqualTo("Test Product offering Spec"); + assertThat(responsesProdOff.getProductOfferingPrice().size()).isEqualTo(1); + assertThat(responsesProdOff.getProdSpecCharValueUse().size()).isEqualTo(1); + assertThat(responsesProdOff.getProdSpecCharValueUse().toArray(new ProductSpecificationCharacteristicValueUse[0])[0] + .getProductSpecCharacteristicValue().size()).isEqualTo(1); + + + + /** + * patch category + */ + + CategoryUpdate scategupd = JsonUtils.toJsonObj(sc, CategoryCreate.class); + scategupd.setVersion("1.2"); + scategupd.setName("Test Product Category UPD2"); + ProductOfferingRef poref = new ProductOfferingRef(); + poref.setId( responsesProdOff.getId() ); + poref.setName( responsesProdOff.getName() ); + scategupd.addProductOfferingItem (poref ); + response = mvc + .perform(MockMvcRequestBuilders.patch("/productCatalogManagement/v4/category/" + responsesCateg.getId()) + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( scategupd ))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Product Category UPD2"))).andExpect(status().isOk()).andReturn() + .getResponse().getContentAsString(); + + assertThat(categRepoService.findAll().size()).isEqualTo(1); + assertThat(categRepoService.findAll().get(0).getProductOfferingRefs().size() ).isEqualTo(1); + + + + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testProductOfferingPrice() throws Exception { + File testProductOfferingPrice = new File( "src/test/resources/testProductOfferingPrice.txt" ); + InputStream in = new FileInputStream( testProductOfferingPrice ); + String resvxf = IOUtils.toString(in, "UTF-8"); + + ProductOfferingPriceCreate scc = JsonUtils.toJsonObj( resvxf, ProductOfferingPriceCreate.class); + scc.setVersion("1.1"); + String response = mvc.perform(MockMvcRequestBuilders.post("/productCatalogManagement/v4/productOfferingPrice") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scc ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Recurring Charge for Business Firewall"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( productOfferingPriceRepoService.findAll().size() ).isEqualTo( 1 ); + + + } + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testProductSpec() throws Exception { + File testProductOfferingPrice = new File( "src/test/resources/testProductSpec.json" ); + InputStream in = new FileInputStream( testProductOfferingPrice ); + String resvxf = IOUtils.toString(in, "UTF-8"); + + ProductSpecificationCreate scc = JsonUtils.toJsonObj( resvxf, ProductSpecificationCreate.class); + scc.setVersion("1.1"); + String response = mvc.perform(MockMvcRequestBuilders.post("/productCatalogManagement/v4/productSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scc ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Acme Firepower NGFW"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( productSpecificationRepoService.findAll().size() ).isEqualTo( 1 ); + + + } + + + +} diff --git a/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..02aa8e095c94224861e518136431600a89d9f4c9 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ResourceCatalogIntegrationTest.java @@ -0,0 +1,855 @@ +/*- + * ========================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.services.api; + + + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.is; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URI; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.common.model.AttachmentRefOrValue; +import org.etsi.osl.tmf.common.model.EValueType; +import org.etsi.osl.tmf.common.model.Quantity; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceCandidateCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalog; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalogUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceCategory; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryRef; +import org.etsi.osl.tmf.rcm634.model.ResourceCategoryUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecCharRelationship; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristic; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristicValue; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRelationship; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCandidateRepoService; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCatalogRepoService; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCategoryRepoService; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.JsonUtils; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockMultipartFile; +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 net.minidev.json.JSONObject; + + +@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 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_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; + + @Autowired + private MockMvc mvc; + + @Autowired + ResourceCatalogRepoService catalogRepoService; + + + @Autowired + ResourceCategoryRepoService categRepoService; + + @Autowired + ResourceSpecificationRepoService specRepoService; + + @Autowired + ResourceCandidateRepoService candidateRepoService; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @Test + public void _countDefaultProperties() { + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 1 ); + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES ); + assertThat( candidateRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + + + assertThat( catalogRepoService.findByName( "Catalog" ) ).isNotNull() ; + assertThat( categRepoService.findByName( "Network Resources" ) ).isNotNull() ; + + ResourceCategory categ = categRepoService.findByName( "Network Resources" ); + assertThat( categ.getResourceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_NETWORK_SPECS ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN", "USER"}) + @Test + public void addCatalogAddCategory() throws Exception { + File scatalog = new File( "src/test/resources/testResourceCatalog.txt" ); + InputStream in = new FileInputStream( scatalog ); + String resvxf = IOUtils.toString(in, "UTF-8"); + + ResourceCatalogCreate scc = JsonUtils.toJsonObj( resvxf, ResourceCatalogCreate.class); + + String response = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceCatalog") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scc ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Catalog"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 2 ); + + ResourceCatalog responsesCatalog = JsonUtils.toJsonObj(response, ResourceCatalog.class); + assertThat( responsesCatalog.getName() ).isEqualTo( "Test Catalog" ); + + assertThat( responsesCatalog.getCategoryObj().size()).isEqualTo(0); + + + /** + * add category + */ + + File scat = new File( "src/test/resources/testResourceCategory.txt" ); + in = new FileInputStream( scat ); + String sc = IOUtils.toString(in, "UTF-8"); + + ResourceCategoryCreate scategcreate = JsonUtils.toJsonObj( sc, ResourceCategoryCreate.class); + + response = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceCategory") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scategcreate ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Category 2"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 1 ); + + ResourceCategory responsesCateg = JsonUtils.toJsonObj(response, ResourceCategory.class); + assertThat( responsesCateg.getName() ).isEqualTo( "Test Category 2" ); + + response = mvc.perform(MockMvcRequestBuilders.get("/resourceCatalogManagement/v4/resourceCategory/"+responsesCateg.getId()) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scategcreate ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Category 2"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + responsesCateg = JsonUtils.toJsonObj(response, ResourceCategory.class); + assertThat( responsesCateg.getName() ).isEqualTo( "Test Category 2" ); + + + /** + * update catalog with category + */ + ResourceCatalogUpdate scu = new ResourceCatalogUpdate(); + scu.setName( responsesCatalog.getName() ); + ResourceCategoryRef categoryItem = new ResourceCategoryRef(); + categoryItem.setId( responsesCateg.getId() ); + + scu.addCategoryItem(categoryItem); + response = mvc.perform(MockMvcRequestBuilders.patch("/resourceCatalogManagement/v4/resourceCatalog/" + responsesCatalog.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scu ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Catalog"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 2 ); + + responsesCatalog = JsonUtils.toJsonObj(response, ResourceCatalog.class); + assertThat(responsesCatalog.getName()).isEqualTo("Test Catalog"); + + + assertThat( responsesCatalog.getCategoryObj().size()).isEqualTo(1); + assertThat( responsesCatalog.getCategoryRefs().get(0).getName() ).isEqualTo( "Test Category 2" ); + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 1 ); + + /** + * Resource Spec + */ + File sspec = new File( "src/test/resources/testResourceSpec.json" ); + in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + LogicalResourceSpecificationCreate sspeccr = JsonUtils.toJsonObj( sspectext, LogicalResourceSpecificationCreate.class); + + response = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Resource Spec"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS +1 ); + LogicalResourceSpecification responsesSpec = JsonUtils.toJsonObj(response, LogicalResourceSpecification.class); + assertThat( responsesSpec.getName() ).isEqualTo( "Test Resource Spec" ); + + assertThat( responsesSpec.getResourceSpecCharacteristic().size() ).isEqualTo(1); + assertThat( responsesSpec.getResourceSpecCharacteristic().toArray( new ResourceSpecificationCharacteristic[0] )[0].getResourceSpecCharacteristicValue().size() ).isEqualTo(1); + + + + +// ResourceCandidateCreate scand = new ResourceCandidateCreate(); +// scand.setName( responsesSpec.getName()); +// ResourceSpecificationRef resSpecificationRef = new ResourceSpecificationRef(); +// resSpecificationRef.setId( responsesSpec.getId()); +// resSpecificationRef.setName( responsesSpec .getName()); +// scand.resourceSpecification(resSpecificationRef); +// categoryItem = new ResourceCategoryRef(); +// categoryItem.setId( responsesCateg.getId()); +// categoryItem.setName( responsesCateg.getName() ); +// scand.addCategoryItem(categoryItem); +// +// response = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceCandidate") +// .with( SecurityMockMvcRequestPostProcessors.csrf()) +// .contentType(MediaType.APPLICATION_JSON) +// .content( JsonUtils.toJson( scand ) )) +// .andExpect(status().isOk()) +// .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) +// .andExpect(jsonPath("name", is("Test Resource Spec"))) +// .andExpect(status().isOk()) +// .andReturn().getResponse().getContentAsString(); + + + + + PhysicalResourceSpecificationCreate physpeccr = JsonUtils.toJsonObj( sspectext, PhysicalResourceSpecificationCreate.class); + physpeccr.setType("PhysicalResourceSpecification"); + physpeccr.setModel("ACME"); + response = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( physpeccr ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Resource Spec"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS +2 ); + PhysicalResourceSpecification phyresponsesSpec = JsonUtils.toJsonObj(response, PhysicalResourceSpecification.class); + assertThat( phyresponsesSpec.getName() ).isEqualTo( "Test Resource Spec" ); + assertThat( phyresponsesSpec.getModel() ).isEqualTo( "ACME" ); + + assertThat( phyresponsesSpec.getResourceSpecCharacteristic().size() ).isEqualTo(1); + assertThat( phyresponsesSpec.getResourceSpecCharacteristic().toArray( new ResourceSpecificationCharacteristic[0] )[0].getResourceSpecCharacteristicValue().size() ).isEqualTo(1); + + + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void manageCategoriesSubCategories() throws Exception { + /** + * add category + */ + + File scat = new File( "src/test/resources/testResourceCategory.txt" ); + InputStream in = new FileInputStream( scat ); + String sc = IOUtils.toString(in, "UTF-8"); + + ResourceCategoryCreate scategcreate = JsonUtils.toJsonObj( sc, ResourceCategoryCreate.class); + scategcreate.setIsRoot(true); + ResourceCategory parentRootCategory = postCategory( scategcreate, scategcreate.getName() ); + + ResourceCategoryCreate scategcreate2 = JsonUtils.toJsonObj( sc, ResourceCategoryCreate.class); + scategcreate2.setName("Child Cat"); + ResourceCategory child1Subcategory = postCategory( scategcreate2, scategcreate2.getName() ); + + ResourceCategoryUpdate scUpd1 = JsonUtils.toJsonObj( sc, ResourceCategoryUpdate.class); + scUpd1.setIsRoot(true); + scUpd1.setName("Parent Cat"); + ResourceCategoryRef scRef = new ResourceCategoryRef(); + scRef.setId( child1Subcategory.getId() ); + scRef.setName( child1Subcategory.getName() ); + scUpd1.addCategoryItem(scRef); + + + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 2 ); + + String response = mvc.perform(MockMvcRequestBuilders.patch("/resourceCatalogManagement/v4/resourceCategory/" + parentRootCategory.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is( "Parent Cat" ))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + parentRootCategory = JsonUtils.toJsonObj(response, ResourceCategory.class); + + + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 2 ); + assertThat( parentRootCategory.getCategoryRefs().size() ).isEqualTo(1); + assertThat( parentRootCategory.getCategoryRefs().get(0).getId() ).isEqualTo( child1Subcategory.getId() ); + + /** + * add to a resource catalog and delete the service catalog, to check that categories are still there + * + */ + ResourceCatalog catalog = catalogRepoService.findByName( "Catalog" ); + assertThat( catalog.getCategoryRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES ); + ResourceCatalogUpdate scu = new ResourceCatalogUpdate(); + scu.setName( catalog.getName() ); + for (ResourceCategoryRef iref : catalog.getCategoryRefs()) { + scu.addCategoryItem( iref ); + } + ResourceCategoryRef categoryItem = new ResourceCategoryRef(); + categoryItem.setId( parentRootCategory.getId() ); + scu.addCategoryItem( categoryItem ); + catalog = catalogRepoService.updateCatalog( catalog.getId(), scu); + + assertThat( catalog.getCategoryRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 1 ); + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 2 ); + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 1 ); + catalogRepoService.deleteById( catalog.getId() );//delete + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 0 ); + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 2 );//categories must remain + //fetch the subcategory and check parent ID + + response = mvc.perform(MockMvcRequestBuilders.get("/resourceCatalogManagement/v4/resourceCategory/" + parentRootCategory.getCategoryRefs().get(0).getId() ) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andReturn().getResponse().getContentAsString(); + + child1Subcategory = JsonUtils.toJsonObj(response, ResourceCategory.class); + + assertThat( child1Subcategory.getParentId() ).isEqualTo( parentRootCategory.getId() ); + + //delete category with childs not allows (not modified) + response = mvc.perform(MockMvcRequestBuilders.delete("/resourceCatalogManagement/v4/resourceCategory/" + parentRootCategory.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isNotModified() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 2 ); + + //delete subcategory + response = mvc.perform(MockMvcRequestBuilders.delete("/resourceCatalogManagement/v4/resourceCategory/" + parentRootCategory.getCategoryRefs().get(0).getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES + 1 ); + + //delete rootcategory + response = mvc.perform(MockMvcRequestBuilders.delete("/resourceCatalogManagement/v4/resourceCategory/" + parentRootCategory.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( categRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATEGORIES ); + + } + + + + private ResourceCategory postCategory(ResourceCategoryCreate scategcreate, String name) throws UnsupportedEncodingException, IOException, Exception { + + String response = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceCategory") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scategcreate ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is( name ))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ResourceCategory responsesCateg = JsonUtils.toJsonObj(response, ResourceCategory.class); + + return responsesCateg; + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN" , "USER"}) + @Test + public void testSpecAttributesUpdate() throws Exception { + logger.info("Test: testSpecAttributesUpdate"); + /** + * Resource Spec + */ + File sspec = new File( "src/test/resources/testResourceSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + LogicalResourceSpecificationCreate sspeccr = JsonUtils.toJsonObj( sspectext, LogicalResourceSpecificationCreate.class); + + AttachmentRefOrValue attachmentItem = new AttachmentRefOrValue(); + attachmentItem.setId( "a-ref-id" ); + attachmentItem.setDescription("an attachment"); + attachmentItem.setUrl("a url"); + attachmentItem.setName("aname"); + sspeccr.addAttachmentItem(attachmentItem); + String responseSpec = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Resource Spec"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + LogicalResourceSpecification responsesSpec = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + //logger.info("Test: testSpecAttachments response = " + responseSpec); + assertThat( responsesSpec.getName() ).isEqualTo( "Test Resource Spec" ); + assertThat( responsesSpec.getAttachment().size() ).isEqualTo( 1 ); + + //make it now as a ResourceSpecificationUpdate, no id, uuid and lastUpdate + JSONObject obj = JsonUtils.toJsonObj(responseSpec, JSONObject.class); + obj.remove("uuid"); + obj.remove("id"); + obj.remove("lastUpdate"); + obj.remove("@type"); + responseSpec = JsonUtils.toJsonString(obj); + + ResourceSpecificationUpdate responsesSpecUpd = JsonUtils.toJsonObj(responseSpec, ResourceSpecificationUpdate.class); + responsesSpecUpd.setName( "Test Spec a attr" ); + responsesSpecUpd.setVersion("2.x"); + ResourceSpecificationCharacteristic spechar = new ResourceSpecificationCharacteristic(); + spechar.setName("A new characteristic"); + ResourceSpecificationCharacteristicValue sv = new ResourceSpecificationCharacteristicValue(); + sv.setValue( new Any("1" ,"a first value") ); + sv.setValueType( EValueType.LONGTEXT.getValue()); + spechar.getResourceSpecCharacteristicValue().add( sv ); + responsesSpecUpd.getResourceSpecificationCharacteristic().add(spechar ); + + String response2 = mvc.perform(MockMvcRequestBuilders.patch("/resourceCatalogManagement/v4/resourceSpecification/" + responsesSpec.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( responsesSpecUpd ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Spec a attr"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + ResourceSpecification responsesSpec2 = JsonUtils.toJsonObj(response2, LogicalResourceSpecification.class); + assertThat( responsesSpec2.getName() ).isEqualTo( "Test Spec a attr" ); + assertThat( responsesSpec2.getVersion() ).isEqualTo( "2.x" ); + assertThat( responsesSpec2.getResourceSpecCharacteristic().size() ).isEqualTo(2); + assertThat( responsesSpec2.getResourceSpecCharacteristic().toArray( new ResourceSpecificationCharacteristic[0] )[0].getResourceSpecCharacteristicValue().size() ).isEqualTo(1); + assertThat( responsesSpec2.findSpecCharacteristicByName("CoverageSpec") ).isNotNull(); + assertThat( responsesSpec2.findSpecCharacteristicByName("A new characteristic") ).isNotNull(); + assertThat( responsesSpec2.findSpecCharacteristicByName("CoverageSpec").getResourceSpecCharacteristicValue().size() ).isEqualTo(1); + assertThat( responsesSpec2.findSpecCharacteristicByName("A new characteristic").getResourceSpecCharacteristicValue().toArray( new ResourceSpecificationCharacteristicValue[0] )[0].getValue().getAlias() ).isEqualTo("a first value"); + assertThat( responsesSpec2.findSpecCharacteristicByName("A new characteristic").getResourceSpecCharacteristicValue().toArray( new ResourceSpecificationCharacteristicValue[0] )[0].getValueType() ).isEqualTo("LONGTEXT"); + assertThat( responsesSpec2.findSpecCharacteristicByName("CoverageSpec").getResourceSpecCharRelationship().size() ).isEqualTo(4); + + + //logger.info("Test: testSpecAttachments responsesSpec2 patch1= " + response2.toString()); + + //test now update and delete things + responsesSpecUpd = JsonUtils.toJsonObj(responseSpec, ResourceSpecificationUpdate.class); + ResourceSpecificationCharacteristicValue val = new ResourceSpecificationCharacteristicValue(); + val.setValueType( EValueType.ARRAY.toString()); + val.setValue( new Any("1" ,"a second value") ); + responsesSpecUpd.getResourceSpecificationCharacteristic().get(0).getResourceSpecCharacteristicValue().add(val); + ResourceSpecCharRelationship scrObj = responsesSpecUpd.getResourceSpecificationCharacteristic().get(0).getResourceSpecCharRelationship().toArray( new ResourceSpecCharRelationship[0])[0]; + ResourceSpecCharRelationship scrObj2 = responsesSpecUpd.getResourceSpecificationCharacteristic().get(0).getResourceSpecCharRelationship().toArray( new ResourceSpecCharRelationship[0])[1]; + ResourceSpecCharRelationship scrObj3 = responsesSpecUpd.getResourceSpecificationCharacteristic().get(0).getResourceSpecCharRelationship().toArray( new ResourceSpecCharRelationship[0])[2]; + scrObj3.setName("FORTESTING"); + String preid = scrObj3.getId(); + responsesSpecUpd.getResourceSpecificationCharacteristic().get(0).getResourceSpecCharRelationship().remove(scrObj); + responsesSpecUpd.getResourceSpecificationCharacteristic().get(0).getResourceSpecCharRelationship().remove(scrObj2); + ResourceSpecCharRelationship scrObj4 = new ResourceSpecCharRelationship(); + scrObj4.setName("ANEWCharRel"); + responsesSpecUpd.getResourceSpecificationCharacteristic().get(0).getResourceSpecCharRelationship().add(scrObj4); + + response2 = mvc.perform(MockMvcRequestBuilders.patch("/resourceCatalogManagement/v4/resourceSpecification/" + responsesSpec.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( responsesSpecUpd ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Resource Spec"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); +// logger.info("Test: testSpecAttachments responsesSpec2 patch2= " + response2.toString()); + + responsesSpec2 = JsonUtils.toJsonObj(response2, LogicalResourceSpecification.class); + + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1 ); + + assertThat( responsesSpec2.getName() ).isEqualTo( "Test Resource Spec" ); + assertThat( responsesSpec2.getResourceSpecCharacteristic().size() ).isEqualTo(1); + assertThat( responsesSpec2.findSpecCharacteristicByName("CoverageSpec") ).isNotNull(); + assertThat( responsesSpec2.findSpecCharacteristicByName("CoverageSpec").getResourceSpecCharacteristicValue().size() ).isEqualTo(2); + boolean secvalExists = false; + boolean arrayValExists = false; + for (ResourceSpecificationCharacteristicValue respval : responsesSpec2.findSpecCharacteristicByName("CoverageSpec").getResourceSpecCharacteristicValue().toArray( new ResourceSpecificationCharacteristicValue[0] )) { + if ( respval.getValue().getAlias().equals("a second value")){ + secvalExists = true; + } + if ( respval.getValueType().equals("ARRAY")){ + arrayValExists = true; + } + } + assertThat( secvalExists ).isTrue(); + assertThat( arrayValExists).isTrue(); + + + assertThat( responsesSpec2.findSpecCharacteristicByName("CoverageSpec").getResourceSpecCharRelationship().size() ).isEqualTo(3); + boolean idfound = false; + boolean ANEWCharRelExists =false; + for (ResourceSpecCharRelationship tscr : responsesSpec2.findSpecCharacteristicByName("CoverageSpec").getResourceSpecCharRelationship()) { + if ( (tscr.getId()!=null) && ( tscr.getId().equals(preid)) ) { + idfound = true; + assertThat( tscr.getName().equals("FORTESTING")); + } + + if ( (tscr!=null) && (tscr.getName().equals( "ANEWCharRel" )) ){ + ANEWCharRelExists = true; + } + } + assertThat( idfound).isTrue(); + assertThat( ANEWCharRelExists).isTrue(); + assertThat( responsesSpec2.findSpecCharacteristicByName("A new characteristic") ).isNull(); + +// logger.info("Test: testSpecAttachments responsesSpec2 patch2= " + response2); + + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS +1 ); + + } + +// @GetMapping("/customHeader") +// public ResponseEntity customHeader() { +// HttpHeaders headers = new HttpHeaders(); +// headers.add("Custom-Header", "foo"); +// +// return new ResponseEntity<>("Custom header set", headers, HttpStatus.OK); +// } + + + private ResourceSpecification createResourceSpec(ResourceSpecificationUpdate sspeccr1) throws Exception{ + + URI url = new URI("/resourceCatalogManagement/v4/resourceSpecification"); + if (sspeccr1 instanceof PhysicalResourceSpecificationUpdate ) { + url = new URI("/resourceCatalogManagement/v4/resourceSpecification"); + } + String responseSpec = mvc.perform(MockMvcRequestBuilders.post( url ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ResourceSpecification responsesSpec1; + if (sspeccr1 instanceof PhysicalResourceSpecificationUpdate ) { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, PhysicalResourceSpecification.class); + }else { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + } + +// logger.info("createResourceSpec = " + responseSpec); + return responsesSpec1; + } + + @WithMockUser(username="osadmin", roles = {"USER" , "ADMIN"}) + @Test + public void testBundledSpec() throws Exception { + logger.info("Test: testBundledSpec " ); + + /** + * 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"); + LogicalResourceSpecification responsesSpec1 = (LogicalResourceSpecification) createResourceSpec( sspeccr1); + + + ResourceSpecificationCreate sspeccr2 = JsonUtils.toJsonObj( sspectext, ResourceSpecificationCreate.class); + sspeccr2.setName("Spec2"); + LogicalResourceSpecification responsesSpec2 = (LogicalResourceSpecification) createResourceSpec(sspeccr2); + + + ResourceSpecificationCreate sspeccr3 = JsonUtils.toJsonObj( sspectext, ResourceSpecificationCreate.class); + sspeccr3.setName("Spec3"); + sspeccr3.isBundle(true); + sspeccr3.addResourceSpecificationRelationshipWith( responsesSpec1 ); + sspeccr3.addResourceSpecificationRelationshipWith( responsesSpec2 ); + LogicalResourceSpecification responsesSpec3 = (LogicalResourceSpecification) createResourceSpec(sspeccr3); + + + assertThat( responsesSpec3.getResourceSpecRelationship().size() ).isEqualTo(2); + boolean idspec1Exists = false; + boolean idspec2Exists = false; + String relationship2UUID = null; + for (ResourceSpecificationRelationship r : responsesSpec3.getResourceSpecRelationship()) { + if ( r.getId().equals( responsesSpec1.getId() ) ) { + idspec1Exists= true; + } + if ( r.getId().equals( responsesSpec2.getId() ) ) { + idspec2Exists= true; + relationship2UUID = r.getUuid(); + } + } + assertThat( idspec1Exists ).isTrue(); + assertThat( idspec2Exists ).isTrue(); + + /** + * try PATCH with service relationships + */ + //first add a new service spec and then reference it + ResourceSpecificationCreate sspeccr4 = JsonUtils.toJsonObj( sspectext, ResourceSpecificationCreate.class); + sspeccr4.setName("Spec4"); + ResourceSpecification responsesSpec4 = createResourceSpec( sspeccr3); + + String responseSpec3 = JsonUtils.toJsonString( responsesSpec3 ); + JSONObject obj = JsonUtils.toJsonObj(responseSpec3, JSONObject.class); + obj.remove("uuid"); + obj.remove("id"); + obj.remove("lastUpdate"); + obj.remove("@type"); + responseSpec3 = JsonUtils.toJsonString(obj); + + ResourceSpecificationUpdate responsesSpecUpd = JsonUtils.toJsonObj(responseSpec3, ResourceSpecificationUpdate.class); + for (ResourceSpecificationRelationship r : responsesSpecUpd.getResourceSpecificationRelationship()) { + if ( r.getId().equals( responsesSpec1.getId() ) ) { + responsesSpecUpd.getResourceSpecificationRelationship().remove(r); + break; + } + } + responsesSpecUpd.addResourceSpecificationRelationshipWith(responsesSpec4); +// logger.info("Test: testBundledSpec responsesSpecUpd= " + responsesSpecUpd.toString()); + + String responsePatch1 = mvc.perform(MockMvcRequestBuilders.patch("/resourceCatalogManagement/v4/resourceSpecification/" + responsesSpec3.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( responsesSpecUpd ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Spec3"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + ResourceSpecification responseSpecPatch1 = JsonUtils.toJsonObj( responsePatch1, LogicalResourceSpecification.class); + +// logger.info("Test: testBundledSpec responsePatch1= " + responsePatch1); + + assertThat( responseSpecPatch1.getResourceSpecRelationship().size() ).isEqualTo(2); + + idspec1Exists = false; + idspec2Exists = false; + boolean idspec4Exists = false; + for (ResourceSpecificationRelationship r : responseSpecPatch1.getResourceSpecRelationship()) { + if ( r.getId().equals( responsesSpec1.getId() ) ) { + idspec1Exists= true; + } + if ( r.getId().equals( responsesSpec2.getId() ) ) { + idspec2Exists= true; + assertThat( r.getUuid() ).isEqualTo( relationship2UUID ); + + } + if ( r.getId().equals( responsesSpec4.getId() ) ) { + idspec4Exists= true; + } + } + + assertThat( idspec1Exists ).isFalse(); + assertThat( idspec2Exists ).isTrue(); + assertThat( idspec4Exists ).isTrue(); + + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 4 ); + + } + + + + + + @WithMockUser(username="osadmin", roles = {"ADMIN" , "USER"}) + @Test + public void testSpecAttachment() throws Exception { + 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"); + LogicalResourceSpecification responsesSpec1 = (LogicalResourceSpecification) createResourceSpec( sspeccr1); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1 ); + + Attachment att = new Attachment(); + att.setDescription("a test atts"); + att.setSize( new Quantity() ); + + File gz = new File( "src/test/resources/cirros_vnf.tar.gz" ); + InputStream ing = new FileInputStream( gz ); + MockMultipartFile prodFile = new MockMultipartFile("afile", "cirros_vnf.tar.gz", "application/x-gzip", IOUtils.toByteArray(ing)); + + + + String responsePatch1 = mvc.perform(MockMvcRequestBuilders + .multipart("/resourceCatalogManagement/v4/resourceSpecification/" + responsesSpec1.getId() + "/attachment" ) + .file(prodFile) + .param("attachment", JsonUtils.toJsonString(att)) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + ) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Spec1"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + ResourceSpecification responseSpecPost1 = JsonUtils.toJsonObj( responsePatch1, LogicalResourceSpecification.class); + + //logger.info("Test: testSpecAttachment responseSpecPost1= " + responseSpecPost1); + + assertThat( responseSpecPost1.getAttachment().size() ).isEqualTo( 1 ); + } + + + @WithMockUser(username="osadmin", roles = {"USER", "ADMIN"}) + @Test + public void testLogicalPhysicalResources() throws Exception { + 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"); + LogicalResourceSpecification responsesSpec1 = (LogicalResourceSpecification) createResourceSpec( sspeccr1); + + + PhysicalResourceSpecificationCreate physspeccr1 = JsonUtils.toJsonObj( sspectext, PhysicalResourceSpecificationCreate.class); + physspeccr1.setType("PhysicalResourceSpecification"); + physspeccr1.setName("SpecPhy1"); + physspeccr1.setPart("APART"); + physspeccr1.setModel("ACME"); + PhysicalResourceSpecification phyresponsesSpec1 = (PhysicalResourceSpecification) createResourceSpec( physspeccr1); + + + //testPhysicalResourceSpec.json + File physsspec2 = new File( "src/test/resources/testPhysicalResourceSpec.json" ); + in = new FileInputStream( physsspec2 ); + String physsspectext = IOUtils.toString(in, "UTF-8"); + PhysicalResourceSpecificationCreate physspeccr2 = JsonUtils.toJsonObj( physsspectext, PhysicalResourceSpecificationCreate.class); + phyresponsesSpec1 = (PhysicalResourceSpecification) createResourceSpec( physspeccr2); + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 3 ); + assertThat( specRepoService.findAllPhysical().size() ).isEqualTo( FIXED_BOOTSTRAPS_PHYSICAL_SPECS + 2 ); + assertThat( specRepoService.findAllLogical().size() ).isEqualTo( FIXED_BOOTSTRAPS_LOGICAL_SPECS + 1); + + } + +} diff --git a/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ee4d7a4f59c3385015c424b3dbe7d4182e965ca8 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ResourceInventoryIntegrationTest.java @@ -0,0 +1,417 @@ +/*- + * ========================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.services.api; + + + +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; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +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.common.model.service.ResourceRef; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCatalogRepoService; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceCategoryRepoService; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.ri639.model.Characteristic; +import org.etsi.osl.tmf.ri639.model.LogicalResource; +import org.etsi.osl.tmf.ri639.model.Resource; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.model.ResourceOperationalStateType; +import org.etsi.osl.tmf.ri639.model.ResourceRelationship; +import org.etsi.osl.tmf.ri639.model.ResourceUpdate; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.etsi.osl.tmf.JsonUtils; + +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; + + +@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 ResourceInventoryIntegrationTest { + + + private static final transient Log logger = LogFactory.getLog( ResourceInventoryIntegrationTest.class.getName()); + + @Autowired + private MockMvc mvc; + + @Autowired + ResourceCatalogRepoService catalogRepoService; + + + @Autowired + ResourceCategoryRepoService categRepoService; + + @Autowired + ResourceSpecificationRepoService specRepoService; + + + @Autowired + ResourceRepoService resourceRepoService; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + @Test + public void _countDefaultProperties() { + + assertThat( resourceRepoService.findAll().size() ).isEqualTo( 0 ); + + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testResourceCreateAndUpdate() 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 + .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); + Resource 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( 0 ); + + + + 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); + 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( 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 ); + + } + + + private ResourceSpecification createResourceSpec(ResourceSpecificationUpdate sspeccr1) throws Exception{ + + URI url = new URI("/resourceCatalogManagement/v4/resourceSpecification"); + if (sspeccr1 instanceof PhysicalResourceSpecificationUpdate ) { + url = new URI("/resourceCatalogManagement/v4/resourceSpecification"); + } + String responseSpec = mvc.perform(MockMvcRequestBuilders.post( url ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ResourceSpecification responsesSpec1; + if (sspeccr1 instanceof PhysicalResourceSpecificationUpdate ) { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, PhysicalResourceSpecification.class); + }else { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + } + +// logger.info("createResourceSpec = " + responseSpec); + return responsesSpec1; + } + + + + + private LogicalResourceSpecification createLogicalResourceSpec() throws Exception{ + 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); + + URI url = new URI("/resourceCatalogManagement/v4/logicalResourceSpec"); + + String responseSpec = mvc.perform(MockMvcRequestBuilders.post( url ) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + LogicalResourceSpecification responsesSpec1; + + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + + logger.info("createResourceSpec = " + responseSpec); + return responsesSpec1; + } + + + + +} diff --git a/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..592b6e4d42d9e475a4ed4a2bae0878cab8a091dd --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ResourceOrderIntegrationTest.java @@ -0,0 +1,194 @@ +package org.etsi.osl.services.api; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +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.io.UnsupportedEncodingException; +import java.net.URI; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.HashSet; +import java.util.Set; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationUpdate; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.ri639.model.Characteristic; +import org.etsi.osl.tmf.ri639.model.ResourceRefOrValue; +import org.etsi.osl.tmf.ri639.model.ResourceRelationship; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.etsi.osl.tmf.ro652.model.ExternalId; +import org.etsi.osl.tmf.ro652.model.ResourceOrder; +import org.etsi.osl.tmf.ro652.model.ResourceOrderCreate; +import org.etsi.osl.tmf.ro652.model.ResourceOrderItem; +import org.etsi.osl.tmf.JsonUtils; + +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.transaction.annotation.Transactional; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class) + +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ResourceOrderIntegrationTest { + + private static final transient Log logger = LogFactory.getLog(ResourceOrderIntegrationTest.class.getName()); + + @Autowired + private MockMvc mvc; + + @Autowired + private FilterChainProxy springSecurityFilterChain; + + @Autowired + ResourceSpecificationRepoService specRepoService; + + @Autowired + ResourceRepoService resourceRepoService; + + @WithMockUser(username = "osadmin", roles = { "USER", "ADMIN" }) + @Test + + public void testResourceOrderCreate() throws UnsupportedEncodingException, IOException, Exception { + + File sspec = new File("src/main/resources/resourceSpecifications/osm-tenant.openslice.io.json"); + InputStream in = new FileInputStream(sspec); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ResourceSpecificationCreate sspeccr1 = JsonUtils.toJsonObj(sspectext, ResourceSpecificationCreate.class); + ResourceSpecification responsesSpec1 = createResourceSpec(sspeccr1); + +// resourceOrderItem id, action +// relatedParty id, @referredType +// note text, id +// orderRelationship id, relationshipType +// orderItem.resource.resourceCharacteristic name +// orderItem.orderItemRelationship orderItem +// orderItem.orderItemRelationship.orderItem itemId +// appointment id +// externalReference name + + ResourceOrderCreate resorder = new ResourceOrderCreate(); + + + resorder + .name("MANOProviderResource") + .category("MANOProvider") + .description("Experimentation Descr") + .addExternalReferenceItem( new ExternalId() ) + .requestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()) + .requestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + + + ResourceOrderItem oItem = new ResourceOrderItem(); + oItem.setId( "xxxx" ); + oItem.setAction("add"); + + + ResourceSpecificationRef resSpecRef = new ResourceSpecificationRef(); + resSpecRef.setId( responsesSpec1.getId() ); + resSpecRef.setName( responsesSpec1.getName() ); + + + Characteristic charitem = new Characteristic(); + charitem + .name("SupportedManoPlatform" ).value( new Any( "OSMvTEN", "OSMvTEN" )) + .name("Username" ).value( new Any( "testakis", "testakis" )); + + Set relationships = new HashSet<>(); + ResourceRelationship erel = new ResourceRelationship(); + erel.setRelationshipType("bubndled"); + relationships.add(erel ); + + ResourceRefOrValue resrc = new ResourceRefOrValue(); + + + resrc + .addResourceCharacteristicItem(charitem) + .resourceSpecification(resSpecRef) + .resourceRelationship( relationships ); + oItem.setResourceRefOrValue( resrc ); + + resorder.addOrderItemItem(oItem); + + logger.info("testResourceOrderCreate Req= " + JsonUtils.toJsonString( resorder )); + // @formatter:off + String responseSorder = mvc + .perform(MockMvcRequestBuilders + .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() + .getResponse() + .getContentAsString(); + + // @formatter:on + logger.info("testResourceOrderCreate = " + responseSorder); + + + + ResourceOrder responseRO = JsonUtils.toJsonObj(responseSorder, ResourceOrder.class); + + assertThat( responseRO.getRequestedCompletionDate()).isNotNull(); + assertThat( responseRO.getOrderItem().stream().findFirst().get() ).isNotNull(); + assertThat( responseRO.getOrderItem().stream().findFirst().get().getResource().getId() ).isNotNull(); + assertThat( responseRO.getOrderItem().stream().findFirst().get().getResource().getName() ).isEqualTo( "osm-tenant.openslice.io" ) ; + } + + private ResourceSpecification createResourceSpec(ResourceSpecificationUpdate sspeccr1) throws Exception { + + URI url = new URI("/resourceCatalogManagement/v4/resourceSpecification"); + if (sspeccr1 instanceof PhysicalResourceSpecificationUpdate) { + url = new URI("/resourceCatalogManagement/v4/resourceSpecification"); + } + String responseSpec = mvc + .perform(MockMvcRequestBuilders.post(url).with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(sspeccr1))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + ResourceSpecification responsesSpec1; + if (sspeccr1 instanceof PhysicalResourceSpecificationUpdate) { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, PhysicalResourceSpecification.class); + } else { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + } + +// logger.info("createResourceSpec = " + responseSpec); + return responsesSpec1; + } + +} diff --git a/src/test/java/org/etsi/osl/services/api/ResourcePoolIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ResourcePoolIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a9763dd599bea04a9468e87149304f386a837bff --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ResourcePoolIntegrationTest.java @@ -0,0 +1,835 @@ +/*- + * ========================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.services.api; + +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; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.service.ResourceRef; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.PhysicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationUpdate; +import org.etsi.osl.tmf.ri639.model.PhysicalResource; +import org.etsi.osl.tmf.ri639.model.Resource; +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.etsi.osl.tmf.rpm685.model.ApplicableTimePeriod; +import org.etsi.osl.tmf.rpm685.model.AvailabilityCheck; +import org.etsi.osl.tmf.rpm685.model.Capacity; +import org.etsi.osl.tmf.rpm685.model.ExtractCreate; +import org.etsi.osl.tmf.rpm685.model.PushCreate; +import org.etsi.osl.tmf.rpm685.model.Reservation; +import org.etsi.osl.tmf.rpm685.model.ReservationCreate; +import org.etsi.osl.tmf.rpm685.model.ResourceCapacityDemand; +import org.etsi.osl.tmf.rpm685.model.ResourcePool; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolCreate; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolRef; +import org.etsi.osl.tmf.rpm685.model.ResourcePoolUpdate; +import org.etsi.osl.tmf.rpm685.reposervices.ResourcePoolRepoService; +import org.etsi.osl.tmf.JsonUtils; + +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; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ResourcePoolIntegrationTest { + + private static final transient Log logger = LogFactory.getLog(ResourcePoolIntegrationTest.class.getName()); + + @Autowired + private MockMvc mvc; + + @Autowired + ResourceRepoService resourceRepoService; + + @Autowired + ResourcePoolRepoService resourcePoolRepoService; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build(); + } + + @WithMockUser(username = "osadmin", roles = { "USER", "ADMIN" }) + @Test + public void testResourcePoolCreateAndUpdate() throws UnsupportedEncodingException, IOException, Exception { + + // Create a resource spec + 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); + + // create a resource + + ResourceCreate aResource = new ResourceCreate(); + aResource.setName("aNew Resource"); + aResource.setCategory("Experimentation"); + aResource.setAtType("PhysicalResource"); + ResourceSpecificationRef aServiceSpecificationRef = new ResourceSpecificationRef(); + aServiceSpecificationRef.setId(responsesSpec1.getId()); + aServiceSpecificationRef.setName(responsesSpec1.getName()); + aResource.setResourceSpecification(aServiceSpecificationRef); + String responseResourceStr = 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("testServiceOrderCreate = " + responseResourceStr); + Resource responseResource = JsonUtils.toJsonObj(responseResourceStr, PhysicalResource.class); + + var resPooltext = "{\"name\" : \"gNB\",\"capacity\" : {\"capacityAmount\" : 4,\"resources\": [{\"id\": \"%s\"},{\"id\": \"F0001\"},{\"id\": \"F0002\"},{\"id\": \"F0003\"} ] }}".formatted(responseResource.getId()); + + ResourcePoolCreate aResourcePool = JsonUtils.toJsonObj(resPooltext, ResourcePoolCreate.class); + + logger.info("aResourcePool JSON = " + JsonUtils.toJsonString(aResourcePool)); + + // @formatter:off + String responseResourcePool = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/resourcePool") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( aResourcePool ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("testresponseResourcePoolCreate = " + responseResourcePool); + ResourcePool responseRPool = JsonUtils.toJsonObj(responseResourcePool, ResourcePool.class); + + assertThat(responseRPool.getId()).isNotNull(); + assertThat(responseRPool.getName()).isEqualTo("gNB"); + assertThat(responseRPool.getCapacity().getCapacityAmount()).isEqualTo(4); + assertThat(responseRPool.getCapacity().getResources().size()).isEqualTo(4); + // assertThat(responseRPool.getCapacity().getResources().stream().findFirst().get() + // .getId()).contains("F0002" ); + + // modify capacity + resPooltext = "{\"name\" : \"gNB\",\"capacity\" : {\"capacityAmount\" : 8,\"resources\": [{\"id\": \"%s\"},{\"id\": \"F0001\"},{\"id\": \"F0002\"},{\"id\": \"F0003\"} ] }}".formatted(responseResource.getId()); + + ResourcePoolUpdate aResourcePoolUpd = JsonUtils.toJsonObj(resPooltext, ResourcePoolUpdate.class); + // @formatter:off + responseResourcePool = mvc + .perform(MockMvcRequestBuilders + .patch("/resourcePoolManagement/v1/resourcePool/" + responseRPool.getId()) + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( aResourcePoolUpd ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("testresponseResourcePoolCreate = " + responseResourcePool); + responseRPool = JsonUtils.toJsonObj(responseResourcePool, ResourcePool.class); + assertThat(responseRPool.getName()).isEqualTo("gNB"); + assertThat(responseRPool.getCapacity().getCapacityAmount()).isEqualTo(8); + assertThat(responseRPool.getCapacity().getResources().size()).isEqualTo(4); + + responseResourcePool = mvc + .perform(MockMvcRequestBuilders.get("/resourcePoolManagement/v1/resourcePool") + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(aResourcePoolUpd))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + List pools = JsonUtils.toJsonObj(responseResourcePool, ArrayList.class); + assertThat(pools.size()).isEqualTo(1); + + responseResourcePool = mvc + .perform(MockMvcRequestBuilders.get("/resourcePoolManagement/v1/resourcePool/" + responseRPool.getId()) + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(aResourcePoolUpd))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + responseRPool = JsonUtils.toJsonObj(responseResourcePool, ResourcePool.class); + assertThat(responseRPool.getName()).isEqualTo("gNB"); + assertThat(responseRPool.getCapacity().getCapacityAmount()).isEqualTo(8); + + /** + * Test reservations + */ + + // Create a reservation + String reserv = + "{"+ + " \"requestedPeriodEndDateTime\": \"2022-10-18T21:17:12.890623100Z\","+ + " \"requestedPeriodStartDateTime\": \"2022-10-11T21:17:12.890623100Z\","+ + " \"description\": \"new reservation\","+ + " \"relatedParty\": {"+ + " \"name\": \"Actor\""+ + " },"+ + " \"validFor\": {"+ + " \"endDateTime\": \"2022-10-18T21:17:12.890623100Z\","+ + " \"startDateTime\": \"2022-10-11T21:17:12.890623100Z\""+ + " },"+ + " \"reservationItem\": ["+ + " {"+ + " \"quantity\": 1,"+ + " \"resourceCapacity\": {"+ + " \"capacityDemandAmount\": 1,"+ + " \"resourcePool\": {"+ + " \"id\": \""+responseRPool.getId()+"\","+ + " \"resources\": ["+ + " {"+ + " \"id\": \""+responseResource.getId()+"\""+ + " }]"+ + " }"+ + " }"+ + " }"+ + " ],"+ + " \"serviceOrderRef\": {"+ + " \"id\": \"xxx\""+ + " }"+ + " }"; + + var rrc = JsonUtils.toJsonObj(reserv, ReservationCreate.class); + + // @formatter:off + String responseReservation = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/reservation") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( rrc ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("testresponseReservationCreate = " + responseReservation); + Reservation aReservation = JsonUtils.toJsonObj(responseReservation, Reservation.class); + + assertThat(aReservation.getId()).isNotNull(); + assertThat(aReservation.getDescription()).isEqualTo("new reservation"); + assertThat(aReservation.getReservationItem().stream().findFirst().get().getQuantity()).isEqualTo(1); + assertThat(aReservation.getReservationItem().stream().findFirst().get().getAppliedCapacityAmount().getResource() + .stream().findFirst().get().getId()).isEqualTo(responseResource.getId()); + + responseReservation = mvc + .perform(MockMvcRequestBuilders.get("/resourcePoolManagement/v1/reservation/" + aReservation.getId()) + .with(SecurityMockMvcRequestPostProcessors.csrf()).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(rrc))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("testresponseReservationPatch = " + responseReservation); + aReservation = JsonUtils.toJsonObj(responseReservation, Reservation.class); + + assertThat(aReservation.getId()).isNotNull(); + assertThat(aReservation.getDescription()).isEqualTo("new reservation"); + assertThat(aReservation.getReservationItem().stream().findFirst().get().getQuantity()).isEqualTo(1); + assertThat(aReservation.getReservationItem().stream().findFirst().get().getResourceCapacity() + .getCapacityDemandAmount()).isEqualTo(1); + assertThat(aReservation.getReservationItem().stream().findFirst().get().getResourceCapacity().getResourcePool() + .getResources().stream().findFirst().get().getId()).isEqualTo(responseResource.getId()); + assertThat(aReservation.getReservationItem().stream().findFirst().get().getAppliedCapacityAmount().getResource() + .stream().findFirst().get().getId()).isEqualTo(responseResource.getId()); + + // Push to pool + var resPoolPushtext = "{\"resourcePool\": {\"id\": \"%s\"},\"capacity\": {\"capacityAmount\": 2,\"resources\": [{\"id\": \"xxx\"},{\"id\": \"yyy\"}]}}".formatted(responseRPool.getId()); + + var aResourcePoolPush = JsonUtils.toJsonObj(resPoolPushtext, PushCreate.class); + logger.info("aResourcePoolPush JSON = " + JsonUtils.toJsonString(aResourcePoolPush)); + + // @formatter:off + String responseResourcePoolPush = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/push") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( aResourcePoolPush ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseResourcePoolPush = " + responseResourcePoolPush); + responseRPool = JsonUtils.toJsonObj(responseResourcePoolPush, ResourcePool.class); + + assertThat(responseRPool.getId()).isNotNull(); + assertThat(responseRPool.getName()).isEqualTo("gNB"); + assertThat(responseRPool.getCapacity().getCapacityAmount()).isEqualTo(10); + assertThat(responseRPool.getCapacity().getResources().size()).isEqualTo(6); + + // Extract from pool + var resExtrText = "{\"resourcePool\": {\"id\": \"%s\"},\"capacity\": {\"capacityAmount\": 2,\"resources\": [{\"id\": \"xxx\"},{\"id\": \"yyy\"}]}}".formatted(responseRPool.getId()); + + + var aResourcePoolExtract = JsonUtils.toJsonObj(resExtrText, ExtractCreate.class); + logger.info("aResourcePoolExtract JSON = " + JsonUtils.toJsonString(aResourcePoolExtract)); + + // @formatter:off + String responseResourcePoolExt = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/extract") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( aResourcePoolExtract ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseResourcePoolExt = " + responseResourcePoolExt); + responseRPool = JsonUtils.toJsonObj(responseResourcePoolExt, ResourcePool.class); + + assertThat(responseRPool.getId()).isNotNull(); + assertThat(responseRPool.getName()).isEqualTo("gNB"); + assertThat(responseRPool.getCapacity().getCapacityAmount()).isEqualTo(8); + assertThat(responseRPool.getCapacity().getResources().size()).isEqualTo(4); + + // Availability Check + // will check if there are free resources of specific amount under this pool + + AvailabilityCheck av = new AvailabilityCheck(); + ResourceCapacityDemand rcd = new ResourceCapacityDemand(); + rcd.setCapacityDemandAmount(1); + ApplicableTimePeriod aperiod = new ApplicableTimePeriod(); + aperiod.setFromDateTime(OffsetDateTime.now(ZoneOffset.UTC)); + aperiod.setEndDateTime(OffsetDateTime.now(ZoneOffset.UTC).plusDays(7)); + rcd.applicableTimePeriod(aperiod); + av.setResourceCapacityDemand(rcd); + ResourcePoolRef rpRef = new ResourcePoolRef(); + rpRef.setId(responseRPool.getId()); + rcd.setResourcePool(rpRef); + + String strav = JsonUtils.toJsonString(av); + logger.info("AvailabilityCheck JSON = " + strav); + + // @formatter:off + String responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + AvailabilityCheck respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, + AvailabilityCheck.class); + + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo( 4 ); + +// RelatedParty relatedParty = new RelatedParty(); +// relatedParty.setName("Actor"); +// ReservationCreate rrc = new ReservationCreate(); +// +// ResourceCapacityDemand resCapDem = new ResourceCapacityDemand(); +// ResourcePoolRef poolRef = new ResourcePoolRef(); +// poolRef.id(responseRPool.getId()); +// resCapDem.capacityDemandAmount("1").resourcePool(poolRef); +// +// ReservationItem resrvItem = new ReservationItem(); +// resrvItem.quantity(1).resourceCapacity(resCapDem); +// +// ServiceOrderRef soRef = new ServiceOrderRef(); +// soRef.id("xxx"); +// TimePeriod validFor = new TimePeriod(); +// validFor.startDateTime(OffsetDateTime.now(ZoneOffset.UTC)) +// .endDateTime(OffsetDateTime.now(ZoneOffset.UTC).plusDays(7)); +// +// rrc.description("new reservation").relatedParty(relatedParty).addReservationItemItem(resrvItem) +// .serviceOrderRef(soRef).validFor(validFor) +// .requestedPeriodStartDateTime(OffsetDateTime.now(ZoneOffset.UTC)) +// .requestedPeriodEndDateTime(OffsetDateTime.now(ZoneOffset.UTC).plusDays(7)); +// +// String rrcStr = JsonUtils.toJsonString(rrc); +// logger.info("ReservationCreate = " + rrcStr); + + } + + @WithMockUser(username = "osadmin", roles = { "USER", "ADMIN" }) + @Test + public void testFindResourceInPools() throws UnsupportedEncodingException, IOException, Exception { + + // Create a resource spec + 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); + + ResourceCreate aResource = new ResourceCreate(); + aResource.setName("gNB A Outdoor"); + aResource.setCategory("Experimentation"); + aResource.setAtType("PhysicalResource"); + ResourceSpecificationRef aServiceSpecificationRef = new ResourceSpecificationRef(); + aServiceSpecificationRef.setId(responsesSpec1.getId()); + aServiceSpecificationRef.setName(responsesSpec1.getName()); + aResource.setResourceSpecification(aServiceSpecificationRef); + Resource r1 = resourceRepoService.addResource(aResource); + ResourceRef rref1 = new ResourceRef(); + rref1.setId(r1.getId()); + rref1.setName( aResource.getName() ); + + + aResource.setName("gNB B Outdoor"); + Resource r1_gb = resourceRepoService.addResource(aResource); + ResourceRef rref1_gb = new ResourceRef(); + rref1_gb.setId(r1_gb.getId()); + rref1_gb.setName( aResource.getName() ); + + aResource.setName("gNB C Outdoor"); + Resource r1_gc = resourceRepoService.addResource(aResource); + ResourceRef rref1_gc = new ResourceRef(); + rref1_gc.setId(r1_gc.getId()); + rref1_gc.setName( aResource.getName() ); + + + + aResource.setName("gNB Indoor"); + Resource r2 = resourceRepoService.addResource(aResource); + ResourceRef rref2 = new ResourceRef(); + rref2.setId(r2.getId()); + + // create Pools + ResourcePoolCreate aResourcePool = new ResourcePoolCreate(); + aResourcePool.setName("Outdoors GNBs"); + Capacity cap = new Capacity(); + cap.addResourceRefItem(rref1); + cap.addResourceRefItem(rref1_gb); + cap.addResourceRefItem(rref1_gc); + aResourcePool.setCapacity(cap); + var rp1 = resourcePoolRepoService.addResourcePool(aResourcePool); + + aResourcePool.setName("Indoor GNBs"); + cap = new Capacity(); + cap.addResourceRefItem(rref2); + aResourcePool.setCapacity(cap); + var rp2 = resourcePoolRepoService.addResourcePool(aResourcePool); + + assertThat(rp1.getCapacity().getResources().size()).isEqualTo(3); + assertThat(rp2.getCapacity().getResources().size()).isEqualTo(1); + + Set refs = resourcePoolRepoService.findResourceRefinPools( rref1.getId() ); + assertThat(refs.size()).isEqualTo(1); + assertThat(refs.stream().findFirst().get().getId() ).isEqualTo( rp1.getId() ); + refs = resourcePoolRepoService.findResourceRefinPools( rref2.getId() ); + assertThat(refs.size()).isEqualTo(1); + assertThat(refs.stream().findFirst().get().getId() ).isEqualTo( rp2.getId() ); + + + //check availability of resource on a specific date then, e.g. R1 + + Set resourcePoolToCheck = resourcePoolRepoService.findResourceRefinPools( r1.getId() ); + ResourcePool rpool = resourcePoolToCheck.stream().findFirst().get(); + + AvailabilityCheck av = new AvailabilityCheck(); + ResourceCapacityDemand rcd = new ResourceCapacityDemand(); + rcd.setCapacityDemandAmount(1); + ApplicableTimePeriod aperiod = new ApplicableTimePeriod(); + OffsetDateTime startReservationDate = OffsetDateTime.now(ZoneOffset.UTC); + OffsetDateTime endReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(7) ; + + + aperiod.setFromDateTime( startReservationDate ); + aperiod.setEndDateTime( endReservationDate ); + rcd.applicableTimePeriod(aperiod); + av.setResourceCapacityDemand( rcd ); + ResourcePoolRef rpRef = new ResourcePoolRef(); + rpRef.setId( rpool.getId() ); + rcd.setResourcePool(rpRef); + Set resourcesToReserve = new HashSet<>(); + resourcesToReserve.add(rref1); + rcd.setResources( resourcesToReserve ); + String strav = JsonUtils.toJsonString(av); + logger.info("AvailabilityCheck JSON = " + strav); + + //no resource reservation yes, so this resource is available + // @formatter:off + String responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + AvailabilityCheck respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, AvailabilityCheck.class); + + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo(1); + + + //reserve this period. + + // Create a reservation + String reserv = + "{"+ + " \"requestedPeriodStartDateTime\": \""+ startReservationDate +"\","+ + " \"requestedPeriodEndDateTime\": \""+ endReservationDate +"\","+ + " \"description\": \"new reservation\","+ + " \"relatedParty\": {"+ + " \"name\": \"Actor\""+ + " },"+ + " \"reservationItem\": ["+ + " {"+ + " \"quantity\": 1,"+ + " \"resourceCapacity\": {"+ + " \"capacityDemandAmount\": 1,"+ + " \"resourcePool\": {"+ + " \"id\": \""+ rpool.getId()+"\","+ + " \"resources\": ["+ + " {"+ + " \"id\": \""+r1.getId()+"\""+ + " }]"+ + " }"+ + " }"+ + " }"+ + " ],"+ + " \"serviceOrderRef\": {"+ + " \"id\": \"xxx\""+ + " }"+ + " }"; + + var rrc = JsonUtils.toJsonObj(reserv, ReservationCreate.class); + + // @formatter:off + String responseReservation = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/reservation") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( rrc ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("testresponseReservationCreate = " + responseReservation); + Reservation aReservation = JsonUtils.toJsonObj(responseReservation, Reservation.class); + + assertThat(aReservation.getId()).isNotNull(); + assertThat(aReservation.getDescription()).isEqualTo("new reservation"); + assertThat(aReservation.getReservationItem().stream().findFirst().get().getQuantity()).isEqualTo(1); + + + //ask again for availability of this resource on this period. We should not get an availability + // @formatter:off + responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, AvailabilityCheck.class); + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo(0); // We should not get an availability + + + //ask again for availability of this resource in between period. We should NOT get an availability + + startReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(1); + endReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(5) ; + + aperiod.setFromDateTime( startReservationDate ); + aperiod.setEndDateTime( endReservationDate ); + rcd.applicableTimePeriod(aperiod); + av.setResourceCapacityDemand( rcd ); + strav = JsonUtils.toJsonString(av); + logger.info("AvailabilityCheck JSON = " + strav); + + // @formatter:off + responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, AvailabilityCheck.class); + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo(0); // We should get an availability + + //ask again for availability of this resource in period larger that includes other reservations. We should NOT get an availability + + startReservationDate = OffsetDateTime.now(ZoneOffset.UTC).minusDays(5); + endReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(10) ; + + aperiod.setFromDateTime( startReservationDate ); + aperiod.setEndDateTime( endReservationDate ); + rcd.applicableTimePeriod(aperiod); + av.setResourceCapacityDemand( rcd ); + strav = JsonUtils.toJsonString(av); + logger.info("AvailabilityCheck JSON = " + strav); + + // @formatter:off + responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, AvailabilityCheck.class); + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo(0); // We should get an availability + + + //ask again for availability of this resource in between period. We should NOT get an availability + + startReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(5); + endReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(10) ; + + aperiod.setFromDateTime( startReservationDate ); + aperiod.setEndDateTime( endReservationDate ); + rcd.applicableTimePeriod(aperiod); + av.setResourceCapacityDemand( rcd ); + strav = JsonUtils.toJsonString(av); + logger.info("AvailabilityCheck JSON = " + strav); + + // @formatter:off + responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, AvailabilityCheck.class); + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo(0); // We should get an availability + + //ask again for availability of this resource in between period. We should NOT get an availability + + startReservationDate = OffsetDateTime.now(ZoneOffset.UTC).minusDays(5); + endReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(1) ; + + aperiod.setFromDateTime( startReservationDate ); + aperiod.setEndDateTime( endReservationDate ); + rcd.applicableTimePeriod(aperiod); + av.setResourceCapacityDemand( rcd ); + strav = JsonUtils.toJsonString(av); + logger.info("AvailabilityCheck JSON = " + strav); + + // @formatter:off + responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, AvailabilityCheck.class); + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo(0); // We should get an availability + + //ask again for availability of this resource on a further period. We SHOULD GET an availability + + startReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(10); + endReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(12) ; + + aperiod.setFromDateTime( startReservationDate ); + aperiod.setEndDateTime( endReservationDate ); + rcd.applicableTimePeriod(aperiod); + av.setResourceCapacityDemand( rcd ); + strav = JsonUtils.toJsonString(av); + logger.info("AvailabilityCheck JSON = " + strav); + + // @formatter:off + responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, AvailabilityCheck.class); + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo(1); // We should get an availability + + + //ask again for availability of two resources of this pool in between period. We should get only 1 RESOURCE availability + + startReservationDate = OffsetDateTime.now(ZoneOffset.UTC).minusDays(5); + endReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(1) ; + + aperiod.setFromDateTime( startReservationDate ); + aperiod.setEndDateTime( endReservationDate ); + rcd.applicableTimePeriod(aperiod); + av.setResourceCapacityDemand( rcd ); + resourcesToReserve = new HashSet<>(); + resourcesToReserve.add(rref1); + resourcesToReserve.add(rref1_gb); + rcd.setResources( resourcesToReserve ); + + strav = JsonUtils.toJsonString(av); + logger.info("AvailabilityCheck JSON = " + strav); + + // @formatter:off + responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, AvailabilityCheck.class); + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo( 1 ); // We should get an availability + for (ResourceRef resourceRef : respAvailabilityCheck.getAvailableResources()) { + logger.info("responseAvailabilityCheckresourceRef = " + resourceRef.getName()); + + } + + + //ask again for availability of any resource of this resource pool in between period. We should get 2 RESOURCES availability + + startReservationDate = OffsetDateTime.now(ZoneOffset.UTC).minusDays(5); + endReservationDate = OffsetDateTime.now(ZoneOffset.UTC).plusDays(1) ; + + aperiod.setFromDateTime( startReservationDate ); + aperiod.setEndDateTime( endReservationDate ); + rcd.applicableTimePeriod(aperiod); + av.setResourceCapacityDemand( rcd ); + rcd.setResources( null ); //THIS SIGNALS TO CHECK ALL RESOURCES OF THIS POOL + strav = JsonUtils.toJsonString(av); + logger.info("AvailabilityCheck JSON = " + strav); + + // @formatter:off + responseAvailabilityCheck = mvc + .perform(MockMvcRequestBuilders + .post("/resourcePoolManagement/v1/availabilityCheck") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson( av ))) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + // @formatter:on + logger.info("responseAvailabilityCheck = " + responseAvailabilityCheck); + respAvailabilityCheck = JsonUtils.toJsonObj(responseAvailabilityCheck, AvailabilityCheck.class); + assertThat(respAvailabilityCheck.getAvailableResources().size()).isEqualTo( 2 ); // We should get an availability + for (ResourceRef resourceRef : respAvailabilityCheck.getAvailableResources()) { + logger.info("responseAvailabilityCheckresourceRef = " + resourceRef.getName()); + + } + } + + private ResourceSpecification createResourceSpec(ResourceSpecificationUpdate sspeccr1) throws Exception { + + URI url = new URI("/resourceCatalogManagement/v4/resourceSpecification"); + + String responseSpec = mvc + .perform(MockMvcRequestBuilders.post(url).with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(sspeccr1))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + ResourceSpecification responsesSpec1; + if (sspeccr1.getType().toLowerCase().contains("physicalresource")) { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, PhysicalResourceSpecification.class); + } else { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + } + +// logger.info("createResourceSpec = " + responseSpec); + return responsesSpec1; + } +} diff --git a/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..511e46c84b9ab994d590da4509d15973b09554c7 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ServiceCatalogIntegrationTest.java @@ -0,0 +1,1252 @@ +/*- + * ========================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.services.api; + + + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.is; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.BootstrapRepository; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.common.model.AttachmentRef; +import org.etsi.osl.tmf.common.model.EValueType; +import org.etsi.osl.tmf.common.model.Quantity; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.pm632.model.Organization; +import org.etsi.osl.tmf.pm632.model.OrganizationCreate; +import org.etsi.osl.tmf.pm632.reposervices.OrganizationRepoService; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.scm633.model.ServiceCandidateRef; +import org.etsi.osl.tmf.scm633.model.ServiceCatalog; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCatalogUpdate; +import org.etsi.osl.tmf.scm633.model.ServiceCategory; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryCreate; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryRef; +import org.etsi.osl.tmf.scm633.model.ServiceCategoryUpdate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharRelationship; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristic; +import org.etsi.osl.tmf.scm633.model.ServiceSpecCharacteristicValue; +import org.etsi.osl.tmf.scm633.model.ServiceSpecRelationship; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationUpdate; +import org.etsi.osl.tmf.scm633.reposervices.CandidateRepoService; +import org.etsi.osl.tmf.scm633.reposervices.CatalogRepoService; +import org.etsi.osl.tmf.scm633.reposervices.CategoryRepoService; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.JsonUtils; + +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.mock.web.MockMultipartFile; +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; +import net.minidev.json.JSONObject; + + +@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 ServiceCatalogIntegrationTest { + + + private static final transient Log logger = LogFactory.getLog( ServiceCatalogIntegrationTest.class.getName()); + + private static final int FIXED_BOOTSTRAPS_SPECS = 1; + + @Autowired + private MockMvc mvc; + + @Autowired + CatalogRepoService catalogRepoService; + + + @Autowired + CategoryRepoService categRepoService; + + @Autowired + ServiceSpecificationRepoService specRepoService; + + @Autowired + CandidateRepoService candidateRepoService; + + @Autowired + private WebApplicationContext context; + + @Autowired + private BootstrapRepository bootstrapRepository; + + + @Autowired + OrganizationRepoService organizationRepoService; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + @Test + public void _countDefaultProperties() { + + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 1 ); + assertThat( categRepoService.findAll().size() ).isEqualTo( 1 ); + assertThat( candidateRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + + assertThat( catalogRepoService.findByName( "Catalog" ) ).isNotNull() ; + assertThat( categRepoService.findByName( "Generic Services" ) ).isNotNull() ; + + ServiceCategory categ = categRepoService.findByName( "Generic Services" ); + assertThat( categ.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + + ServiceCategory categ2 = categRepoService.findByIdEager( categ.getId() ); + assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + + boolean vinnisbFound = false; + boolean gstFound = false; + for (ServiceCandidateRef scr : categ.getServiceCandidateRefs()) { + if (scr.getName().equals( "A GST(NEST) Service Example" )) { + gstFound = true; + } + if (scr.getName().equals( "A VINNI Service Example" )) { + vinnisbFound = true; + } + } + + assertThat( gstFound ).isTrue(); + //assertThat( vinnisbFound ).isTrue(); + + + + } + + @Test + public void givenRequestOnPrivateService_shouldFailWith401() throws Exception { +// mvc.perform(post("/serviceCatalogManagement/v4/serviceCatalog") +// .contentType(MediaType.APPLICATION_JSON)) +// .andExpect(status().isUnauthorized()); + } + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void addCatalogAddCategory() throws Exception { + File scatalog = new File( "src/test/resources/testServiceCatalog.txt" ); + InputStream in = new FileInputStream( scatalog ); + String resvxf = IOUtils.toString(in, "UTF-8"); + + ServiceCatalogCreate scc = JsonUtils.toJsonObj( resvxf, ServiceCatalogCreate.class); + + String response = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceCatalog") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scc ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Catalog"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 2 ); + + ServiceCatalog responsesCatalog = JsonUtils.toJsonObj(response, ServiceCatalog.class); + assertThat( responsesCatalog.getName() ).isEqualTo( "Test Catalog" ); + + assertThat( responsesCatalog.getCategoryObj().size()).isEqualTo(0); + + + /** + * add category + */ + + File scat = new File( "src/test/resources/testServiceCategory.txt" ); + in = new FileInputStream( scat ); + String sc = IOUtils.toString(in, "UTF-8"); + + ServiceCategoryCreate scategcreate = JsonUtils.toJsonObj( sc, ServiceCategoryCreate.class); + + response = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceCategory") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scategcreate ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Category 2"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( categRepoService.findAll().size() ).isEqualTo( 2 ); + + ServiceCategory responsesCateg = JsonUtils.toJsonObj(response, ServiceCategory.class); + assertThat( responsesCateg.getName() ).isEqualTo( "Test Category 2" ); + + + /** + * update catalog with category + */ + ServiceCatalogUpdate scu = new ServiceCatalogUpdate(); + scu.setName( responsesCatalog.getName() ); + ServiceCategoryRef categoryItem = new ServiceCategoryRef(); + categoryItem.setId( responsesCateg.getId() ); + + scu.addCategoryItem(categoryItem); + response = mvc.perform(MockMvcRequestBuilders.patch("/serviceCatalogManagement/v4/serviceCatalog/" + responsesCatalog.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scu ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Catalog"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 2 ); + + responsesCatalog = JsonUtils.toJsonObj(response, ServiceCatalog.class); + assertThat(responsesCatalog.getName()).isEqualTo("Test Catalog"); + + + assertThat( responsesCatalog.getCategoryObj().size()).isEqualTo(1); + assertThat( responsesCatalog.getCategoryRefs().get(0).getName() ).isEqualTo( "Test Category 2" ); + + /** + * Service Spec + */ + File sspec = new File( "src/test/resources/testServiceSpec.json" ); + in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ServiceSpecificationCreate sspeccr = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + + response = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Spec"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS +1 ); + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + assertThat( responsesSpec.getName() ).isEqualTo( "Test Spec" ); + + assertThat( responsesSpec.getServiceSpecCharacteristic().size() ).isEqualTo(2); + assertThat( responsesSpec.getServiceSpecCharacteristic().toArray( new ServiceSpecCharacteristic[0] )[0].getServiceSpecCharacteristicValue().size() ).isEqualTo(1); + + + + + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void manageCategoriesSubCategories() throws Exception { + /** + * add category + */ + + File scat = new File( "src/test/resources/testServiceCategory.txt" ); + InputStream in = new FileInputStream( scat ); + String sc = IOUtils.toString(in, "UTF-8"); + + ServiceCategoryCreate scategcreate = JsonUtils.toJsonObj( sc, ServiceCategoryCreate.class); + scategcreate.setIsRoot(true); + ServiceCategory parentRootCategory = postCategory( scategcreate, scategcreate.getName() ); + + ServiceCategoryCreate scategcreate2 = JsonUtils.toJsonObj( sc, ServiceCategoryCreate.class); + scategcreate2.setName("Child Cat"); + ServiceCategory child1Subcategory = postCategory( scategcreate2, scategcreate2.getName() ); + + ServiceCategoryUpdate scUpd1 = JsonUtils.toJsonObj( sc, ServiceCategoryUpdate.class); + scUpd1.setIsRoot(true); + scUpd1.setName("Parent Cat"); + ServiceCategoryRef scRef = new ServiceCategoryRef(); + scRef.setId( child1Subcategory.getId() ); + scRef.setName( child1Subcategory.getName() ); + scUpd1.addCategoryItem(scRef); + + + assertThat( categRepoService.findAll().size() ).isEqualTo( 3 ); + + String response = mvc.perform(MockMvcRequestBuilders.patch("/serviceCatalogManagement/v4/serviceCategory/" + parentRootCategory.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is( "Parent Cat" ))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + parentRootCategory = JsonUtils.toJsonObj(response, ServiceCategory.class); + + + assertThat( categRepoService.findAll().size() ).isEqualTo( 3 ); + assertThat( parentRootCategory.getCategoryRefs().size() ).isEqualTo(1); + assertThat( parentRootCategory.getCategoryRefs().get(0).getId() ).isEqualTo( child1Subcategory.getId() ); + + + /** + * add to a service catalog and delete the service catalog, to check that categories are still there + * + */ + + ServiceCatalog catalog = catalogRepoService.findByName( "Catalog" ); + assertThat( catalog.getCategoryRefs().size() ).isEqualTo( 1 ); + ServiceCatalogUpdate scu = new ServiceCatalogUpdate(); + scu.setName( catalog.getName() ); + for (ServiceCategoryRef iref : catalog.getCategoryRefs()) { + scu.addCategoryItem( iref ); + } + ServiceCategoryRef categoryItem = new ServiceCategoryRef(); + categoryItem.setId( parentRootCategory.getId() ); + scu.addCategoryItem( categoryItem ); + catalog = catalogRepoService.updateCatalog( catalog.getId(), scu); + + assertThat( catalog.getCategoryRefs().size() ).isEqualTo( 2 ); + assertThat( categRepoService.findAll().size() ).isEqualTo( 3 ); + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 1 ); + catalogRepoService.deleteById( catalog.getId() );//delete + assertThat( catalogRepoService.findAll().size() ).isEqualTo( 0 ); + assertThat( categRepoService.findAll().size() ).isEqualTo( 3 );//categories must remain + + + //fetch the subcategory and check parent ID + + response = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceCategory/" + parentRootCategory.getCategoryRefs().get(0).getId() ) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andReturn().getResponse().getContentAsString(); + + child1Subcategory = JsonUtils.toJsonObj(response, ServiceCategory.class); + + assertThat( child1Subcategory.getParentId() ).isEqualTo( parentRootCategory.getId() ); + + //delete category with childs not allows (not modified) + response = mvc.perform(MockMvcRequestBuilders.delete("/serviceCatalogManagement/v4/serviceCategory/" + parentRootCategory.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isNotModified() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( categRepoService.findAll().size() ).isEqualTo( 3 ); + + //delete subcategory + response = mvc.perform(MockMvcRequestBuilders.delete("/serviceCatalogManagement/v4/serviceCategory/" + parentRootCategory.getCategoryRefs().get(0).getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( categRepoService.findAll().size() ).isEqualTo( 2 ); + + //delete rootcategory + response = mvc.perform(MockMvcRequestBuilders.delete("/serviceCatalogManagement/v4/serviceCategory/" + parentRootCategory.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scUpd1 ) )) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( categRepoService.findAll().size() ).isEqualTo( 1 ); + + } + + private ServiceCategory postCategory(ServiceCategoryCreate scategcreate, String name) throws UnsupportedEncodingException, IOException, Exception { + + String response = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceCategory") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scategcreate ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is( name ))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ServiceCategory responsesCateg = JsonUtils.toJsonObj(response, ServiceCategory.class); + + return responsesCateg; + } + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testSpecAttributesUpdate() throws Exception { + logger.info("Test: testSpecAttributesUpdate"); + /** + * Service Spec + */ + File sspec = new File( "src/test/resources/testServiceSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ServiceSpecificationCreate sspeccr = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + + AttachmentRef attachmentItem = new AttachmentRef(); + attachmentItem.setId( "a-ref-id" ); + attachmentItem.setDescription("an attachment"); + attachmentItem.setUrl("a url"); + attachmentItem.setName("a url"); + sspeccr.addAttachmentItem(attachmentItem); + String responseSpec = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Spec"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(responseSpec, ServiceSpecification.class); + logger.info("Test: testSpecAttachments response = " + responseSpec); + assertThat( responsesSpec.getName() ).isEqualTo( "Test Spec" ); + assertThat( responsesSpec.getAttachment().size() ).isEqualTo( 1 ); + + //make it now as a ServiceSpecificationUpdate, no id, uuid and lastUpdate + JSONObject obj = JsonUtils.toJsonObj(responseSpec, JSONObject.class); + obj.remove("uuid"); + obj.remove("id"); + obj.remove("lastUpdate"); + responseSpec = JsonUtils.toJsonString(obj); + + ServiceSpecificationUpdate responsesSpecUpd = JsonUtils.toJsonObj(responseSpec, ServiceSpecificationUpdate.class); + responsesSpecUpd.setName( "Test Spec a attr" ); + responsesSpecUpd.setVersion("2.x"); + ServiceSpecCharacteristic spechar = new ServiceSpecCharacteristic(); + spechar.setName("A new characteristic"); + ServiceSpecCharacteristicValue sv = new ServiceSpecCharacteristicValue(); + sv.setValue( new Any("1" ,"a first value") ); + sv.setValueType( EValueType.LONGTEXT.getValue()); + spechar.getServiceSpecCharacteristicValue().add( sv ); + responsesSpecUpd.getServiceSpecCharacteristic().add(spechar ); + + String response2 = mvc.perform(MockMvcRequestBuilders.patch("/serviceCatalogManagement/v4/serviceSpecification/" + responsesSpec.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( responsesSpecUpd ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Spec a attr"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + ServiceSpecification responsesSpec2 = JsonUtils.toJsonObj(response2, ServiceSpecification.class); + assertThat( responsesSpec2.getName() ).isEqualTo( "Test Spec a attr" ); + assertThat( responsesSpec2.getVersion() ).isEqualTo( "2.x" ); + assertThat( responsesSpec2.getServiceSpecCharacteristic().size() ).isEqualTo(3); + assertThat( responsesSpec2.getServiceSpecCharacteristic().toArray( new ServiceSpecCharacteristic[0] )[0].getServiceSpecCharacteristicValue().size() ).isEqualTo(1); + assertThat( responsesSpec2.findSpecCharacteristicByName("Coverage") ).isNotNull(); + assertThat( responsesSpec2.findSpecCharacteristicByName("A new characteristic") ).isNotNull(); + assertThat( responsesSpec2.findSpecCharacteristicByName("Coverage").getServiceSpecCharacteristicValue().size() ).isEqualTo(1); + assertThat( responsesSpec2.findSpecCharacteristicByName("A new characteristic").getServiceSpecCharacteristicValue().toArray( new ServiceSpecCharacteristicValue[0] )[0].getValue().getAlias() ).isEqualTo("a first value"); + assertThat( responsesSpec2.findSpecCharacteristicByName("A new characteristic").getServiceSpecCharacteristicValue().toArray( new ServiceSpecCharacteristicValue[0] )[0].getValueType() ).isEqualTo("LONGTEXT"); + assertThat( responsesSpec2.findSpecCharacteristicByName("Coverage").getServiceSpecCharRelationship().size() ).isEqualTo(4); + + + logger.info("Test: testSpecAttachments responsesSpec2 patch1= " + response2.toString()); + + //test now update and delete things + responsesSpecUpd = JsonUtils.toJsonObj(responseSpec, ServiceSpecificationUpdate.class); + ServiceSpecCharacteristicValue val = new ServiceSpecCharacteristicValue(); + val.setValueType( EValueType.ARRAY.toString()); + val.setValue( new Any("1" ,"a second value") ); + + // Following code related to 'notNullRelationshipIndex' is to fix random test failures due to getServiceSpecCharacteristic + // not having 3 ServiceSpecCharRelationships + int notNullRelationshipIndex = 0; + for (int i=0; i()).size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); //this is somehow wrong in Testing ONLY + + + /** + * + */ + + String responseSpecs = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification?fields=serviceCandidateObjId") + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + List specs = JsonUtils.toJsonObj( responseSpecs, ArrayList.class ); + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS +1 ); + assertThat( specRepoService.findAll(null , new HashMap<>()).size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); //this is somehow wrong it should be 2..anyway to investigate in future + assertThat(specs.size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ) ; + + + + /** + * + */ + + String responseSpecsFilter = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification?fields=serviceCandidateObjId&name=A%20GST(NEST)%20Service%20Example") + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + List specsFilter = JsonUtils.toJsonObj( responseSpecsFilter, ArrayList.class ); + + + assertThat(specsFilter.size() ).isEqualTo(1) ; + } + + @WithMockUser(username="osadmin", roles = {"USER"}) + @Test + public void testGSTUpdate() throws Exception { + logger.info("Test: testGSTUpdate " ); + + ServiceCategory categ = categRepoService.findByName( "Generic Services" ); + ServiceCategory categ2 = categRepoService.findByIdEager( categ.getId() ); + assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + + ServiceSpecification spec = this.specRepoService.findByNameAndVersion("A GST(NEST) Service Example", "5.0.0" ); + assertThat( spec ).isNotNull(); + + spec.setVersion("0.x.0"); + this.specRepoService.updateServiceSpecification( spec); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + + this.bootstrapRepository.initRepo(); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS +1 ); + + + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testVINNISBT() throws Exception { + logger.info("Test: testVINNISBT " ); + + /** + * first add + */ + + File sspec = new File( "src/main/resources/vinnisb/vinnisb.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ServiceSpecificationCreate sspeccr1 = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + sspeccr1.setName( sspeccr1.getName()+"_acopy_" ); + String responseSpec1 = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + ServiceSpecification responsesSpec1 = JsonUtils.toJsonObj(responseSpec1, ServiceSpecification.class); + + logger.info("Test: testBundledSpec responseSpec1 = " + responseSpec1); + + assertThat( responsesSpec1.getVersion() ).isEqualTo("0.1.0"); + assertThat( responsesSpec1.getServiceSpecCharacteristic().size() ).isEqualTo(2); + assertThat( responsesSpec1.getServiceSpecRelationship().size() ).isEqualTo(0); + boolean userPartyRoleOwnerexists = false; + for (RelatedParty r : responsesSpec1.getRelatedParty()) { + if ( r.getName().equals( "osadmin" ) && r.getRole().equals( UserPartRoleType.OWNER.toString() )) { + userPartyRoleOwnerexists = true; + } + } + + assertThat(userPartyRoleOwnerexists ).isTrue() ; + 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 it should be 2..anyway to investigate in future..something is happening with Session factory + + + /** + * + */ + + String responseSpecs = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification?fields=serviceCandidateObjId") + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + List specs = JsonUtils.toJsonObj( responseSpecs, ArrayList.class ); + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS +1 ); + assertThat( specRepoService.findAll( null, new HashMap<>()).size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); //this is somehow wrong it should be 2..anyway to investigate in future + assertThat(specs.size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ) ; + + + + /** + * + */ + + String responseSpecsFilter = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification?fields=serviceCandidateObjId&name=A%20VINNI%20Service%20Example") + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + List specsFilter = JsonUtils.toJsonObj( responseSpecsFilter, ArrayList.class ); + + + assertThat(specsFilter.size() ).isEqualTo(0) ; + } + + @WithMockUser(username="osadmin", roles = {"USER"}) + @Test + public void testVINNISBTUpdate() throws Exception { +// logger.info("Test: testVINNISBTUpdate " ); +// +// ServiceCategory categ = categRepoService.findByName( "Generic Services" ); +// ServiceCategory categ2 = categRepoService.findByIdEager( categ.getId() ); +// assertThat( categ2.getServiceCandidateRefs().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); +// +// ServiceSpecification spec = this.specRepoService.findByNameAndVersion("A VINNI Service Example", "0.1.0" ); +// assertThat( spec ).isNotNull(); +// +// spec.setVersion("0.x.0"); +// this.specRepoService.updateServiceSpecification( spec); +// +// assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); +// +// this.bootstrapRepository.initRepo(); +// +// assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 11 ); +// assertThat( candidateRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 11 ); + + + + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testSpecDelete() throws Exception { + + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + + /** + * first add 1 specs + */ + + File sspec = new File( "src/test/resources/testServiceSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + + ServiceSpecificationCreate sspeccr1 = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + sspeccr1.setName("Spec1"); + ServiceSpecification responsesSpec1 = createServiceSpec(sspectext, sspeccr1); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1 ); + + + this.specRepoService.deleteByUuid( responsesSpec1.getId() ); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN", "USER"}) + @Test + public void testExternhalSpecUpdate() throws Exception { + + /** + * first add 1 specs + */ + + File sspec = new File( "src/test/resources/testServiceSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + + ServiceSpecificationCreate sspeccr1 = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + sspeccr1.setName("Spec1"); + ServiceSpecification responsesSpec1 = createServiceSpec(sspectext, sspeccr1); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1 ); + assertThat( responsesSpec1.getServiceSpecCharacteristic()).hasSize(2) ; + + /** + * we use responsesSpec1 as base to add another ServiceSpecification example from an external partner + */ + String externaluuid = UUID.randomUUID().toString(); + responsesSpec1.setUuid( externaluuid ); //change this as external + responsesSpec1.getRelatedParty().clear();//clear all related parties if any + + /** + * add to the spec, an organization as related party + */ + + + @Valid + OrganizationCreate organizationCreate = new OrganizationCreate(); + organizationCreate.setName("ANORGZ"); + Organization o = organizationRepoService.addOrganization(organizationCreate); + + ServiceSpecification specupd = specRepoService.updateExternalServiceSpec(externaluuid, o.getId(), responsesSpec1); + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 2 ); + assertThat( specupd.getRelatedParty()).hasSize(1); + assertThat( specupd.getServiceSpecCharacteristic()).hasSize(2) ; + + responsesSpec1.setName( responsesSpec1.getName() + "_NEWNAME"); + + ServiceSpecCharacteristic serviceSpecCharacteristicItem = new ServiceSpecCharacteristic(); + serviceSpecCharacteristicItem.setName("A Second Attribute"); + responsesSpec1.addServiceSpecCharacteristicItem(serviceSpecCharacteristicItem ); + specupd = specRepoService.updateExternalServiceSpec(externaluuid, o.getId(), responsesSpec1); + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 2 ); + assertThat( specupd.getRelatedParty()).hasSize(1); + assertThat( specupd.getServiceSpecCharacteristic()).hasSize( 3 ) ; + assertThat( specupd.getName() ).isEqualTo( responsesSpec1.getName() ) ; + + + } + + private LogicalResourceSpecification createLogicalResourceSpec() throws Exception{ + 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); + + URI url = new URI("/resourceCatalogManagement/v4/logicalResourceSpec"); + + String responseSpec = mvc.perform(MockMvcRequestBuilders.post( url ) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + LogicalResourceSpecification responsesSpec1; + + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + + logger.info("createResourceSpec = " + responseSpec); + return responsesSpec1; + } + + + +} diff --git a/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..16ad168abce52debb68d788ab7467a9a0ea096dd --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ServiceInventoryIntegrationTest.java @@ -0,0 +1,380 @@ +/*- + * ========================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.services.api; + + + +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; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.common.model.service.Characteristic; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; +import org.etsi.osl.tmf.common.model.service.ServiceStateType; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.scm633.reposervices.CatalogRepoService; +import org.etsi.osl.tmf.scm633.reposervices.CategoryRepoService; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceActionQueueAction; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import org.etsi.osl.tmf.JsonUtils; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.context.WebApplicationContext; + + +@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 ServiceInventoryIntegrationTest { + + + private static final transient Log logger = LogFactory.getLog( ServiceInventoryIntegrationTest.class.getName()); + + @Autowired + private MockMvc mvc; + + @Autowired + CatalogRepoService catalogRepoService; + + + @Autowired + CategoryRepoService categRepoService; + + @Autowired + ServiceSpecificationRepoService specRepoService; + + + @Autowired + ServiceRepoService serviceRepoService; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + @Test + public void _countDefaultProperties() { + + assertThat( serviceRepoService.findAll().size() ).isEqualTo( 0 ); + + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testServiceCreateAndUpdate() throws UnsupportedEncodingException, IOException, Exception { + + /** + * first add 2 specs + */ + + File sspec = new File( "src/test/resources/testServiceSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + + ServiceSpecificationCreate sspeccr1 = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + sspeccr1.setName("Spec1"); + ServiceSpecification responsesSpec1 = createServiceSpec(sspectext, sspeccr1); + + //service 2 is an RFS + ServiceSpecificationCreate sspeccr2 = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + sspeccr2.setName("Spec2"); + ResourceSpecificationRef resourceSpecificationItem = new ResourceSpecificationRef(); + resourceSpecificationItem.setId("resourceid"); + resourceSpecificationItem.setName("resourceName"); + sspeccr2.addResourceSpecificationItem(resourceSpecificationItem); + ServiceSpecification responsesSpec2 = createServiceSpec(sspectext, sspeccr2); + /** + * add them as bundle + */ + + ServiceSpecificationCreate sspeccr3 = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + sspeccr3.setName("BundleExampleSpec"); + sspeccr3.isBundle(true); + sspeccr3.addServiceSpecRelationshipWith( responsesSpec1 ); + sspeccr3.addServiceSpecRelationshipWith( responsesSpec2 ); + ServiceSpecification responsesSpec3 = createServiceSpec(sspectext, sspeccr3); + + ServiceCreate aService = new ServiceCreate(); + aService.setName("aNew Service"); + aService.setCategory("Experimentation"); + aService.setDescription("Experimentation Descr"); + aService.setStartDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + aService.setEndDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + + Note noteItem = new Note(); + noteItem.text("test note"); + aService.addNoteItem(noteItem); + + Characteristic serviceCharacteristicItem = new Characteristic(); + + serviceCharacteristicItem.setName( "ConfigStatus" ); + serviceCharacteristicItem.setValue( new Any("NONE")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "NSLCM" ); + serviceCharacteristicItem.setValue( new Any("nslcm_test")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "NSR" ); + serviceCharacteristicItem.setValue( new Any("nsr_test")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + ServiceSpecificationRef aServiceSpecificationRef = new ServiceSpecificationRef(); + aServiceSpecificationRef.setId(responsesSpec3.getId() ); + aServiceSpecificationRef.setName(responsesSpec3.getName()); + + aService.setServiceSpecificationRef(aServiceSpecificationRef ); + + logger.info("aService JSON = " + JsonUtils.toJsonString( aService )); + + String responseService = mvc.perform(MockMvcRequestBuilders.post("/serviceInventory/v4/service") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( aService ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + logger.info("testServiceOrderCreate = " + responseService); + Service responseSrvc = JsonUtils.toJsonObj( responseService, Service.class); + + + logger.info("testService = " + JsonUtils.toJsonString( responseSrvc )); + + + assertThat( responseSrvc.getCategory() ).isEqualTo( "Experimentation" ); + assertThat( responseSrvc.getDescription() ).isEqualTo( "Experimentation Descr" ); + assertThat( responseSrvc.getStartDate() ).isNotNull(); + assertThat( responseSrvc.getEndDate() ).isNotNull(); + assertThat( responseSrvc.getServiceCharacteristic().size() ).isEqualTo( 3 ); + assertThat( responseSrvc.getServiceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "NONE" ) ; + + + assertThat( responseSrvc.getNote().size() ).isEqualTo( 2 ); + + boolean userPartyRoleexists = false; + for (RelatedParty r : responseSrvc.getRelatedParty()) { + if ( r.getName().equals( "osadmin" ) && r.getRole().equals( UserPartRoleType.REQUESTER.toString() )) { + userPartyRoleexists = true; + } + } + + assertThat(userPartyRoleexists ).isTrue() ; + + assertThat( serviceRepoService.findAll().size() ).isEqualTo( 1 ); + + + ServiceUpdate servUpd = new ServiceUpdate(); + servUpd.setEndDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + responseSrvc.getNote().stream().forEach(n -> servUpd.addNoteItem(n)); + Note en = new Note(); + en.text("test note2"); + en.setDate( OffsetDateTime.now(ZoneOffset.UTC).toString() ); + servUpd.addNoteItem(en); + + for (Characteristic c : responseSrvc.getServiceCharacteristic()) { + if (c.getName().equals( "ConfigStatus" )) { + c.setValue( new Any("RUNNING")); + } + servUpd.addServiceCharacteristicItem(c); + } + servUpd.setState( ServiceStateType.ACTIVE ); + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "DeploymentRequestID" ); + serviceCharacteristicItem.setValue( new Any("1007")); + servUpd.addServiceCharacteristicItem(serviceCharacteristicItem); + + + + String responseSorderUpd = mvc.perform(MockMvcRequestBuilders.patch("/serviceInventory/v4/service/" + responseSrvc.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( servUpd ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + logger.info("testServiceOrderUpdate = " + responseSorderUpd); + Service responseSOUpd = JsonUtils.toJsonObj(responseSorderUpd, Service.class); + + + assertThat( serviceRepoService.findAll().size() ).isEqualTo( 1 ); + + assertThat( responseSOUpd.getEndDate() ).isNotNull(); + assertThat( responseSOUpd.getNote().size() ).isEqualTo( 5 ); + assertThat( responseSOUpd.getServiceCharacteristic().size() ).isEqualTo( 4 ); + assertThat( responseSOUpd.getServiceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "RUNNING" ) ; + assertThat( responseSOUpd.getServiceCharacteristicByName( "DeploymentRequestID" ).getValue().getValue() ).isEqualTo( "1007" ) ; + + + + +// responseSorderUpd = mvc.perform(MockMvcRequestBuilders.get("/serviceInventory/v4/service/updateServiceDeploymentDescriptor/1007" ) +// .with( SecurityMockMvcRequestPostProcessors.csrf()) +// .contentType(MediaType.APPLICATION_JSON) +// .content( JsonUtils.toJson( servUpd ) )) +// .andExpect(status().isOk()) +// .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) +// .andExpect(status().isOk()) +// .andReturn().getResponse().getContentAsString(); +// logger.info("testServiceOrderUpdate = " + responseSorderUpd); +// responseSOUpd = JsonUtils.toJsonObj(responseSorderUpd, Service.class); +// assertThat( responseSOUpd.getServiceCharacteristic().size() ).isEqualTo( 4 ); +// assertThat( responseSOUpd.getNote().size() ).isEqualTo( 5 ); + + + + servUpd.setState( ServiceStateType.INACTIVE ); + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "DeploymentRequestID" ); + serviceCharacteristicItem.setValue( new Any("1007")); + servUpd.addServiceCharacteristicItem(serviceCharacteristicItem); + + + + responseSorderUpd = mvc.perform(MockMvcRequestBuilders.patch("/serviceInventory/v4/service/" + responseSrvc.getId() ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( servUpd ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + logger.info("testServiceOrderUpdate = " + responseSorderUpd); + responseSOUpd = JsonUtils.toJsonObj(responseSorderUpd, Service.class); + + + assertThat( serviceRepoService.findAll().size() ).isEqualTo( 1 ); + + assertThat( responseSOUpd.getEndDate() ).isNotNull(); + assertThat( responseSOUpd.getNote().size() ).isEqualTo( 7 ); + assertThat( responseSOUpd.getServiceCharacteristic().size() ).isEqualTo( 4 ); + assertThat( responseSOUpd.getServiceCharacteristicByName( "ConfigStatus" ).getValue().getValue() ).isEqualTo( "RUNNING" ) ; + assertThat( responseSOUpd.getServiceCharacteristicByName( "DeploymentRequestID" ).getValue().getValue() ).isEqualTo( "1007" ) ; + + + assertThat( serviceRepoService.findAllServiceActionQueueItems().size() ).isEqualTo( 3 ); + assertThat( serviceRepoService.findAllServiceActionQueueItems().get(0).getAction() ).isEqualTo(ServiceActionQueueAction.EVALUATE_STATE_CHANGE_TOACTIVE ); + + } + + + private ServiceSpecification createServiceSpec(String sspectext, ServiceSpecificationCreate sspeccr1) throws Exception{ + + String responseSpec = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + ServiceSpecification responsesSpec1 = JsonUtils.toJsonObj(responseSpec, ServiceSpecification.class); + logger.info("createServiceSpec = " + responseSpec); + return responsesSpec1; + } + + + + + private LogicalResourceSpecification createLogicalResourceSpec() throws Exception{ + 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); + + URI url = new URI("/resourceCatalogManagement/v4/logicalResourceSpec"); + + String responseSpec = mvc.perform(MockMvcRequestBuilders.post( url ) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + LogicalResourceSpecification responsesSpec1; + + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + + logger.info("createResourceSpec = " + responseSpec); + return responsesSpec1; + } + + + +} diff --git a/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..017804bfc044adbd710d2f7999d0fc1dc7696406 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ServiceOrderIntegrationTest.java @@ -0,0 +1,438 @@ +/*- + * ========================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.services.api; + +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; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.List; + +import org.apache.camel.CamelContext; +import org.apache.camel.RoutesBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.common.model.service.Characteristic; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.common.model.service.ServiceRef; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.scm633.reposervices.CatalogRepoService; +import org.etsi.osl.tmf.scm633.reposervices.CategoryRepoService; +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceOrderRef; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import org.etsi.osl.tmf.so641.model.ServiceOrder; +import org.etsi.osl.tmf.so641.model.ServiceOrderCreate; +import org.etsi.osl.tmf.so641.model.ServiceOrderItem; +import org.etsi.osl.tmf.so641.model.ServiceOrderStateType; +import org.etsi.osl.tmf.so641.model.ServiceOrderUpdate; +import org.etsi.osl.tmf.so641.model.ServiceRestriction; +import org.etsi.osl.tmf.so641.reposervices.ServiceOrderRepoService; +import org.etsi.osl.tmf.JsonUtils; + +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; + +@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 ServiceOrderIntegrationTest { + + private static final transient Log logger = LogFactory.getLog(ServiceOrderIntegrationTest.class.getName()); + + @Autowired + private MockMvc mvc; + + @Autowired + CatalogRepoService catalogRepoService; + + @Autowired + CategoryRepoService categRepoService; + + @Autowired + ServiceSpecificationRepoService specRepoService; + + @Autowired + ServiceOrderRepoService serviceOrderRepoService; + + @Autowired + ServiceRepoService serviceRepoService; + + @Autowired + private WebApplicationContext context; + + + @Autowired + private FilterChainProxy springSecurityFilterChain; + + private class UserMocked { + public String getUserByUsername( String username) { + + return "{\"id\":\"001\"}"; + } + } + + UserMocked userMocked = new UserMocked(); + + @Autowired + private CamelContext camelContext; + + @Before + public void setup() throws Exception { + mvc = MockMvcBuilders.webAppContextSetup(context). + apply(springSecurity(springSecurityFilterChain)).build(); + + } + + @Test + public void _countDefaultProperties() { + + assertThat(serviceOrderRepoService.findAll().size()).isEqualTo(0); + + } + + @WithMockUser(username="osadmin", roles = {"USER","ADMIN"}) + @Test + public void testServiceOrderCreateAndUpdate() throws UnsupportedEncodingException, IOException, Exception { + + RoutesBuilder builder = new RouteBuilder() { + @Override + public void configure() { + from("direct:get_user_byusername").bean( userMocked, "getUserByUsername"); + + }; + }; + + camelContext.addRoutes(builder); + /** + * first add 2 specs + */ + + File sspec = new File("src/test/resources/testServiceSpec.json"); + InputStream in = new FileInputStream(sspec); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ServiceSpecificationCreate sspeccr1 = JsonUtils.toJsonObj(sspectext, ServiceSpecificationCreate.class); + sspeccr1.setName("Spec1"); + ServiceSpecification responsesSpec1 = createServiceSpec( sspeccr1); + + sspec = new File("src/test/resources/testServiceSpec2.json"); + in = new FileInputStream(sspec); + sspectext = IOUtils.toString(in, "UTF-8"); + // service 2 is an RFS + ServiceSpecificationCreate sspeccr2 = JsonUtils.toJsonObj(sspectext, ServiceSpecificationCreate.class); + sspeccr2.setName("Spec2"); + ResourceSpecificationRef resourceSpecificationItem = new ResourceSpecificationRef(); + resourceSpecificationItem.setId("resourceid"); + resourceSpecificationItem.setName("resourceName"); + sspeccr2.addResourceSpecificationItem(resourceSpecificationItem); + ServiceSpecification responsesSpec2 = createServiceSpec( sspeccr2); + /** + * add them as bundle + */ + + ServiceSpecificationCreate sspeccr3 = JsonUtils.toJsonObj(sspectext, ServiceSpecificationCreate.class); + sspeccr3.setName("BundleExampleSpec"); + sspeccr3.isBundle(true); + sspeccr3.addServiceSpecRelationshipWith(responsesSpec1); + sspeccr3.addServiceSpecRelationshipWith(responsesSpec2); + ServiceSpecification responsesSpec3 = createServiceSpec( sspeccr3); + + + /** + * the bundle service characteristics must be same with the total of characteristics of each service in the bundle + * here 1+2 + the 2 characteristics of the service itself total 5 + */ + + assertThat( responsesSpec3.getServiceSpecCharacteristic().size() ).isEqualTo( 3 ); + + ServiceOrderCreate servOrder = new ServiceOrderCreate(); + servOrder.setCategory("Experimentation"); + servOrder.setDescription("Experimentation Descr"); + servOrder.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + servOrder.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + + Note noteItem = new Note(); + noteItem.text("test note"); + servOrder.addNoteItem(noteItem); + + ServiceOrderItem soi = new ServiceOrderItem(); + servOrder.getOrderItem().add(soi); + soi.setState(ServiceOrderStateType.ACKNOWLEDGED); + + ServiceRestriction serviceRestriction = new ServiceRestriction(); + ServiceSpecificationRef aServiceSpecificationRef = new ServiceSpecificationRef(); + aServiceSpecificationRef.setId(responsesSpec3.getId()); + aServiceSpecificationRef.setName(responsesSpec3.getName()); + + serviceRestriction.setServiceSpecification(aServiceSpecificationRef); + serviceRestriction.setName("aserviceRestriction"); + soi.setService(serviceRestriction); + + Characteristic charitem = new Characteristic(); + charitem.setName("Spec2Attribute1"); + charitem.setValue( new Any("3", "Indoor")); + serviceRestriction.addServiceCharacteristicItem(charitem ); + + String responseSorder = mvc + .perform(MockMvcRequestBuilders.post("/serviceOrdering/v4/serviceOrder") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(servOrder))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + logger.info("testServiceOrderCreate = " + responseSorder); + ServiceOrder responseSO = JsonUtils.toJsonObj(responseSorder, ServiceOrder.class); + + logger.info("BundleExampleSpec = " + JsonUtils.toJsonString(responsesSpec3)); + logger.info("responsesSpec1 = " + JsonUtils.toJsonString(responsesSpec1)); + logger.info("responsesSpec2 = " + JsonUtils.toJsonString(responsesSpec2)); + logger.info("testServiceOrderCreate = " + JsonUtils.toJsonString(responseSO)); + + assertThat(responseSO.getCategory()).isEqualTo("Experimentation"); + assertThat(responseSO.getDescription()).isEqualTo("Experimentation Descr"); + assertThat(responseSO.getRequestedStartDate()).isNotNull(); + assertThat(responseSO.getRequestedCompletionDate()).isNotNull(); + + assertThat(responseSO.getOrderItem().size()).isEqualTo(1); + + + assertThat( responsesSpec1.getServiceSpecCharacteristic().size() ).isEqualTo( 2 ); + assertThat( responsesSpec2.getServiceSpecCharacteristic().size() ).isEqualTo( 3 ); + assertThat( responsesSpec3.getServiceSpecCharacteristic().size() ).isEqualTo( 3 ); + + + responseSO.getOrderItem().stream().forEach(soiElement -> { + assertThat(soiElement.getState()).isEqualTo(ServiceOrderStateType.ACKNOWLEDGED); + assertThat(soiElement.getService().getServiceSpecification()).isNotNull(); + assertThat(soiElement.getService().getServiceSpecification().getName()).isEqualTo( "BundleExampleSpec" ); + + /** + * the ordered service characteristics must be same with the total of characteristics of service + * with ONLY user configurable values (This changed on 20/8/2021 with the implementation of rules) + * (and NO with default values from non configurable attributes) + * Therefore the service should have only 1 characteristic (the Spec2Attribute1 name) + */ + assertThat( soiElement.getService().getServiceCharacteristic().size() ).isEqualTo( 1 ); + assertThat( soiElement.getService().getServiceCharacteristic().stream().findFirst().get().getName() ).isEqualTo( "Spec2Attribute1" ); + + + }); + assertThat(responseSO.getNote().size()).isEqualTo(3); + + boolean userPartyRoleexists = false; + for (RelatedParty r : responseSO.getRelatedParty()) { + if (r.getName().equals("osadmin") && r.getRole().equals(UserPartRoleType.REQUESTER.toString())) { + userPartyRoleexists = true; + } + } + + assertThat(userPartyRoleexists).isTrue(); + + assertThat(serviceOrderRepoService.findAll().size()).isEqualTo(1); + + 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"); + + Note anoteItem = new Note(); + anoteItem.setText("Service Created by OSOM:AutomationCheck"); + s.addNoteItem(anoteItem); + + ServiceOrderRef serviceOrderref = new ServiceOrderRef(); + serviceOrderref.setId(responseSO.getId()); + serviceOrderref.setServiceOrderItemId((new ArrayList<>(responseSO.getOrderItem())).get(0).getId()); + s.addServiceOrderItem(serviceOrderref); + + Service createdServ = serviceRepoService.addService(s); + + ServiceOrderUpdate servOrderUpd = new ServiceOrderUpdate(); + servOrderUpd.setExpectedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + responseSO.getNote().stream().forEach(n -> servOrderUpd.addNoteItem(n)); + Note en = new Note(); + en.text("test note2"); + servOrderUpd.addNoteItem(en); + servOrderUpd.addOrderItemItem((new ArrayList<>(responseSO.getOrderItem())).get(0)); + servOrderUpd.getOrderItem().get(0).setState(ServiceOrderStateType.INPROGRESS); + ServiceRef supportingServiceItem = new ServiceRef(); + supportingServiceItem.setId(createdServ.getId()); + supportingServiceItem.setReferredType(createdServ.getName()); + supportingServiceItem.setName(createdServ.getName()); + servOrderUpd.getOrderItem().get(0).getService().addSupportingServiceItem(supportingServiceItem); + + String responseSorderUpd = mvc + .perform(MockMvcRequestBuilders.patch("/serviceOrdering/v4/serviceOrder/" + responseSO.getId()) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(servOrderUpd))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + logger.info("testServiceOrderUpdate = " + responseSorderUpd); + ServiceOrder responseSOUpd = JsonUtils.toJsonObj(responseSorderUpd, ServiceOrder.class); + + assertThat(serviceOrderRepoService.findAll().size()).isEqualTo(1); + + assertThat(responseSOUpd.getOrderItem().size()).isEqualTo(1); + responseSOUpd.getOrderItem().stream().forEach(soiElement -> { + assertThat(soiElement.getState()).isEqualTo(ServiceOrderStateType.INPROGRESS); + assertThat(soiElement.getService().getServiceSpecification()).isNotNull(); + assertThat(soiElement.getService().getServiceSpecification().getName()).isEqualTo("BundleExampleSpec"); + assertThat(soiElement.getService().getSupportingService().size()).isEqualTo(1); + }); + + assertThat(responseSOUpd.getExpectedCompletionDate()).isNotNull(); + assertThat(responseSOUpd.getNote().size()).isEqualTo( 4 ); + + File sspecSO = new File("src/test/resources/TestServiceOrderDates.json"); + InputStream inSO = new FileInputStream(sspecSO); + String sspectextSO = IOUtils.toString(inSO, "UTF-8"); + + ServiceOrder sspeccr1SO = JsonUtils.toJsonObj(sspectextSO, ServiceOrder.class); + + assertThat(sspeccr1SO).isNotNull(); + + // Ensure that all Services' end dates were updated correctly + boolean allSupportingServicesEndDatesUpdatedToServiceOrderExpectedCompletionDate = true; + List services = serviceRepoService.getServicesFromOrderID(responseSO.getId()); + + for (String serviceId : services) { + Service service = serviceRepoService.findByUuid(serviceId); + if (!service.getEndDate().equals(responseSOUpd.getExpectedCompletionDate())) { + allSupportingServicesEndDatesUpdatedToServiceOrderExpectedCompletionDate = false; + break; + } + } + assertThat(allSupportingServicesEndDatesUpdatedToServiceOrderExpectedCompletionDate).isTrue(); + } + + @WithMockUser(username="osadmin", roles = {"USER"}) + @Test + public void testVINNISpecServiceOrderCreateAndUpdate() throws UnsupportedEncodingException, IOException, Exception { + String responseSpecClonedVINNI = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/cloneVINNI?serviceName=aVINNIService") + .contentType(MediaType.APPLICATION_JSON) + .param("addServiceTopology", "true") + .param("addServiceRequirements", "true") + .param("addServiceExposureLevel1", "true") + .param("addServiceExposureLevel2", "true") + .param("addServiceExposureLevel3", "true") + .param("addServiceExposureLevel4", "true") + .param("addServiceMonitoring", "true") + .param("addServiceTesting", "true") + .param("addServiceVNF", "true") + .param("addServiceNSD", "true") + .content( JsonUtils.toJson( "" ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ServiceSpecification clonedSpec = JsonUtils.toJsonObj( responseSpecClonedVINNI, ServiceSpecification.class); + assertThat( clonedSpec.getName() ).isEqualTo( "aVINNIService" ); + + } + + + private ServiceSpecification createServiceSpec( ServiceSpecificationCreate sspeccr1) + throws Exception { + + String responseSpec = mvc + .perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(sspeccr1))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + ServiceSpecification responsesSpec1 = JsonUtils.toJsonObj(responseSpec, ServiceSpecification.class); + logger.info("createServiceSpec = " + responseSpec); + return responsesSpec1; + } + + private LogicalResourceSpecification createLogicalResourceSpec() throws Exception { + 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); + + URI url = new URI("/resourceCatalogManagement/v4/logicalResourceSpec"); + + String responseSpec = mvc + .perform(MockMvcRequestBuilders.post(url).contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(sspeccr1))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + LogicalResourceSpecification responsesSpec1; + + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + + logger.info("createResourceSpec = " + responseSpec); + return responsesSpec1; + } + + +} diff --git a/src/test/java/org/etsi/osl/services/api/ServiceTestManagementIntegrationTest.java b/src/test/java/org/etsi/osl/services/api/ServiceTestManagementIntegrationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..dc212c3d361682cb426113a5822b96717bf86f7d --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ServiceTestManagementIntegrationTest.java @@ -0,0 +1,147 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 2021 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.services.api; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.is; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import org.etsi.osl.tmf.stm653.model.ServiceTestCreate; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationCreate; +import org.etsi.osl.tmf.stm653.reposervices.ServiceTestRepoService; +import org.etsi.osl.tmf.stm653.reposervices.ServiceTestSpecificationRepoService; +import org.etsi.osl.tmf.JsonUtils; + +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; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ServiceTestManagementIntegrationTest { + + private static final transient Log logger = LogFactory.getLog(ServiceTestManagementIntegrationTest.class.getName()); + + @Autowired + private MockMvc mvc; + + @Autowired + ServiceTestSpecificationRepoService aServiceTestSpecRpoService; + + @Autowired + ServiceTestRepoService aServiceTestRpoService; + + @Autowired + ServiceRepoService serviceRepoService; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build(); + } + + @WithMockUser(username = "osadmin", roles = { "ADMIN","USER" }) + @Test + public void testServiceTestSpecCreateAndUpdate() throws UnsupportedEncodingException, IOException, Exception { + + /** + * first add 2 specs + */ +// /testServiceTestSpec + + + + File sspec = new File( "src/test/resources/testServiceTestSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + ServiceTestSpecificationCreate spec = JsonUtils.toJsonObj( sspectext, ServiceTestSpecificationCreate.class); + + + String response = mvc.perform(MockMvcRequestBuilders.post("/serviceTestManagement/v4/serviceTestSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( spec ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("A test name"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( aServiceTestSpecRpoService.findAll().size() ).isEqualTo( 1 ); + + + sspec = new File( "src/test/resources/testServiceTest.json" ); + in = new FileInputStream( sspec ); + sspectext = IOUtils.toString(in, "UTF-8"); + ServiceTestCreate stest = JsonUtils.toJsonObj( sspectext, ServiceTestCreate.class); + + + response = mvc.perform(MockMvcRequestBuilders.post("/serviceTestManagement/v4/serviceTest") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( stest ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("A test name"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( aServiceTestRpoService.findAll().size() ).isEqualTo( 1 ); + + + } + + +} diff --git a/src/test/java/org/etsi/osl/services/api/gsm674/GeographicSiteManagementApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/gsm674/GeographicSiteManagementApiControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..04878fd10c9dfdf92a02d8e22c5b999a523214bd --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/gsm674/GeographicSiteManagementApiControllerTest.java @@ -0,0 +1,134 @@ +package org.etsi.osl.services.api.gsm674; + +import org.etsi.osl.tmf.gsm674.api.GeographicSiteManagementApiController; +import org.etsi.osl.tmf.gsm674.model.GeographicSite; +import org.etsi.osl.tmf.gsm674.reposervices.GeographicSiteManagementService; +import org.junit.jupiter.api.BeforeEach; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.context.ActiveProfiles; + +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +@AutoConfigureMockMvc +@ActiveProfiles("testing") +class GeographicSiteManagementApiControllerTest { + + @InjectMocks + private GeographicSiteManagementApiController controller; + + @Mock + private GeographicSiteManagementService service; + + @BeforeEach + void setUp() { + MockitoAnnotations.openMocks(this); + } + + @Test + void testRetrieveGeographicSites() { + List sites = new ArrayList<>(); + // Add test data to sites list + when(service.findAllGeographicSites()).thenReturn(sites); + + ResponseEntity> response = controller.listGeographicSite(); + + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertEquals(sites, response.getBody()); + } + + @Test + void testFetchGeographicSite() { + GeographicSite site = new GeographicSite(); + // Add test data to sites list + when(service.findGeographicSiteByUUID("123")).thenReturn(site); + + ResponseEntity response = controller.retrieveGeographicSite("123"); + + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertEquals(site, response.getBody()); + } + + @Test + void testCreateGeographicSite() { + GeographicSite site = new GeographicSite(); + + when(service.createGeographicSite(any())).thenReturn(site); + + ResponseEntity response = controller.createGeographicSite(site); + + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertEquals(site, response.getBody()); + } + + @Test + void testExceptionWhenCreateGeographicSite(){ + GeographicSite site = new GeographicSite(); + + when(service.createGeographicSite(any())).thenThrow(RuntimeException.class); + + ResponseEntity response = controller.createGeographicSite(site); + + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); + } + + @Test + void testDeleteGeographicSite() { + + doNothing().when(service).deleteGeographicSiteById(anyString()); + ResponseEntity response = controller.deleteGeographicSite("siteId"); + + assertEquals(HttpStatus.OK, response.getStatusCode()); + } + + @Test + void testDeleteGeographicSiteException() { + + doThrow(RuntimeException.class).when(service).deleteGeographicSiteById(anyString()); + ResponseEntity response = controller.deleteGeographicSite("siteId"); + + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); + } + + @Test + void testPatchGeographicalSite() { + String siteId = "siteId"; + GeographicSite updatedSite = new GeographicSite(); + // Set up mock service behavior + when(service.updateGeographicSite(anyString(), any())).thenReturn(updatedSite); + + ResponseEntity response = controller.patchGeographicalSite(siteId, updatedSite); + + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertEquals(updatedSite, response.getBody()); + } + + @Test + void testPatchGeographicalSiteException() { + String siteId = "siteId"; + GeographicSite updatedSite = new GeographicSite(); + // Set up mock service behavior + when(service.updateGeographicSite(anyString(), any())).thenThrow(RuntimeException.class); + + ResponseEntity response = controller.patchGeographicalSite(siteId, updatedSite); + + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode()); + } + +} diff --git a/src/test/java/org/etsi/osl/services/api/gsm674/GeographicSiteManagementServiceTest.java b/src/test/java/org/etsi/osl/services/api/gsm674/GeographicSiteManagementServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0ffbb2cb930558a1222221d67c7c92955e0bdb79 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/gsm674/GeographicSiteManagementServiceTest.java @@ -0,0 +1,96 @@ +package org.etsi.osl.services.api.gsm674; +import org.etsi.osl.tmf.gsm674.model.GeographicSite; +import org.etsi.osl.tmf.gsm674.repo.GeographicSiteManagementRepository; +import org.etsi.osl.tmf.gsm674.reposervices.GeographicSiteManagementService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.context.ActiveProfiles; + +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; + +@AutoConfigureMockMvc +@ActiveProfiles("testing") +class GeographicSiteManagementServiceTest { + @InjectMocks + private GeographicSiteManagementService service; + + @Mock + private GeographicSiteManagementRepository repository; + + @BeforeEach + void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + void testFindAllGeographicSites() { + // Mock data + List sites = List.of(new GeographicSite(), new GeographicSite()); + when(repository.findAll()).thenReturn(sites); + + List result = service.findAllGeographicSites(); + + assertEquals(sites, result); + } + + @Test + void testFindGeographicSiteByUUID() { + // Mock data + String uuid = "123"; + GeographicSite site = new GeographicSite(); + when(repository.findByUuid(uuid)).thenReturn(Optional.of(site)); + + GeographicSite result = service.findGeographicSiteByUUID(uuid); + + assertEquals(site, result); + } + + @Test + void testCreateGeographicSite() { + // Mock data + GeographicSite site = new GeographicSite(); + when(repository.save(any())).thenReturn(site); + + GeographicSite result = service.createGeographicSite(site); + + assertEquals(site, result); + } + + @Test + void testUpdateGeographicSite() { + // Mock data + String id = "123"; + GeographicSite existingSite = new GeographicSite(); + GeographicSite newSite = new GeographicSite(); + when(repository.findByUuid(id)).thenReturn(Optional.of(existingSite)); + when(repository.save(any())).thenReturn(existingSite); + + GeographicSite result = service.updateGeographicSite(id, newSite); + + assertNotNull(result); + assertEquals(existingSite, result); + // Add additional assertions for updated fields if needed + } + + @Test + void testDeleteGeographicSiteById() { + // Mock data + String id = "123"; + GeographicSite existingSite = new GeographicSite(); + when(repository.findByUuid(id)).thenReturn(Optional.of(existingSite)); + + Void result = service.deleteGeographicSiteById(id); + + assertNull(result); + verify(repository, times(1)).delete(existingSite); + } +} diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/CommonTests.java b/src/test/java/org/etsi/osl/services/api/rcm634/CommonTests.java new file mode 100644 index 0000000000000000000000000000000000000000..94440f8aedd8b79878b57ffeb19ab5348c208a99 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/CommonTests.java @@ -0,0 +1,187 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 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.services.api.rcm634; + +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.etsi.osl.tmf.rcm634.api.ApiException; +import org.etsi.osl.tmf.rcm634.api.ApiOriginFilter; +import org.etsi.osl.tmf.rcm634.api.ApiResponseMessage; +import org.etsi.osl.tmf.rcm634.api.ImportJobApiController; +import org.etsi.osl.tmf.rcm634.api.ExportJobApiController; +import org.etsi.osl.tmf.rcm634.api.ListenerApiController; +import org.etsi.osl.tmf.rcm634.api.HubApiController; +import org.etsi.osl.tmf.rcm634.api.NotFoundException; + +import org.junit.jupiter.api.Test; + +import org.springframework.mock.web.MockHttpServletRequest; + +import java.io.IOException; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.*; + +public class CommonTests { + + @Test + public void testApiException() { + int errorCode = 404; + String errorMessage = "Not Found"; + + ApiException exception = new ApiException(errorCode, errorMessage); + + assertEquals(errorMessage, exception.getMessage()); + assertEquals(errorCode, exception.getCode()); + } + + @Test + public void testApiOriginFilter() throws IOException, ServletException { + HttpServletRequest request = mock(HttpServletRequest.class); + HttpServletResponse response = mock(HttpServletResponse.class); + FilterChain chain = mock(FilterChain.class); + + ApiOriginFilter filter = new ApiOriginFilter(); + filter.doFilter(request, response, chain); + + verify(response).addHeader("Access-Control-Allow-Origin", "*"); + verify(response).addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + verify(response).addHeader("Access-Control-Allow-Headers", "Content-Type"); + verify(chain).doFilter(request, response); + } + + @Test + public void testApiResponseMessage() { + int[] codes = {ApiResponseMessage.ERROR, ApiResponseMessage.WARNING, ApiResponseMessage.INFO, ApiResponseMessage.OK, ApiResponseMessage.TOO_BUSY, 6}; + + String[] types = {"error", "warning", "info", "ok", "too busy", "unknown"}; + + String[] messages = {"An error occured", "This is a warning", "Given info", "ok", "System is too busy", "unknown code"}; + + for (int i = 0; i < codes.length; i++) { + int code = codes[i]; + String type = types[i]; + String message = messages[i]; + + ApiResponseMessage responseMessage = new ApiResponseMessage(code, message); + + assertEquals(message, responseMessage.getMessage()); + assertEquals(code, responseMessage.getCode()); + assertEquals(type, responseMessage.getType()); + + } + + ApiResponseMessage responseMessage = new ApiResponseMessage(); + responseMessage.setMessage("Error"); + assertEquals("Error", responseMessage.getMessage()); + responseMessage.setType("ok"); + assertEquals("ok", responseMessage.getType()); + responseMessage.setCode(ApiResponseMessage.OK); + assertEquals(ApiResponseMessage.OK, responseMessage.getCode()); + } + + @Test + public void testExportJobApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + ExportJobApiController controller = new ExportJobApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testHubApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + HubApiController controller = new HubApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testImportJobApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + ImportJobApiController controller = new ImportJobApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testListenerApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + ListenerApiController controller = new ListenerApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testNotFoundException() { + int errorCode = 404; + String errorMessage = "Not Found"; + + NotFoundException exception = new NotFoundException(errorCode, errorMessage); + + assertEquals(errorMessage, exception.getMessage()); + assertEquals(errorCode, exception.getCode()); + } + +} + diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ConnectionPointSpecificationRefTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ConnectionPointSpecificationRefTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c899aef4beda6c6cb26637b74bb965990d94fdcd --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ConnectionPointSpecificationRefTest.java @@ -0,0 +1,129 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.ConnectionPointSpecificationRef; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import java.lang.reflect.Method; + +public class ConnectionPointSpecificationRefTest { + + @Test + void testConnectionPointSpecificationRef() { + ConnectionPointSpecificationRef ref = new ConnectionPointSpecificationRef(); + String id = "testId"; + String href = "testHref"; + String name = "testName"; + String version = "testVersion"; + String referredType = "testReferredType"; + + ref.id(id); + ref.setUuid(id); + ref.href(href); + ref.name(name); + ref.version(version); + ref._atReferredType(referredType); + + assertEquals(id, ref.getId()); + assertEquals(href, ref.getHref()); + assertEquals(name, ref.getName()); + assertEquals(version, ref.getVersion()); + assertEquals(referredType, ref.getAtReferredType()); + + ref = new ConnectionPointSpecificationRef(); + ref.setUuid(id); + ref.setHref(href); + ref.setName(name); + ref.setVersion(version); + ref.setAtReferredType(referredType); + + assertEquals(id, ref.getId()); + assertEquals(href, ref.getHref()); + assertEquals(name, ref.getName()); + assertEquals(version, ref.getVersion()); + assertEquals(referredType, ref.getAtReferredType()); + } + + @Test + void testEquals() { + String id = "testId"; + String href = "testHref"; + String name = "testName"; + String version = "testVersion"; + String referredType = "testReferredType"; + + ConnectionPointSpecificationRef ref1 = new ConnectionPointSpecificationRef(); + ref1.setUuid(id); + ref1.setHref(href); + ref1.setName(name); + ref1.setVersion(version); + ref1.setAtReferredType(referredType); + + ConnectionPointSpecificationRef ref2 = new ConnectionPointSpecificationRef(); + ref2.setUuid(id); + ref2.setHref(href); + ref2.setName(name); + ref2.setVersion(version); + ref2.setAtReferredType(referredType); + + + assertTrue(ref1.equals(ref2)); + assertEquals(ref1.hashCode(), ref2.hashCode()); + + ref1.id("differentId"); + + assertFalse(ref1.equals(ref2)); + assertNotEquals(ref1.hashCode(), ref2.hashCode()); + } + + @Test + void testToString() { + ConnectionPointSpecificationRef ref = new ConnectionPointSpecificationRef(); + + String id = "testId"; + String href = "testHref"; + String name = "testName"; + String version = "testVersion"; + String baseType = "testBaseType"; + String schemaLocation = "testSchemaLocation"; + String type = "testType"; + String referredType = "testReferredType"; + + ref.id(id); + ref.setUuid(id); + ref.setHref(href); + ref.setName(name); + ref.setVersion(version); + ref.setBaseType(baseType); + ref.setSchemaLocation(schemaLocation); + ref.setType(type); + ref.setAtReferredType(referredType); + + String expectedString = "class ConnectionPointSpecificationRef {\n" + + " id: " + id + "\n" + + " href: " + href + "\n" + + " name: " + name + "\n" + + " version: " + version + "\n" + + " _atBaseType: " + baseType + "\n" + + " _atSchemaLocation: " + schemaLocation + "\n" + + " _atType: " + type + "\n" + + " _atReferredType: " + referredType + "\n" + + "}"; + + assertEquals(expectedString, ref.toString()); + } + + @Test + void testToIndentedString() throws Exception { + ConnectionPointSpecificationRef ref = new ConnectionPointSpecificationRef(); + + Method method = ConnectionPointSpecificationRef.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String input = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(ref, input); + + assertEquals(expectedOutput, output); + } +} diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ConnectionSpecificationTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ConnectionSpecificationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..527d5df1752579f709e08e0a6211dad65fe0b8eb --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ConnectionSpecificationTest.java @@ -0,0 +1,118 @@ +package org.etsi.osl.services.api.rcm634; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.etsi.osl.tmf.rcm634.model.ConnectionSpecification; +import org.etsi.osl.tmf.rcm634.model.EndpointSpecificationRef; + +import java.util.HashSet; +import java.util.Set; + +public class ConnectionSpecificationTest { + + @Test + void testConnectionSpecification() { + ConnectionSpecification spec = new ConnectionSpecification(); + String id = "testId"; + String href = "testHref"; + String associationType = "testAssociationType"; + String name = "testName"; + Set endpointSpecification = new HashSet<>(); + String baseType = "testBaseType"; + String schemaLocation = "testSchemaLocation"; + String type = "testType"; + + spec.id(id); + spec.setUuid(id); + spec.href(href); + spec.associationType(associationType); + spec.name(name); + spec.endpointSpecification(endpointSpecification); + spec._atBaseType(baseType); + spec._atSchemaLocation(schemaLocation); + spec._atType(type); + + assertEquals(id, spec.getId()); + assertEquals(href, spec.getHref()); + assertEquals(associationType, spec.getAssociationType()); + assertEquals(name, spec.getName()); + assertEquals(endpointSpecification, spec.getEndpointSpecification()); + assertEquals(baseType, spec.getAtBaseType()); + assertEquals(schemaLocation, spec.getAtSchemaLocation()); + assertEquals(type, spec.getAtType()); + + String expectedString = "class ConnectionSpecification {\n" + + " id: " + id + "\n" + + " href: " + href + "\n" + + " associationType: " + associationType + "\n" + + " name: " + name + "\n" + + " endpointSpecification: " + endpointSpecification.toString().replace("\n", "\n ") + "\n" + + " _atBaseType: " + baseType + "\n" + + " _atSchemaLocation: " + schemaLocation + "\n" + + " _atType: " + type + "\n" + + "}"; + + assertEquals(expectedString, spec.toString()); + + ConnectionSpecification spec2 = new ConnectionSpecification(); + spec2.id(id); + spec2.href(href); + spec2.associationType(associationType); + spec2.name(name); + spec2.endpointSpecification(endpointSpecification); + spec2._atBaseType(baseType); + spec2._atSchemaLocation(schemaLocation); + spec2._atType(type); + + assertTrue(spec.equals(spec2)); + assertEquals(spec.hashCode(), spec2.hashCode()); + + spec.id("differentId"); + + assertFalse(spec.equals(spec2)); + assertNotEquals(spec.hashCode(), spec2.hashCode()); + } + + @Test + void testSetters() { + ConnectionSpecification spec = new ConnectionSpecification(); + String id = "testId"; + String href = "testHref"; + String associationType = "testAssociationType"; + String name = "testName"; + Set endpointSpecification = new HashSet<>(); + String baseType = "testBaseType"; + String schemaLocation = "testSchemaLocation"; + String type = "testType"; + + spec.setUuid(id); + spec.id(id); + spec.setHref(href); + spec.setAssociationType(associationType); + spec.setName(name); + spec.setEndpointSpecification(endpointSpecification); + spec.setAtBaseType(baseType); + spec.setAtSchemaLocation(schemaLocation); + spec.setAtType(type); + + assertEquals(id, spec.getId()); + assertEquals(href, spec.getHref()); + assertEquals(associationType, spec.getAssociationType()); + assertEquals(name, spec.getName()); + assertEquals(endpointSpecification, spec.getEndpointSpecification()); + assertEquals(baseType, spec.getAtBaseType()); + assertEquals(schemaLocation, spec.getAtSchemaLocation()); + assertEquals(type, spec.getAtType()); + } + + @Test + void testAddEndpointSpecificationItem() { + ConnectionSpecification spec = new ConnectionSpecification(); + EndpointSpecificationRef endpointSpecRef = new EndpointSpecificationRef(); + endpointSpecRef.id("testId"); + + spec.addEndpointSpecificationItem(endpointSpecRef); + + assertTrue(spec.getEndpointSpecification().contains(endpointSpecRef)); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ConstraintRefTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ConstraintRefTest.java new file mode 100644 index 0000000000000000000000000000000000000000..17dc9e3206cb909164032f180075563d1aca9cde --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ConstraintRefTest.java @@ -0,0 +1,80 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.ConstraintRef; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +public class ConstraintRefTest { + + @Test + void testConstraintRef() { + ConstraintRef ref = new ConstraintRef(); + String id = "testId"; + String href = "testHref"; + String name = "testName"; + String version = "testVersion"; + String referredType = "testReferredType"; + + String baseType = "BaseEntity"; + String schemaLocation = "null"; + String type = "null"; + + ref.id(id); + ref.setUuid(id); + ref.href(href); + ref.name(name); + ref.version(version); + ref._atReferredType(referredType); + + assertEquals(id, ref.getId()); + assertEquals(href, ref.getHref()); + assertEquals(name, ref.getName()); + assertEquals(version, ref.getVersion()); + assertEquals(referredType, ref.getAtReferredType()); + + String expectedString = "class ConstraintRef {\n" + + " id: " + id + "\n" + + " href: " + href + "\n" + + " name: " + name + "\n" + + " version: " + version + "\n" + + " baseType: " + baseType + "\n" + + " schemaLocation: " + schemaLocation + "\n" + + " type: " + type + "\n" + + " _atReferredType: " + referredType + "\n" + + "}"; + + assertEquals(expectedString, ref.toString()); + + ConstraintRef ref2 = new ConstraintRef(); + ref2.id(id); + ref2.setUuid(id); + ref2.href(href); + ref2.name(name); + ref2.version(version); + ref2._atReferredType(referredType); + + assertTrue(ref.equals(ref2)); + assertEquals(ref.hashCode(), ref2.hashCode()); + + ref.id("differentId"); + ref.setUuid("differentId"); + + assertFalse(ref.equals(ref2)); + assertNotEquals(ref.hashCode(), ref2.hashCode()); + + ref = new ConstraintRef(); + + ref.setId(id); + ref.setUuid(id); + ref.setHref(href); + ref.setName(name); + ref.setVersion(version); + ref.setAtReferredType(referredType); + + assertEquals(id, ref.getId()); + assertEquals(href, ref.getHref()); + assertEquals(name, ref.getName()); + assertEquals(version, ref.getVersion()); + assertEquals(referredType, ref.getAtReferredType()); + } +} diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/EndpointSpecificationRefTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/EndpointSpecificationRefTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2618021c454ff02b3f17ebf264ff988924550574 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/EndpointSpecificationRefTest.java @@ -0,0 +1,180 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.ConnectionPointSpecificationRef; +import org.etsi.osl.tmf.rcm634.model.EndpointSpecificationRef; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import java.lang.reflect.Method; + +public class EndpointSpecificationRefTest { + @Test + void testName() { + EndpointSpecificationRef ref = new EndpointSpecificationRef(); + String name = "testName"; + ref.setName(name); + assertEquals(name, ref.getName()); + + EndpointSpecificationRef newRef = ref.name("newTestName"); + assertEquals(ref, newRef); + } + + @Test + void testConnectionPointSpecification() { + EndpointSpecificationRef ref = new EndpointSpecificationRef(); + ConnectionPointSpecificationRef connectionPointSpecificationRef = new ConnectionPointSpecificationRef(); + ref.setConnectionPointSpecification(connectionPointSpecificationRef); + assertEquals(connectionPointSpecificationRef, ref.getConnectionPointSpecification()); + + EndpointSpecificationRef newRef = ref.connectionPointSpecification(connectionPointSpecificationRef.name("newRef")); + assertEquals(ref, newRef); + } + + @Test + void testEndpointSpecificationRef() { + EndpointSpecificationRef ref = new EndpointSpecificationRef(); + String id = "testId"; + String href = "testHref"; + Boolean isRoot = true; + String role = "testRole"; + String referredType = "testReferredType"; + + ref.id(id); + ref.setUuid(id); + ref.href(href); + ref.isRoot(isRoot); + ref.role(role); + ref._atReferredType(referredType); + + assertEquals(id, ref.getId()); + assertEquals(href, ref.getHref()); + assertEquals(isRoot, ref.isIsRoot()); + assertEquals(role, ref.getRole()); + assertEquals(referredType, ref.getAtReferredType()); + + ref = new EndpointSpecificationRef(); + ref.setUuid(id); + ref.setHref(href); + ref.setIsRoot(isRoot); + ref.setRole(role); + ref.setAtReferredType(referredType); + + assertEquals(id, ref.getId()); + assertEquals(href, ref.getHref()); + assertEquals(isRoot, ref.isIsRoot()); + assertEquals(role, ref.getRole()); + assertEquals(referredType, ref.getAtReferredType()); + } + + @Test + void testEquals() { + String id = "testId"; + String href = "testHref"; + Boolean isRoot = true; + String role = "testRole"; + String referredType = "testReferredType"; + + EndpointSpecificationRef ref1 = new EndpointSpecificationRef(); + ref1.setUuid(id); + ref1.setHref(href); + ref1.setIsRoot(isRoot); + ref1.setRole(role); + ref1.setAtReferredType(referredType); + + EndpointSpecificationRef ref2 = new EndpointSpecificationRef(); + ref2.setUuid(id); + ref2.setHref(href); + ref2.setIsRoot(isRoot); + ref2.setRole(role); + ref2.setAtReferredType(referredType); + + assertTrue(ref1.equals(ref2)); + + ref1.id("differentId"); + + assertFalse(ref1.equals(ref2)); + } + + @Test + void testHashCode() { + String id = "testId"; + String href = "testHref"; + Boolean isRoot = true; + String role = "testRole"; + String referredType = "testReferredType"; + + EndpointSpecificationRef ref1 = new EndpointSpecificationRef(); + ref1.setUuid(id); + ref1.setHref(href); + ref1.setIsRoot(isRoot); + ref1.setRole(role); + ref1.setAtReferredType(referredType); + + EndpointSpecificationRef ref2 = new EndpointSpecificationRef(); + ref2.setUuid(id); + ref2.setHref(href); + ref2.setIsRoot(isRoot); + ref2.setRole(role); + ref2.setAtReferredType(referredType); + + assertEquals(ref1.hashCode(), ref2.hashCode()); + + ref1.id("differentId"); + + assertNotEquals(ref1.hashCode(), ref2.hashCode()); + } + + @Test + void testToString() { + EndpointSpecificationRef ref = new EndpointSpecificationRef(); + + String id = "testId"; + String href = "testHref"; + Boolean isRoot = true; + String role = "testRole"; + String baseType = "testBaseType"; + String schemaLocation = "testSchemaLocation"; + String type = "testType"; + String referredType = "testReferredType"; + + ref.id(id); + ref.setUuid(id); + ref.setHref(href); + ref.isRoot(isRoot); + ref.role(role); + ref.setBaseType(baseType); + ref.setSchemaLocation(schemaLocation); + ref.setType(type); + ref.setAtReferredType(referredType); + + + String expectedString = "class EndpointSpecificationRef {\n" + + " id: testId\n" + + " href: testHref\n" + + " isRoot: true\n" + + " name: null\n" + + " role: testRole\n" + + " connectionPointSpecification: null\n" + + " _atBaseType: testBaseType\n" + + " _atSchemaLocation: testSchemaLocation\n" + + " _atType: testType\n" + + " _atReferredType: testReferredType\n" + + "}"; + + assertEquals(expectedString, ref.toString()); + } + + @Test + void testToIndentedString() throws Exception { + EndpointSpecificationRef ref = new EndpointSpecificationRef(); + + Method method = EndpointSpecificationRef.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String input = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(ref, input); + + assertEquals(expectedOutput, output); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/EntityRefTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/EntityRefTest.java new file mode 100644 index 0000000000000000000000000000000000000000..156d8c94b716a82a0e8eed48430ba5057769f2c8 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/EntityRefTest.java @@ -0,0 +1,143 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.EntityRef; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import java.lang.reflect.Method; + +public class EntityRefTest { + + @Test + void testEntityRef() { + EntityRef ref = new EntityRef(); + String id = "testId"; + String href = "testHref"; + String name = "testName"; + String referredType = "testReferredType"; + + ref.id(id); + ref.setUuid(id); + ref.href(href); + ref.name(name); + ref._atReferredType(referredType); + + assertEquals(id, ref.getId()); + assertEquals(href, ref.getHref()); + assertEquals(name, ref.getName()); + assertEquals(referredType, ref.getAtReferredType()); + + ref = new EntityRef(); + ref.setId(id); + ref.setUuid(id); + ref.setHref(href); + ref.setName(name); + ref.setAtReferredType(referredType); + + assertEquals(id, ref.getId()); + assertEquals(href, ref.getHref()); + assertEquals(name, ref.getName()); + assertEquals(referredType, ref.getAtReferredType()); + } + + @Test + void testEquals() { + String id = "testId"; + String href = "testHref"; + String name = "testName"; + String referredType = "testReferredType"; + + EntityRef ref1 = new EntityRef(); + ref1.setUuid(id); + ref1.setHref(href); + ref1.setName(name); + ref1.setAtReferredType(referredType); + + EntityRef ref2 = new EntityRef(); + ref2.setUuid(id); + ref2.setHref(href); + ref2.setName(name); + ref2.setAtReferredType(referredType); + + assertTrue(ref1.equals(ref2)); + + ref1.id("differentId"); + + assertFalse(ref1.equals(ref2)); + } + + @Test + void testHashCode() { + String id = "testId"; + String href = "testHref"; + String name = "testName"; + String referredType = "testReferredType"; + + EntityRef ref1 = new EntityRef(); + ref1.setUuid(id); + ref1.setHref(href); + ref1.setName(name); + ref1.setAtReferredType(referredType); + + EntityRef ref2 = new EntityRef(); + ref2.setUuid(id); + ref2.setHref(href); + ref2.setName(name); + ref2.setAtReferredType(referredType); + + assertEquals(ref1.hashCode(), ref2.hashCode()); + + ref1.id("differentId"); + ref1.setUuid("differentId"); + + assertNotEquals(ref1.hashCode(), ref2.hashCode()); + } + + @Test + void testToString() { + EntityRef ref = new EntityRef(); + + String id = "testId"; + String href = "testHref"; + String name = "testName"; + String baseType = "testBaseType"; + String schemaLocation = "testSchemaLocation"; + String type = "testType"; + String referredType = "testReferredType"; + + ref.id(id); + ref.setUuid(id); + ref.setHref(href); + ref.name(name); + ref.setBaseType(baseType); + ref.setSchemaLocation(schemaLocation); + ref.setType(type); + ref.setAtReferredType(referredType); + + String expectedString = "class EntityRef {\n" + + " id: testId\n" + + " href: testHref\n" + + " name: testName\n" + + " baseType: testBaseType\n" + + " schemaLocation: testSchemaLocation\n" + + " type: testType\n" + + " _atReferredType: testReferredType\n" + + "}"; + + assertEquals(expectedString, ref.toString()); + } + + @Test + void testToIndentedString() throws Exception { + EntityRef ref = new EntityRef(); + + Method method = EntityRef.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String input = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(ref, input); + + assertEquals(expectedOutput, output); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ErrorTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d567d602a1d23e50171041b9c65a0cb36829ae4c --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ErrorTest.java @@ -0,0 +1,179 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.Error; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import java.lang.reflect.Method; + +public class ErrorTest { + + @Test + void testError() { + Error error = new Error(); + String code = "testCode"; + String reason = "testReason"; + String message = "testMessage"; + String status = "testStatus"; + String referenceError = "testReferenceError"; + + error.code(code); + error.reason(reason); + error.message(message); + error.status(status); + error.referenceError(referenceError); + + assertEquals(code, error.getCode()); + assertEquals(reason, error.getReason()); + assertEquals(message, error.getMessage()); + assertEquals(status, error.getStatus()); + assertEquals(referenceError, error.getReferenceError()); + + error = new Error(); + error.setCode(code); + error.setReason(reason); + error.setMessage(message); + error.setStatus(status); + error.setReferenceError(referenceError); + + assertEquals(code, error.getCode()); + assertEquals(reason, error.getReason()); + assertEquals(message, error.getMessage()); + assertEquals(status, error.getStatus()); + assertEquals(referenceError, error.getReferenceError()); + } + + @Test + void testEquals() { + String code = "testCode"; + String reason = "testReason"; + String message = "testMessage"; + String status = "testStatus"; + String referenceError = "testReferenceError"; + + Error error1 = new Error(); + error1.setReason(reason); + error1.setMessage(message); + error1.setStatus(status); + error1.setReferenceError(referenceError); + + Error error2 = new Error(); + error2.setReason(reason); + error2.setMessage(message); + error2.setStatus(status); + error2.setReferenceError(referenceError); + + assertTrue(error1.equals(error2)); + + error1.code("differentCode"); + + assertFalse(error1.equals(error2)); + } + + @Test + void testHashCode() { + String code = "testCode"; + String reason = "testReason"; + String message = "testMessage"; + String status = "testStatus"; + String referenceError = "testReferenceError"; + + Error error1 = new Error(); + error1.setReason(reason); + error1.setMessage(message); + error1.setStatus(status); + error1.setReferenceError(referenceError); + + Error error2 = new Error(); + error2.setReason(reason); + error2.setMessage(message); + error2.setStatus(status); + error2.setReferenceError(referenceError); + + assertEquals(error1.hashCode(), error2.hashCode()); + + error1.code("differentCode"); + + assertNotEquals(error1.hashCode(), error2.hashCode()); + } + + @Test + void testToString() { + Error error = new Error(); + + String code = "testCode"; + String reason = "testReason"; + String message = "testMessage"; + String status = "testStatus"; + String referenceError = "testReferenceError"; + String baseType = "testBaseType"; + String schemaLocation = "testSchemaLocation"; + String type = "testType"; + + error.code(code); + error.reason(reason); + error.message(message); + error.status(status); + error.referenceError(referenceError); + + String expectedString = "class Error {\n" + + " code: testCode\n" + + " reason: testReason\n" + + " message: testMessage\n" + + " status: testStatus\n" + + " referenceError: testReferenceError\n" + + " _atBaseType: null\n" + + " _atSchemaLocation: null\n" + + " _atType: null\n" + + "}"; + + assertEquals(expectedString, error.toString()); + } + + @Test + void testToIndentedString() throws Exception { + Error error = new Error(); + + Method method = Error.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String input = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(error, input); + + assertEquals(expectedOutput, output); + } + + @Test + void testAtBaseType() { + Error error = new Error(); + String baseType = "testBaseType"; + error.setAtBaseType(baseType); + assertEquals(baseType, error.getAtBaseType()); + + Error newError = error._atBaseType("newTestBaseType"); + assertEquals(error, newError); + } + + @Test + void testAtSchemaLocation() { + Error error = new Error(); + String schemaLocation = "testSchemaLocation"; + error.setAtSchemaLocation(schemaLocation); + assertEquals(schemaLocation, error.getAtSchemaLocation()); + + Error newError = error._atSchemaLocation("newTestSchemaLocation"); + assertEquals(error, newError); + } + + @Test + void testAtType() { + Error error = new Error(); + String type = "testType"; + error.setAtType(type); + assertEquals(type, error.getAtType()); + + Error newError = error._atType("newTestType"); + assertEquals(error, newError); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/EventSubscriptionInputTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/EventSubscriptionInputTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b585830eddfd8b3adadb861593826a75f4a28893 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/EventSubscriptionInputTest.java @@ -0,0 +1,102 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.EventSubscriptionInput; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import java.lang.reflect.Method; + +public class EventSubscriptionInputTest { + + @Test + void testEventSubscriptionInput() { + EventSubscriptionInput input = new EventSubscriptionInput(); + String callback = "testCallback"; + String query = "testQuery"; + + input.callback(callback); + input.query(query); + + assertEquals(callback, input.getCallback()); + assertEquals(query, input.getQuery()); + + input = new EventSubscriptionInput(); + input.setCallback(callback); + input.setQuery(query); + + assertEquals(callback, input.getCallback()); + assertEquals(query, input.getQuery()); + } + + @Test + void testEquals() { + String callback = "testCallback"; + String query = "testQuery"; + + EventSubscriptionInput input1 = new EventSubscriptionInput(); + input1.setCallback(callback); + input1.setQuery(query); + + EventSubscriptionInput input2 = new EventSubscriptionInput(); + input2.setCallback(callback); + input2.setQuery(query); + + assertTrue(input1.equals(input2)); + + input1.callback("differentCallback"); + + assertFalse(input1.equals(input2)); + } + + @Test + void testHashCode() { + String callback = "testCallback"; + String query = "testQuery"; + + EventSubscriptionInput input1 = new EventSubscriptionInput(); + input1.setCallback(callback); + input1.setQuery(query); + + EventSubscriptionInput input2 = new EventSubscriptionInput(); + input2.setCallback(callback); + input2.setQuery(query); + + assertEquals(input1.hashCode(), input2.hashCode()); + + input1.callback("differentCallback"); + + assertNotEquals(input1.hashCode(), input2.hashCode()); + } + + @Test + void testToString() { + EventSubscriptionInput input = new EventSubscriptionInput(); + + String callback = "testCallback"; + String query = "testQuery"; + + input.callback(callback); + input.query(query); + + String expectedString = "class EventSubscriptionInput {\n" + + " callback: testCallback\n" + + " query: testQuery\n" + + "}"; + + assertEquals(expectedString, input.toString()); + } + + @Test + void testToIndentedString() throws Exception { + EventSubscriptionInput input = new EventSubscriptionInput(); + + Method method = EventSubscriptionInput.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String inputString = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(input, inputString); + + assertEquals(expectedOutput, output); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/EventSubscriptionTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/EventSubscriptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b28f7a8deebc49527d70598d79c0980b0de689b6 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/EventSubscriptionTest.java @@ -0,0 +1,116 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.EventSubscription; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import java.lang.reflect.Method; + +public class EventSubscriptionTest { + + @Test + void testEventSubscription() { + EventSubscription subscription = new EventSubscription(); + String id = "testId"; + String callback = "testCallback"; + String query = "testQuery"; + + subscription.id(id); + subscription.callback(callback); + subscription.query(query); + + assertEquals(id, subscription.getId()); + assertEquals(callback, subscription.getCallback()); + assertEquals(query, subscription.getQuery()); + + subscription = new EventSubscription(); + subscription.setId(id); + subscription.setCallback(callback); + subscription.setQuery(query); + + assertEquals(id, subscription.getId()); + assertEquals(callback, subscription.getCallback()); + assertEquals(query, subscription.getQuery()); + } + + @Test + void testEquals() { + String id = "testId"; + String callback = "testCallback"; + String query = "testQuery"; + + EventSubscription subscription1 = new EventSubscription(); + subscription1.setId(id); + subscription1.setCallback(callback); + subscription1.setQuery(query); + + EventSubscription subscription2 = new EventSubscription(); + subscription2.setId(id); + subscription2.setCallback(callback); + subscription2.setQuery(query); + + assertTrue(subscription1.equals(subscription2)); + + subscription1.id("differentId"); + + assertFalse(subscription1.equals(subscription2)); + } + + @Test + void testHashCode() { + String id = "testId"; + String callback = "testCallback"; + String query = "testQuery"; + + EventSubscription subscription1 = new EventSubscription(); + subscription1.setId(id); + subscription1.setCallback(callback); + subscription1.setQuery(query); + + EventSubscription subscription2 = new EventSubscription(); + subscription2.setId(id); + subscription2.setCallback(callback); + subscription2.setQuery(query); + + assertEquals(subscription1.hashCode(), subscription2.hashCode()); + + subscription1.id("differentId"); + + assertNotEquals(subscription1.hashCode(), subscription2.hashCode()); + } + + @Test + void testToString() { + EventSubscription subscription = new EventSubscription(); + + String id = "testId"; + String callback = "testCallback"; + String query = "testQuery"; + + subscription.id(id); + subscription.callback(callback); + subscription.query(query); + + String expectedString = "class EventSubscription {\n" + + " id: testId\n" + + " callback: testCallback\n" + + " query: testQuery\n" + + "}"; + + assertEquals(expectedString, subscription.toString()); + } + + @Test + void testToIndentedString() throws Exception { + EventSubscription subscription = new EventSubscription(); + + Method method = EventSubscription.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String input = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(subscription, input); + + assertEquals(expectedOutput, output); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobCreateEventPayloadTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobCreateEventPayloadTest.java new file mode 100644 index 0000000000000000000000000000000000000000..87641b196d986a3b81f13bcfd9cef23e46c1ffbb --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobCreateEventPayloadTest.java @@ -0,0 +1,87 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.ExportJob; +import org.etsi.osl.tmf.rcm634.model.ExportJobCreateEventPayload; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Method; +import static org.junit.jupiter.api.Assertions.*; + +public class ExportJobCreateEventPayloadTest { + + @Test + void testExportJobCreateEventPayload() { + ExportJobCreateEventPayload payload = new ExportJobCreateEventPayload(); + ExportJob job = new ExportJob(); + job.setId("testId"); + + payload.exportJob(job); + assertEquals(job, payload.getExportJob()); + + payload = new ExportJobCreateEventPayload(); + payload.setExportJob(job); + assertEquals(job, payload.getExportJob()); + } + + @Test + void testEquals() { + ExportJobCreateEventPayload payload1 = new ExportJobCreateEventPayload(); + ExportJob job = new ExportJob(); + job.setId("testId"); + payload1.setExportJob(job); + + ExportJobCreateEventPayload payload2 = new ExportJobCreateEventPayload(); + payload2.setExportJob(job); + + assertTrue(payload1.equals(payload2)); + + payload1.setExportJob(new ExportJob()); + + assertFalse(payload1.equals(payload2)); + } + + @Test + void testHashCode() { + ExportJobCreateEventPayload payload1 = new ExportJobCreateEventPayload(); + ExportJob job = new ExportJob(); + job.setId("testId"); + payload1.setExportJob(job); + + ExportJobCreateEventPayload payload2 = new ExportJobCreateEventPayload(); + payload2.setExportJob(job); + + assertEquals(payload1.hashCode(), payload2.hashCode()); + + payload1.setExportJob(new ExportJob()); + + assertNotEquals(payload1.hashCode(), payload2.hashCode()); + } + + @Test + void testToString() { + ExportJobCreateEventPayload payload = new ExportJobCreateEventPayload(); + ExportJob job = new ExportJob(); + job.setId("testId"); + payload.setExportJob(job); + + String expectedString = "class ExportJobCreateEventPayload {\n" + + " exportJob: class ExportJob {\n" + + " id: testId\n" + + " href: null\n" + + " completionDate: null\n" + + " contentType: null\n" + + " creationDate: null\n" + + " errorLog: null\n" + + " path: null\n" + + " query: null\n" + + " url: null\n" + + " status: null\n" + + " _atBaseType: null\n" + + " _atSchemaLocation: null\n" + + " _atType: null\n" + + " }\n" + + "}"; + + assertEquals(expectedString, payload.toString()); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobCreateEventTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobCreateEventTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1c6eb60d03c49d6322076002f45ad6cb5e90b886 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobCreateEventTest.java @@ -0,0 +1,180 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.ExportJobCreateEvent; +import org.etsi.osl.tmf.rcm634.model.ExportJobCreateEventPayload; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Method; +import java.time.OffsetDateTime; +import static org.junit.jupiter.api.Assertions.*; + +public class ExportJobCreateEventTest { + + @Test + void testExportJobCreateEvent() { + ExportJobCreateEvent event = new ExportJobCreateEvent(); + String id = "testId"; + String href = "testHref"; + String eventId = "testEventId"; + OffsetDateTime eventTime = OffsetDateTime.now(); + String eventType = "testEventType"; + String correlationId = "testCorrelationId"; + String domain = "testDomain"; + String title = "testTitle"; + String description = "testDescription"; + String priority = "testPriority"; + OffsetDateTime timeOccurred = OffsetDateTime.now(); + ExportJobCreateEventPayload eventPayload = new ExportJobCreateEventPayload(); + + event.id(id); + event.href(href); + event.eventId(eventId); + event.eventTime(eventTime); + event.eventType(eventType); + event.correlationId(correlationId); + event.domain(domain); + event.title(title); + event.description(description); + event.priority(priority); + event.timeOcurred(timeOccurred); + event.event(eventPayload); + + assertEquals(id, event.getId()); + assertEquals(href, event.getHref()); + assertEquals(eventId, event.getEventId()); + assertEquals(eventTime, event.getEventTime()); + assertEquals(eventType, event.getEventType()); + assertEquals(correlationId, event.getCorrelationId()); + assertEquals(domain, event.getDomain()); + assertEquals(title, event.getTitle()); + assertEquals(description, event.getDescription()); + assertEquals(priority, event.getPriority()); + assertEquals(timeOccurred, event.getTimeOcurred()); + assertEquals(eventPayload, event.getEvent()); + } + + @Test + void testEquals() { + ExportJobCreateEvent event1 = new ExportJobCreateEvent(); + event1.setId("testId"); + event1.setHref("testHref"); + event1.setEventId("testEventId"); + event1.setEventTime(OffsetDateTime.now()); + event1.setEventType("testEventType"); + event1.setCorrelationId("testCorrelationId"); + event1.setDomain("testDomain"); + event1.setTitle("testTitle"); + event1.setDescription("testDescription"); + event1.setPriority("testPriority"); + event1.setTimeOcurred(OffsetDateTime.now()); + event1.setEvent(new ExportJobCreateEventPayload()); + + ExportJobCreateEvent event2 = new ExportJobCreateEvent(); + event2.setId("testId"); + event2.setHref("testHref"); + event2.setEventId("testEventId"); + event2.setEventTime(event1.getEventTime()); + event2.setEventType("testEventType"); + event2.setCorrelationId("testCorrelationId"); + event2.setDomain("testDomain"); + event2.setTitle("testTitle"); + event2.setDescription("testDescription"); + event2.setPriority("testPriority"); + event2.setTimeOcurred(event1.getTimeOcurred()); + event2.setEvent(new ExportJobCreateEventPayload()); + + assertTrue(event1.equals(event2)); + + event1.setId("differentId"); + + assertFalse(event1.equals(event2)); + } + + @Test + void testHashCode() { + ExportJobCreateEvent event1 = new ExportJobCreateEvent(); + event1.setId("testId"); + event1.setHref("testHref"); + event1.setEventId("testEventId"); + event1.setEventTime(OffsetDateTime.now()); + event1.setEventType("testEventType"); + event1.setCorrelationId("testCorrelationId"); + event1.setDomain("testDomain"); + event1.setTitle("testTitle"); + event1.setDescription("testDescription"); + event1.setPriority("testPriority"); + event1.setTimeOcurred(OffsetDateTime.now()); + event1.setEvent(new ExportJobCreateEventPayload()); + + ExportJobCreateEvent event2 = new ExportJobCreateEvent(); + event2.setId("testId"); + event2.setHref("testHref"); + event2.setEventId("testEventId"); + event2.setEventTime(event1.getEventTime()); + event2.setEventType("testEventType"); + event2.setCorrelationId("testCorrelationId"); + event2.setDomain("testDomain"); + event2.setTitle("testTitle"); + event2.setDescription("testDescription"); + event2.setPriority("testPriority"); + event2.setTimeOcurred(event1.getTimeOcurred()); + event2.setEvent(new ExportJobCreateEventPayload()); + + assertEquals(event1.hashCode(), event2.hashCode()); + + event1.setId("differentId"); + + assertNotEquals(event1.hashCode(), event2.hashCode()); + } + + @Test + void testToString() { + ExportJobCreateEvent event = new ExportJobCreateEvent(); + event.setId("testId"); + event.setHref("testHref"); + event.setEventId("testEventId"); + event.setEventTime(OffsetDateTime.parse("2024-01-19T17:02:03.289504717+02:00")); + event.setEventType("testEventType"); + event.setCorrelationId("testCorrelationId"); + event.setDomain("testDomain"); + event.setTitle("testTitle"); + event.setDescription("testDescription"); + event.setPriority("testPriority"); + event.setTimeOcurred(OffsetDateTime.parse("2024-01-19T17:02:03.289527665+02:00")); + event.setEvent(new ExportJobCreateEventPayload()); + + String expectedString = "class ExportJobCreateEvent {\n" + + " id: testId\n" + + " href: testHref\n" + + " eventId: testEventId\n" + + " eventTime: 2024-01-19T17:02:03.289504717+02:00\n" + + " eventType: testEventType\n" + + " correlationId: testCorrelationId\n" + + " domain: testDomain\n" + + " title: testTitle\n" + + " description: testDescription\n" + + " priority: testPriority\n" + + " timeOcurred: 2024-01-19T17:02:03.289527665+02:00\n" + + " event: class ExportJobCreateEventPayload {\n" + + " exportJob: null\n" + + " }\n" + + "}"; + + assertEquals(expectedString, event.toString()); + } + + @Test + void testToIndentedString() throws Exception { + ExportJobCreateEvent event = new ExportJobCreateEvent(); + + Method method = ExportJobCreateEvent.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String input = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(event, input); + + assertEquals(expectedOutput, output); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobCreateTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobCreateTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8333fe9498c480f200ef02cc64c204c512e2ff7e --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobCreateTest.java @@ -0,0 +1,231 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.ExportJobCreate; +import org.etsi.osl.tmf.rcm634.model.JobStateType; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Method; +import java.time.OffsetDateTime; +import static org.junit.jupiter.api.Assertions.*; + +public class ExportJobCreateTest { + + @Test + void testExportJobCreate() { + ExportJobCreate jobCreate = new ExportJobCreate(); + String query = "testQuery"; + OffsetDateTime completionDate = OffsetDateTime.now(); + OffsetDateTime creationDate = OffsetDateTime.now(); + String contentType = "testContentType"; + String errorLog = "testErrorLog"; + String path = "testPath"; + String url = "testUrl"; + + jobCreate.query(query); + jobCreate.setCompletionDate(completionDate); + jobCreate.setCreationDate(creationDate); + jobCreate.setContentType(contentType); + jobCreate.setErrorLog(errorLog); + jobCreate.setPath(path); + jobCreate.setUrl(url); + + assertEquals(query, jobCreate.getQuery()); + assertEquals(completionDate, jobCreate.getCompletionDate()); + assertEquals(creationDate, jobCreate.getCreationDate()); + assertEquals(contentType, jobCreate.getContentType()); + assertEquals(errorLog, jobCreate.getErrorLog()); + assertEquals(path, jobCreate.getPath()); + assertEquals(url, jobCreate.getUrl()); + + jobCreate = new ExportJobCreate(); + jobCreate.setQuery(query); + jobCreate.setCompletionDate(completionDate); + jobCreate.setCreationDate(creationDate); + jobCreate.setContentType(contentType); + jobCreate.setErrorLog(errorLog); + jobCreate.setPath(path); + jobCreate.setUrl(url); + + assertEquals(query, jobCreate.getQuery()); + assertEquals(completionDate, jobCreate.getCompletionDate()); + assertEquals(creationDate, jobCreate.getCreationDate()); + assertEquals(contentType, jobCreate.getContentType()); + assertEquals(errorLog, jobCreate.getErrorLog()); + assertEquals(path, jobCreate.getPath()); + assertEquals(url, jobCreate.getUrl()); + } + + @Test + void testStatus() { + ExportJobCreate jobCreate = new ExportJobCreate(); + JobStateType status = JobStateType.RUNNING; + jobCreate.setStatus(status); + assertEquals(status, jobCreate.getStatus()); + + ExportJobCreate newJobCreate = jobCreate.status(JobStateType.FAILED); + assertEquals(jobCreate, newJobCreate); + } + + @Test + void testAtBaseType() { + ExportJobCreate jobCreate = new ExportJobCreate(); + String baseType = "testBaseType"; + jobCreate.setAtBaseType(baseType); + assertEquals(baseType, jobCreate.getAtBaseType()); + + ExportJobCreate newJobCreate = jobCreate._atBaseType("newTestBaseType"); + assertEquals(jobCreate, newJobCreate); + } + + @Test + void testAtSchemaLocation() { + ExportJobCreate jobCreate = new ExportJobCreate(); + String schemaLocation = "testSchemaLocation"; + jobCreate.setAtSchemaLocation(schemaLocation); + assertEquals(schemaLocation, jobCreate.getAtSchemaLocation()); + + ExportJobCreate newJobCreate = jobCreate._atSchemaLocation("newTestSchemaLocation"); + assertEquals(jobCreate, newJobCreate); + } + + @Test + void testAtType() { + ExportJobCreate jobCreate = new ExportJobCreate(); + String type = "testType"; + jobCreate.setAtType(type); + assertEquals(type, jobCreate.getAtType()); + + ExportJobCreate newJobCreate = jobCreate._atType("newTestType"); + assertEquals(jobCreate, newJobCreate); + } + + @Test + void testErrorLog() { + ExportJobCreate jobCreate = new ExportJobCreate(); + String errorLog = "testErrorLog"; + jobCreate.setErrorLog(errorLog); + assertEquals(errorLog, jobCreate.getErrorLog()); + + ExportJobCreate newJobCreate = jobCreate.errorLog("newTestErrorLog"); + assertEquals(jobCreate, newJobCreate); + } + + @Test + void testPath() { + ExportJobCreate jobCreate = new ExportJobCreate(); + String path = "testPath"; + jobCreate.setPath(path); + assertEquals(path, jobCreate.getPath()); + + ExportJobCreate newJobCreate = jobCreate.path("newTestPath"); + assertEquals(jobCreate, newJobCreate); + } + + @Test + void testUrl() { + ExportJobCreate jobCreate = new ExportJobCreate(); + String url = "testUrl"; + jobCreate.setUrl(url); + assertEquals(url, jobCreate.getUrl()); + + ExportJobCreate newJobCreate = jobCreate.url("newTestUrl"); + assertEquals(jobCreate, newJobCreate); + } + + @Test + void testEquals() { + ExportJobCreate jobCreate1 = new ExportJobCreate(); + jobCreate1.setQuery("testQuery"); + jobCreate1.setCompletionDate(OffsetDateTime.now()); + jobCreate1.setCreationDate(OffsetDateTime.now()); + jobCreate1.setContentType("testContentType"); + jobCreate1.setErrorLog("testErrorLog"); + jobCreate1.setPath("testPath"); + jobCreate1.setUrl("testUrl"); + + ExportJobCreate jobCreate2 = new ExportJobCreate(); + jobCreate2.setQuery("testQuery"); + jobCreate2.setCompletionDate(jobCreate1.getCompletionDate()); + jobCreate2.setCreationDate(jobCreate1.getCreationDate()); + jobCreate2.setContentType("testContentType"); + jobCreate2.setErrorLog("testErrorLog"); + jobCreate2.setPath("testPath"); + jobCreate2.setUrl("testUrl"); + + assertTrue(jobCreate1.equals(jobCreate2)); + + jobCreate1.setQuery("differentQuery"); + + assertFalse(jobCreate1.equals(jobCreate2)); + } + + @Test + void testHashCode() { + ExportJobCreate jobCreate1 = new ExportJobCreate(); + jobCreate1.setQuery("testQuery"); + jobCreate1.setCompletionDate(OffsetDateTime.now()); + jobCreate1.setCreationDate(OffsetDateTime.now()); + jobCreate1.setContentType("testContentType"); + jobCreate1.setErrorLog("testErrorLog"); + jobCreate1.setPath("testPath"); + jobCreate1.setUrl("testUrl"); + + ExportJobCreate jobCreate2 = new ExportJobCreate(); + jobCreate2.setQuery("testQuery"); + jobCreate2.setCompletionDate(jobCreate1.getCompletionDate()); + jobCreate2.setCreationDate(jobCreate1.getCreationDate()); + jobCreate2.setContentType("testContentType"); + jobCreate2.setErrorLog("testErrorLog"); + jobCreate2.setPath("testPath"); + jobCreate2.setUrl("testUrl"); + + assertEquals(jobCreate1.hashCode(), jobCreate2.hashCode()); + + jobCreate1.setQuery("differentQuery"); + + assertNotEquals(jobCreate1.hashCode(), jobCreate2.hashCode()); + } + + @Test + void testToString() { + ExportJobCreate jobCreate = new ExportJobCreate(); + jobCreate.setQuery("testQuery"); + jobCreate.setCompletionDate(OffsetDateTime.parse("2024-01-19T17:02:03.289504717+02:00")); + jobCreate.setCreationDate(OffsetDateTime.parse("2024-01-19T17:02:03.289527665+02:00")); + jobCreate.setContentType("testContentType"); + jobCreate.setErrorLog("testErrorLog"); + jobCreate.setPath("testPath"); + jobCreate.setUrl("testUrl"); + + String expectedString = "class ExportJobCreate {\n" + + " completionDate: 2024-01-19T17:02:03.289504717+02:00\n" + + " contentType: testContentType\n" + + " creationDate: 2024-01-19T17:02:03.289527665+02:00\n" + + " errorLog: testErrorLog\n" + + " path: testPath\n" + + " query: testQuery\n" + + " url: testUrl\n" + + " status: null\n" + + " _atBaseType: null\n" + + " _atSchemaLocation: null\n" + + " _atType: null\n" + + "}"; + + assertEquals(expectedString, jobCreate.toString()); + } + + @Test + void testToIndentedString() throws Exception { + ExportJobCreate jobCreate = new ExportJobCreate(); + + Method method = ExportJobCreate.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String input = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(jobCreate, input); + + assertEquals(expectedOutput, output); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobStateChangeEventTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobStateChangeEventTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d8bb2bbd4ac9c275b20f3ca55781a978bc638c12 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobStateChangeEventTest.java @@ -0,0 +1,196 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.ExportJob; +import org.etsi.osl.tmf.rcm634.model.ExportJobStateChangeEvent; +import org.etsi.osl.tmf.rcm634.model.ExportJobStateChangeEventPayload; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Method; +import java.time.OffsetDateTime; +import static org.junit.jupiter.api.Assertions.*; + +public class ExportJobStateChangeEventTest { + + @Test + void testExportJobStateChangeEvent() { + ExportJobStateChangeEvent event = new ExportJobStateChangeEvent(); + String id = "testId"; + String href = "testHref"; + String eventId = "testEventId"; + OffsetDateTime eventTime = OffsetDateTime.now(); + String eventType = "testEventType"; + String correlationId = "testCorrelationId"; + String domain = "testDomain"; + String title = "testTitle"; + String description = "testDescription"; + String priority = "testPriority"; + OffsetDateTime timeOccurred = OffsetDateTime.now(); + ExportJobStateChangeEventPayload eventPayload = new ExportJobStateChangeEventPayload(); + + event.id(id); + event.href(href); + event.eventId(eventId); + event.eventTime(eventTime); + event.eventType(eventType); + event.correlationId(correlationId); + event.domain(domain); + event.title(title); + event.description(description); + event.priority(priority); + event.timeOcurred(timeOccurred); + event.event(eventPayload); + + assertEquals(id, event.getId()); + assertEquals(href, event.getHref()); + assertEquals(eventId, event.getEventId()); + assertEquals(eventTime, event.getEventTime()); + assertEquals(eventType, event.getEventType()); + assertEquals(correlationId, event.getCorrelationId()); + assertEquals(domain, event.getDomain()); + assertEquals(title, event.getTitle()); + assertEquals(description, event.getDescription()); + assertEquals(priority, event.getPriority()); + assertEquals(timeOccurred, event.getTimeOcurred()); + assertEquals(eventPayload, event.getEvent()); + } + + @Test + void testEquals() { + ExportJobStateChangeEvent event1 = new ExportJobStateChangeEvent(); + event1.setId("testId"); + event1.setHref("testHref"); + event1.setEventId("testEventId"); + event1.setEventTime(OffsetDateTime.now()); + event1.setEventType("testEventType"); + event1.setCorrelationId("testCorrelationId"); + event1.setDomain("testDomain"); + event1.setTitle("testTitle"); + event1.setDescription("testDescription"); + event1.setPriority("testPriority"); + event1.setTimeOcurred(OffsetDateTime.now()); + event1.setEvent(new ExportJobStateChangeEventPayload()); + + ExportJobStateChangeEvent event2 = new ExportJobStateChangeEvent(); + event2.setId("testId"); + event2.setHref("testHref"); + event2.setEventId("testEventId"); + event2.setEventTime(event1.getEventTime()); + event2.setEventType("testEventType"); + event2.setCorrelationId("testCorrelationId"); + event2.setDomain("testDomain"); + event2.setTitle("testTitle"); + event2.setDescription("testDescription"); + event2.setPriority("testPriority"); + event2.setTimeOcurred(event1.getTimeOcurred()); + event2.setEvent(new ExportJobStateChangeEventPayload()); + + assertTrue(event1.equals(event2)); + + event1.setId("differentId"); + + assertFalse(event1.equals(event2)); + } + + @Test + void testHashCode() { + ExportJobStateChangeEvent event1 = new ExportJobStateChangeEvent(); + event1.setId("testId"); + event1.setHref("testHref"); + event1.setEventId("testEventId"); + event1.setEventTime(OffsetDateTime.now()); + event1.setEventType("testEventType"); + event1.setCorrelationId("testCorrelationId"); + event1.setDomain("testDomain"); + event1.setTitle("testTitle"); + event1.setDescription("testDescription"); + event1.setPriority("testPriority"); + event1.setTimeOcurred(OffsetDateTime.now()); + event1.setEvent(new ExportJobStateChangeEventPayload()); + + ExportJobStateChangeEvent event2 = new ExportJobStateChangeEvent(); + event2.setId("testId"); + event2.setHref("testHref"); + event2.setEventId("testEventId"); + event2.setEventTime(event1.getEventTime()); + event2.setEventType("testEventType"); + event2.setCorrelationId("testCorrelationId"); + event2.setDomain("testDomain"); + event2.setTitle("testTitle"); + event2.setDescription("testDescription"); + event2.setPriority("testPriority"); + event2.setTimeOcurred(event1.getTimeOcurred()); + event2.setEvent(new ExportJobStateChangeEventPayload()); + + assertEquals(event1.hashCode(), event2.hashCode()); + + event1.setId("differentId"); + + assertNotEquals(event1.hashCode(), event2.hashCode()); + } + + @Test + void testToString() { + ExportJobStateChangeEvent event = new ExportJobStateChangeEvent(); + event.setId("testId"); + event.setHref("testHref"); + event.setEventId("testEventId"); + event.setEventTime(OffsetDateTime.parse("2024-01-19T17:02:03.289504717+02:00")); + event.setEventType("testEventType"); + event.setCorrelationId("testCorrelationId"); + event.setDomain("testDomain"); + event.setTitle("testTitle"); + event.setDescription("testDescription"); + event.setPriority("testPriority"); + event.setTimeOcurred(OffsetDateTime.parse("2024-01-19T17:02:03.289527665+02:00")); + event.setEvent(new ExportJobStateChangeEventPayload()); + + String expectedString = "class ExportJobStateChangeEvent {\n" + + " id: testId\n" + + " href: testHref\n" + + " eventId: testEventId\n" + + " eventTime: 2024-01-19T17:02:03.289504717+02:00\n" + + " eventType: testEventType\n" + + " correlationId: testCorrelationId\n" + + " domain: testDomain\n" + + " title: testTitle\n" + + " description: testDescription\n" + + " priority: testPriority\n" + + " timeOcurred: 2024-01-19T17:02:03.289527665+02:00\n" + + " event: class ExportJobStateChangeEventPayload {\n" + + " exportJob: null\n" + + " }\n" + + "}"; + + assertEquals(expectedString, event.toString()); + } + + @Test + void testToIndentedString() throws Exception { + ExportJobStateChangeEvent event = new ExportJobStateChangeEvent(); + + Method method = ExportJobStateChangeEvent.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String input = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(event, input); + + assertEquals(expectedOutput, output); + } + + @Test + void testExportJob() { + ExportJobStateChangeEventPayload payload = new ExportJobStateChangeEventPayload(); + ExportJob job = new ExportJob(); + job.setId("testId"); + payload.setExportJob(job); + assertEquals(job, payload.getExportJob()); + + ExportJob newJob = new ExportJob(); + newJob.setId("newTestId"); + ExportJobStateChangeEventPayload newPayload = payload.exportJob(newJob); + assertEquals(payload, newPayload); + assertEquals(newJob, payload.getExportJob()); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobTest.java new file mode 100644 index 0000000000000000000000000000000000000000..07567d68d5fc7194e021d26e33a204a838dec0f1 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ExportJobTest.java @@ -0,0 +1,266 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.rcm634.model.ExportJob; +import org.etsi.osl.tmf.rcm634.model.JobStateType; +import org.junit.jupiter.api.Test; +import java.time.OffsetDateTime; +import static org.junit.jupiter.api.Assertions.*; + +public class ExportJobTest { + + @Test + void testExportJob() { + ExportJob job = new ExportJob(); + String id = "testId"; + String query = "testQuery"; + OffsetDateTime completionDate = OffsetDateTime.now(); + OffsetDateTime creationDate = OffsetDateTime.now(); + String contentType = "testContentType"; + String errorLog = "testErrorLog"; + String path = "testPath"; + String url = "testUrl"; + + job.id(id); + job.query(query); + job.setCompletionDate(completionDate); + job.setCreationDate(creationDate); + job.setContentType(contentType); + job.setErrorLog(errorLog); + job.setPath(path); + job.setUrl(url); + + assertEquals(id, job.getId()); + assertEquals(query, job.getQuery()); + assertEquals(completionDate, job.getCompletionDate()); + assertEquals(creationDate, job.getCreationDate()); + assertEquals(contentType, job.getContentType()); + assertEquals(errorLog, job.getErrorLog()); + assertEquals(path, job.getPath()); + assertEquals(url, job.getUrl()); + + job = new ExportJob(); + job.setId(id); + job.setQuery(query); + job.setCompletionDate(completionDate); + job.setCreationDate(creationDate); + job.setContentType(contentType); + job.setErrorLog(errorLog); + job.setPath(path); + job.setUrl(url); + + assertEquals(id, job.getId()); + assertEquals(query, job.getQuery()); + assertEquals(completionDate, job.getCompletionDate()); + assertEquals(creationDate, job.getCreationDate()); + assertEquals(contentType, job.getContentType()); + assertEquals(errorLog, job.getErrorLog()); + assertEquals(path, job.getPath()); + assertEquals(url, job.getUrl()); + } + + @Test + void testEquals() { + String id = "testId"; + String callback = "testCallback"; + String query = "testQuery"; + OffsetDateTime completionDate = OffsetDateTime.now(); + OffsetDateTime creationDate = OffsetDateTime.now(); + String contentType = "testContentType"; + String errorLog = "testErrorLog"; + String path = "testPath"; + String url = "testUrl"; + + ExportJob job1 = new ExportJob(); + job1.setId(id); + job1.setQuery(query); + job1.setCompletionDate(completionDate); + job1.setCreationDate(creationDate); + job1.setContentType(contentType); + job1.setErrorLog(errorLog); + job1.setPath(path); + job1.setUrl(url); + + ExportJob job2 = new ExportJob(); + job2.setId(id); + job2.setQuery(query); + job2.setCompletionDate(completionDate); + job2.setCreationDate(creationDate); + job2.setContentType(contentType); + job2.setErrorLog(errorLog); + job2.setPath(path); + job2.setUrl(url); + + assertTrue(job1.equals(job2)); + + job1.id("differentId"); + + assertFalse(job1.equals(job2)); + } + + @Test + void testHashCode() { + String id = "testId"; + String callback = "testCallback"; + String query = "testQuery"; + OffsetDateTime completionDate = OffsetDateTime.now(); + OffsetDateTime creationDate = OffsetDateTime.now(); + String contentType = "testContentType"; + String errorLog = "testErrorLog"; + String path = "testPath"; + String url = "testUrl"; + + ExportJob job1 = new ExportJob(); + job1.setId(id); + job1.setQuery(query); + job1.setCompletionDate(completionDate); + job1.setCreationDate(creationDate); + job1.setContentType(contentType); + job1.setErrorLog(errorLog); + job1.setPath(path); + job1.setUrl(url); + + ExportJob job2 = new ExportJob(); + job2.setId(id); + job2.setQuery(query); + job2.setCompletionDate(completionDate); + job2.setCreationDate(creationDate); + job2.setContentType(contentType); + job2.setErrorLog(errorLog); + job2.setPath(path); + job2.setUrl(url); + + assertEquals(job1.hashCode(), job2.hashCode()); + + job1.id("differentId"); + + assertNotEquals(job1.hashCode(), job2.hashCode()); + } + + @Test + void testToString() { + ExportJob job = new ExportJob(); + + String id = "testId"; + String callback = "testCallback"; + String query = "testQuery"; + OffsetDateTime completionDate = OffsetDateTime.parse("2024-01-19T16:35:07.730526064+02:00"); + OffsetDateTime creationDate = OffsetDateTime.parse("2024-01-19T16:35:07.731493435+02:00"); + String contentType = "testContentType"; + String errorLog = "testErrorLog"; + String path = "testPath"; + String url = "testUrl"; + + job.id(id); + job.query(query); + job.setCompletionDate(completionDate); + job.setCreationDate(creationDate); + job.setContentType(contentType); + job.setErrorLog(errorLog); + job.setPath(path); + job.setUrl(url); + + String expectedString = "class ExportJob {\n" + + " id: testId\n" + + " href: null\n" + + " completionDate: 2024-01-19T16:35:07.730526064+02:00\n" + + " contentType: testContentType\n" + + " creationDate: 2024-01-19T16:35:07.731493435+02:00\n" + + " errorLog: testErrorLog\n" + + " path: testPath\n" + + " query: testQuery\n" + + " url: testUrl\n" + + " status: null\n" + + " _atBaseType: null\n" + + " _atSchemaLocation: null\n" + + " _atType: null\n" + + "}"; + + assertEquals(expectedString, job.toString()); + } + + @Test + void testHref() { + ExportJob job = new ExportJob(); + String href = "testHref"; + job.setHref(href); + assertEquals(href, job.getHref()); + + ExportJob newJob = job.href("newTestHref"); + assertEquals(job, newJob); + } + + @Test + void testCompletionDate() { + ExportJob job = new ExportJob(); + OffsetDateTime completionDate = OffsetDateTime.now(); + job.setCompletionDate(completionDate); + assertEquals(completionDate, job.getCompletionDate()); + + ExportJob newJob = job.completionDate(OffsetDateTime.now()); + assertEquals(job, newJob); + } + + @Test + void testContentType() { + ExportJob job = new ExportJob(); + String contentType = "testContentType"; + job.setContentType(contentType); + assertEquals(contentType, job.getContentType()); + + ExportJob newJob = job.contentType("newTestContentType"); + assertEquals(job, newJob); + } + + @Test + void testCreationDate() { + ExportJob job = new ExportJob(); + OffsetDateTime creationDate = OffsetDateTime.now(); + job.setCreationDate(creationDate); + assertEquals(creationDate, job.getCreationDate()); + } + + @Test + void testStatus() { + ExportJob job = new ExportJob(); + JobStateType status = JobStateType.RUNNING; + job.setStatus(status); + assertEquals(status, job.getStatus()); + + ExportJob newJob = job.status(JobStateType.FAILED); + assertEquals(job, newJob); + } + + @Test + void testAtBaseType() { + ExportJob job = new ExportJob(); + String baseType = "testBaseType"; + job.setAtBaseType(baseType); + assertEquals(baseType, job.getAtBaseType()); + + ExportJob newJob = job._atBaseType("newTestBaseType"); + assertEquals(job, newJob); + } + + @Test + void testAtSchemaLocation() { + ExportJob job = new ExportJob(); + String schemaLocation = "testSchemaLocation"; + job.setAtSchemaLocation(schemaLocation); + assertEquals(schemaLocation, job.getAtSchemaLocation()); + + ExportJob newJob = job._atSchemaLocation("newTestSchemaLocation"); + assertEquals(job, newJob); + } + + @Test + void testAtType() { + ExportJob job = new ExportJob(); + String type = "testType"; + job.setAtType(type); + assertEquals(type, job.getAtType()); + + ExportJob newJob = job._atType("newTestType"); + assertEquals(job, newJob); + } + +} \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..1aa8d1ad93d816b0a087ba4380fad137c9238490 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationApiControllerTest.java @@ -0,0 +1,257 @@ +package org.etsi.osl.services.api.rcm634; + +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.transaction.Transactional; +import org.apache.commons.io.IOUtils; +import org.etsi.osl.tmf.JsonUtils; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.rcm634.api.ResourceSpecificationApiController; +import org.etsi.osl.tmf.rcm634.model.*; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockHttpServletRequest; +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.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.List; +import java.util.Optional; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + + +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureTestDatabase +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ResourceSpecificationApiControllerTest { + + @Autowired + private MockMvc mvc; + + @InjectMocks + ResourceSpecificationApiController resourceSpecificationApiController; + + @Mock + ResourceSpecificationRepoService resourceSpecificationRepoService; + + @Mock + ResourceSpecification resourceSpecification; + + @BeforeEach + public void init() { + MockitoAnnotations.initMocks(this); + } + + + // Test CREATE with role ADMIN + @Test + @WithMockUser(authorities = {"ROLE_ADMIN"}) + public void testCreateResourceSpecificationAdmin() throws Exception { + + // Testing a valid physical resource specification at the correct endpoint + File resourceSpecFile = new File("src/test/resources/testPhysicalResourceSpec.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String resourceSpecString = IOUtils.toString(in, "UTF-8"); + PhysicalResourceSpecificationCreate physicalResourceSpecCreate = JsonUtils.toJsonObj(resourceSpecString, PhysicalResourceSpecificationCreate.class); + + mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(physicalResourceSpecCreate))) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Resource Spec"))) + .andExpect(status().isOk()) + .andReturn().getResponse(); + + + LogicalResourceSpecificationCreate logicalResourceSpecificationCreate = new LogicalResourceSpecificationCreate(); + logicalResourceSpecificationCreate.setName("Test Logical Resource Spec"); + mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(logicalResourceSpecificationCreate))) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Logical Resource Spec"))) + .andExpect(status().isOk()) + .andReturn().getResponse(); + + + ResourceFunctionSpecificationCreate resourceFunctionSpecificationCreate = new ResourceFunctionSpecificationCreate(); + resourceFunctionSpecificationCreate.setName("Test Resource Function Specification"); + resourceFunctionSpecificationCreate.setType("ResourceFunctionSpecification"); + mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(resourceFunctionSpecificationCreate))) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Resource Function Specification"))) + .andExpect(status().isOk()) + .andReturn().getResponse(); + + // Testing a valid physical resource specification wrong endpoint + mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecificat") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(physicalResourceSpecCreate))) + .andExpect(status().isNotFound()) + .andReturn().getResponse(); + + // Testing a valid physical resource specification wrong payload correct endpoint + String wrongStringPayload = "random string as payload"; + byte[] wrongPayload = wrongStringPayload.getBytes(); + + mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(wrongPayload)) + .andExpect(status().isBadRequest()) + .andReturn().getResponse(); + } + + // Test CREATE with incorrect role USER + @Test + @WithMockUser(authorities = {"ROLE_USER"}) + public void testCreateResourceSpecificationUser() throws Exception { + // Testing a valid physical resource specification + File physicalResourceSpecFile = new File("src/test/resources/testResourceSpec.json"); + InputStream in = new FileInputStream(physicalResourceSpecFile); + String physicalResourceSpecString = IOUtils.toString(in, "UTF-8"); + LogicalResourceSpecificationCreate physicalResourceSpecCreate = JsonUtils.toJsonObj(physicalResourceSpecString, LogicalResourceSpecificationCreate.class); + mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(physicalResourceSpecCreate))) + .andExpect(status().isForbidden()) + .andReturn().getResponse(); + + } + + // Test DELETE method with role ADMIN + @Test + @WithMockUser(authorities = {"ROLE_ADMIN"}) + public void testDeleteResourceSpecificationAdmin() throws Exception { + ResourceFunctionSpecificationCreate resourceFunctionSpecificationCreate = new ResourceFunctionSpecificationCreate(); + resourceFunctionSpecificationCreate.setName("Test Resource Function Specification"); + resourceFunctionSpecificationCreate.setType("ResourceFunctionSpecification"); + String createdSpecificationString = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(resourceFunctionSpecificationCreate))) + .andReturn().getResponse().getContentAsString(); + System.out.println(createdSpecificationString); + + ResourceSpecification createdSpecification = JsonUtils.toJsonObj(createdSpecificationString, ResourceFunctionSpecification.class); + String idToBeDeleted = createdSpecification.getId(); + + mvc.perform(MockMvcRequestBuilders.delete("/resourceCatalogManagement/v4/resourceSpecification/" + idToBeDeleted) + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(null))) + .andExpect(status().isOk()) + .andReturn().getResponse(); + + } + + // Test DELETE method with incorrect role USER + @Test + @WithMockUser(authorities = {"ROLE_USER"}) + public void testDeleteResourceSpecificationUser() throws Exception { + mvc.perform(MockMvcRequestBuilders.delete("/resourceCatalogManagement/v4/resourceSpecification/idToBeDeleted") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(null))) + .andExpect(status().isForbidden()) + .andReturn().getResponse(); + + } + + // Test GET by id method with no role + @Test + @WithMockUser(authorities = {"ROLE_ADMIN"}) + public void testRetrieveResourceSpecification() throws Exception { + ResourceFunctionSpecificationCreate resourceFunctionSpecificationCreate = new ResourceFunctionSpecificationCreate(); + resourceFunctionSpecificationCreate.setName("Test Resource Function Specification"); + resourceFunctionSpecificationCreate.setType("ResourceFunctionSpecification"); + String createdSpecificationString = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(resourceFunctionSpecificationCreate))) + .andReturn().getResponse().getContentAsString(); + + ResourceSpecification createdSpecification = JsonUtils.toJsonObj(createdSpecificationString, ResourceFunctionSpecification.class); + String id = createdSpecification.getId(); + String fields = "name"; + mvc.perform(MockMvcRequestBuilders.get("/resourceCatalogManagement/v4/resourceSpecification/" + id) + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(null)) + .param("fields", fields)) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Resource Function Specification"))) + .andExpect(status().isOk()) + .andReturn().getResponse(); + } + + @Test + @WithMockUser(authorities = {"ROLE_ADMIN"}) + public void testListResourceSpecification() throws Exception { + String listResSpecsResponseString = mvc.perform(MockMvcRequestBuilders.get("/resourceCatalogManagement/v4/resourceSpecification") + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(null))) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + List listResSpecsResponse = JsonUtils.toListOfJsonObj(listResSpecsResponseString, LogicalResourceSpecification.class); + assertEquals(7, listResSpecsResponse.size()); + + mvc.perform(MockMvcRequestBuilders.get("/resourceCatalogManagement/v4/resourceSpecification") + .contentType(MediaType.APPLICATION_JSON) + .content(JsonUtils.toJson(null)) + .param("fields", "lastUpdate")) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + } + + @Test + void testGetObjectMapper() { + ObjectMapper objectMapper = new ObjectMapper(); + MockHttpServletRequest request = new MockHttpServletRequest(); + ResourceSpecificationApiController controller = new ResourceSpecificationApiController(objectMapper, request); + + Optional result = controller.getObjectMapper(); + assertTrue(result.isPresent()); + assertEquals(objectMapper, result.get()); + } + + @Test + void testGetRequest() { + ObjectMapper objectMapper = new ObjectMapper(); + MockHttpServletRequest request = new MockHttpServletRequest(); + ResourceSpecificationApiController controller = new ResourceSpecificationApiController(objectMapper, request); + + Optional result = controller.getRequest(); + assertTrue(result.isPresent()); + assertEquals(request, result.get()); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationCharacteristicTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationCharacteristicTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4e297af9d097645a507ed585b2b2d50cd1af0a68 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationCharacteristicTest.java @@ -0,0 +1,351 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.common.model.TimePeriod; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecCharRelationship; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristic; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristicValue; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.Set; + +import static org.junit.jupiter.api.Assertions.*; + +public class ResourceSpecificationCharacteristicTest { + @Test + void testResourceSpecificationCharacteristicConstructorAndAllProperties() { + // Create a new ResourceSpecificationCharacteristic object and set its properties + ResourceSpecificationCharacteristic characteristic1 = new ResourceSpecificationCharacteristic(); + characteristic1.setName("testName1"); + characteristic1.setDescription("testDescription1"); + characteristic1.setValueType("testValueType1"); + characteristic1.setConfigurable(true); + characteristic1.setValidFor(new TimePeriod()); + characteristic1.setSchemaLocation("testSchemaLocation1"); + characteristic1.setValueSchemaLocation("testValueSchemaLocation1"); + characteristic1.setMinCardinality(1); + characteristic1.setMaxCardinality(1); + characteristic1.setIsUnique(true); + characteristic1.setRegex("testRegex1"); + characteristic1.setExtensible(true); + characteristic1.setResourceSpecCharRelationship(new HashSet<>()); + characteristic1.setResourceSpecificationCharacteristicValue(new HashSet<>()); + + // Create another ResourceSpecificationCharacteristic object using the constructor that takes another ResourceSpecificationCharacteristic object as a parameter + ResourceSpecificationCharacteristic characteristic2 = new ResourceSpecificationCharacteristic(characteristic1); + characteristic2.setSchemaLocation("testSchemaLocation1"); + characteristic2.setValueSchemaLocation("testValueSchemaLocation1"); + + // Assert that the properties of the two objects are equal + assertEquals(characteristic1.getName(), characteristic2.getName()); + assertEquals(characteristic1.getDescription(), characteristic2.getDescription()); + assertEquals(characteristic1.getValueType(), characteristic2.getValueType()); + assertEquals(characteristic1.isConfigurable(), characteristic2.isConfigurable()); + assertEquals(characteristic1.getValidFor(), characteristic2.getValidFor()); + assertEquals(characteristic1.getSchemaLocation(), characteristic2.getSchemaLocation()); + assertEquals(characteristic1.getValueSchemaLocation(), characteristic2.getValueSchemaLocation()); + assertEquals(characteristic1.getMinCardinality(), characteristic2.getMinCardinality()); + assertEquals(characteristic1.getMaxCardinality(), characteristic2.getMaxCardinality()); + assertEquals(characteristic1.isIsUnique(), characteristic2.isIsUnique()); + assertEquals(characteristic1.getRegex(), characteristic2.getRegex()); + assertEquals(characteristic1.isExtensible(), characteristic2.isExtensible()); + assertEquals(characteristic1.getResourceSpecCharRelationship(), characteristic2.getResourceSpecCharRelationship()); + assertEquals(characteristic1.getResourceSpecCharacteristicValue(), characteristic2.getResourceSpecCharacteristicValue()); + } + + @Test + void testName() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + String name = "Test Name"; + characteristic.name(name); + assertEquals(name, characteristic.getName()); + } + + @Test + void testDescription() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + String description = "Test Description"; + characteristic.description(description); + assertEquals(description, characteristic.getDescription()); + } + + @Test + void testValueType() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + String valueType = "Test ValueType"; + characteristic.valueType(valueType); + assertEquals(valueType, characteristic.getValueType()); + } + + @Test + void testConfigurable() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + Boolean configurable = true; + characteristic.configurable(configurable); + assertEquals(configurable, characteristic.isConfigurable()); + } + + @Test + void testValidFor() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + TimePeriod validFor = new TimePeriod(); + characteristic.validFor(validFor); + assertEquals(validFor, characteristic.getValidFor()); + } + + @Test + void testType() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + String type = "Test Type"; + characteristic.type(type); + assertEquals(type, characteristic.getType()); + } + + @Test + void testSchemaLocation() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + String schemaLocation = "Test SchemaLocation"; + characteristic.schemaLocation(schemaLocation); + assertEquals(schemaLocation, characteristic.getSchemaLocation()); + } + + @Test + void testValueSchemaLocation() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + String valueSchemaLocation = "Test ValueSchemaLocation"; + characteristic.valueSchemaLocation(valueSchemaLocation); + assertEquals(valueSchemaLocation, characteristic.getValueSchemaLocation()); + } + + @Test + void testMinCardinality() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + Integer minCardinality = 1; + characteristic.minCardinality(minCardinality); + assertEquals(minCardinality, characteristic.getMinCardinality()); + } + + @Test + void testMaxCardinality() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + Integer maxCardinality = 10; + characteristic.maxCardinality(maxCardinality); + assertEquals(maxCardinality, characteristic.getMaxCardinality()); + } + + @Test + void testIsUnique() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + Boolean isUnique = true; + characteristic.isUnique(isUnique); + assertEquals(isUnique, characteristic.isIsUnique()); + } + + @Test + void testRegex() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + String regex = "Test Regex"; + characteristic.regex(regex); + assertEquals(regex, characteristic.getRegex()); + } + + @Test + void testExtensible() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + Boolean extensible = true; + characteristic.extensible(extensible); + assertEquals(extensible, characteristic.isExtensible()); + } + + @Test + void testResourceSpecCharRelationship() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + Set resourceSpecCharRelationship = new HashSet<>(); + resourceSpecCharRelationship.add(new ResourceSpecCharRelationship()); + characteristic.resourceSpecCharRelationship(resourceSpecCharRelationship); + assertEquals(resourceSpecCharRelationship, characteristic.getResourceSpecCharRelationship()); + } + + @Test + void testResourceSpecCharacteristicValue() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + Set resourceSpecCharacteristicValue = new HashSet<>(); + resourceSpecCharacteristicValue.add(new ResourceSpecificationCharacteristicValue()); + characteristic.ResourceSpecCharacteristicValue(resourceSpecCharacteristicValue); + assertEquals(resourceSpecCharacteristicValue, characteristic.getResourceSpecCharacteristicValue()); + } + + @Test + void testAddResourceSpecCharacteristicValueItem() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + ResourceSpecificationCharacteristicValue resourceSpecCharacteristicValueItem = new ResourceSpecificationCharacteristicValue(); + characteristic.addResourceSpecCharacteristicValueItem(resourceSpecCharacteristicValueItem); + assertTrue(characteristic.getResourceSpecCharacteristicValue().contains(resourceSpecCharacteristicValueItem)); + } + + @Test + void testEquals() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + characteristic.setName("Test Name"); + characteristic.setDescription("Test Description"); + characteristic.setValueType("Test ValueType"); + characteristic.setConfigurable(true); + characteristic.setType("Test Type"); + characteristic.setSchemaLocation("Test SchemaLocation"); + characteristic.setValueSchemaLocation("Test ValueSchemaLocation"); + characteristic.setMinCardinality(1); + characteristic.setMaxCardinality(10); + characteristic.setIsUnique(true); + characteristic.setRegex("Test Regex"); + characteristic.setExtensible(true); + + ResourceSpecificationCharacteristic characteristic2 = new ResourceSpecificationCharacteristic(); + characteristic2.setName("Test Name"); + characteristic2.setDescription("Test Description"); + characteristic2.setValueType("Test ValueType"); + characteristic2.setConfigurable(true); + characteristic2.setType("Test Type"); + characteristic2.setSchemaLocation("Test SchemaLocation"); + characteristic2.setValueSchemaLocation("Test ValueSchemaLocation"); + characteristic2.setMinCardinality(1); + characteristic2.setMaxCardinality(10); + characteristic2.setIsUnique(true); + characteristic2.setRegex("Test Regex"); + characteristic2.setExtensible(true); + + assertTrue(characteristic.equals(characteristic2)); + + characteristic2.name("Test Name 2"); + assertFalse(characteristic.equals(characteristic2)); + } + + @Test + void testToString() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + characteristic.setName("Test Name"); + characteristic.setDescription("Test Description"); + characteristic.setValueType("Test ValueType"); + characteristic.setConfigurable(true); + characteristic.setValidFor(new TimePeriod()); + characteristic.setType("Test Type"); + characteristic.setSchemaLocation("Test SchemaLocation"); + characteristic.setValueSchemaLocation("Test ValueSchemaLocation"); + characteristic.setMinCardinality(1); + characteristic.setMaxCardinality(10); + characteristic.setIsUnique(true); + characteristic.setRegex("Test Regex"); + characteristic.setExtensible(true); + characteristic.setResourceSpecCharRelationship(new HashSet<>()); + characteristic.setResourceSpecificationCharacteristicValue(new HashSet<>()); + + String expectedString = "class ResourceSpecificationCharacteristic {\n" + + " name: Test Name\n" + + " description: Test Description\n" + + " valueType: Test ValueType\n" + + " configurable: true\n" + + " validFor: " + characteristic.getValidFor().toString().replace("\n", "\n ") + "\n" + + " type: Test Type\n" + + " schemaLocation: Test SchemaLocation\n" + + " valueSchemaLocation: Test ValueSchemaLocation\n" + + " minCardinality: 1\n" + + " maxCardinality: 10\n" + + " isUnique: true\n" + + " regex: Test Regex\n" + + " extensible: true\n" + + " resourceSpecCharRelationship: []\n" + + " ResourceSpecificationCharacteristicValue: []\n" + + "}"; + + assertEquals(expectedString, characteristic.toString()); + } + + @Test + void testToIndentedString() throws Exception { + ResourceSpecificationCharacteristic resourceSpecificationCharacteristic = new ResourceSpecificationCharacteristic(); + + Method method = ResourceSpecificationCharacteristic.class.getDeclaredMethod("toIndentedString", Object.class); + method.setAccessible(true); + + String input = "Hello\nWorld"; + String expectedOutput = "Hello\n World"; + + String output = (String) method.invoke(resourceSpecificationCharacteristic, input); + + assertEquals(expectedOutput, output); + } + + @Test + void testUpdateWith() { + ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); + characteristic.setName("Test Name"); + characteristic.setDescription("Test Description"); + characteristic.setConfigurable(true); + characteristic.setType("org.etsi.osl.tmf.rcm634.model.ResourceSpecificationCharacteristic"); + characteristic.setMinCardinality(1); + characteristic.setMaxCardinality(10); + characteristic.setIsUnique(true); + characteristic.setRegex("Test Regex"); + characteristic.setExtensible(true); + + ResourceSpecificationCharacteristic characteristic2 = new ResourceSpecificationCharacteristic(); + characteristic2.updateWith(characteristic); + + assertEquals(characteristic, characteristic2); + } + +// @Test +// void testUpdateResourceSpecificationCharacteristicValues() throws NoSuchMethodException { +// // Create a ResourceSpecificationCharacteristic instance +// ResourceSpecificationCharacteristic characteristic = new ResourceSpecificationCharacteristic(); +// +// // Create a set of ResourceSpecificationCharacteristicValue instances +// Set values = new HashSet<>(); +// ResourceSpecificationCharacteristicValue value1 = new ResourceSpecificationCharacteristicValue(); +// value1.setValue(new Any("Test value 1")); +// +// ResourceSpecificationCharacteristicValue value2 = new ResourceSpecificationCharacteristicValue(); +// value2.setValue(new Any("Test value 2")); +// values.add(value2); +// +// Method method = ResourceSpecificationCharacteristic.class.getDeclaredMethod("updateResourceSpecificationCharacteristicValues", Object.class); +// method.setAccessible(true); +// characteristic.updateResourceSpecificationCharacteristicValues(values); +// +// // Assert that the resourceSpecCharacteristicValue set has been updated correctly +// Set updatedValues = characteristic.getResourceSpecCharacteristicValue(); +// assertEquals(2, updatedValues.size()); +// assertTrue(updatedValues.contains(value1)); +// assertTrue(updatedValues.contains(value2)); +// +// // Create a new set of ResourceSpecificationCharacteristicValue instances with one new value +// Set newValues = new HashSet<>(values); +// ResourceSpecificationCharacteristicValue value3 = new ResourceSpecificationCharacteristicValue(); +// value3.setValue(new Any("Test Value 3")); +// newValues.add(value3); +// +// // Call the updateResourceSpecificationCharacteristicValues method with the new set +// characteristic.updateResourceSpecificationCharacteristicValues(newValues); +// +// // Assert that the resourceSpecCharacteristicValue set has been updated correctly +// updatedValues = characteristic.getResourceSpecCharacteristicValue(); +// assertEquals(3, updatedValues.size()); +// assertTrue(updatedValues.contains(value1)); +// assertTrue(updatedValues.contains(value2)); +// assertTrue(updatedValues.contains(value3)); +// +// // Create a new set of ResourceSpecificationCharacteristicValue instances without the first value +// newValues = new HashSet<>(values); +// newValues.remove(value1); +// +// // Call the updateResourceSpecificationCharacteristicValues method with the new set +// characteristic.updateResourceSpecificationCharacteristicValues(newValues); +// +// // Assert that the resourceSpecCharacteristicValue set has been updated correctly +// updatedValues = characteristic.getResourceSpecCharacteristicValue(); +// assertEquals(2, updatedValues.size()); +// assertFalse(updatedValues.contains(value1)); +// assertTrue(updatedValues.contains(value2)); +// assertTrue(updatedValues.contains(value3)); +// } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationTest.java b/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a767b1178430a0c8cf1feced4fd0a99a38d01c8b --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/rcm634/ResourceSpecificationTest.java @@ -0,0 +1,422 @@ +package org.etsi.osl.services.api.rcm634; + +import org.etsi.osl.tmf.common.model.AttachmentRefOrValue; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.*; +import org.junit.jupiter.api.Test; + +import java.util.HashSet; +import java.util.Set; + +import static org.junit.jupiter.api.Assertions.*; + +public class ResourceSpecificationTest { + + static class TestResourceSpecification extends ResourceSpecification { + // You can add additional methods or override existing ones if needed + } + + @Test + void testResourceSpecification() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + + String id = "testId"; + Boolean isBundle = true; + String category = "testCategory"; + + resourceSpec.setUuid(id); + resourceSpec.setIsBundle(isBundle); + resourceSpec.setCategory(category); + + assertEquals(id, resourceSpec.getId()); + assertEquals(isBundle, resourceSpec.isIsBundle()); + assertEquals(category, resourceSpec.getCategory()); + } + + @Test + void testEquals() { + ResourceSpecification resourceSpec1 = new TestResourceSpecification(); + resourceSpec1.setUuid("testId"); + resourceSpec1.getId(); + resourceSpec1.setIsBundle(true); + resourceSpec1.setCategory("testCategory"); + + ResourceSpecification resourceSpec2 = new TestResourceSpecification(); + resourceSpec2.setUuid("testId"); + resourceSpec2.getId(); + resourceSpec2.setIsBundle(true); + resourceSpec2.setCategory("testCategory"); + + assertTrue(resourceSpec1.equals(resourceSpec2)); + + resourceSpec1.setUuid("differentId"); + resourceSpec1.getId(); + + assertFalse(resourceSpec1.equals(resourceSpec2)); + } + + @Test + void testHashCode() { + ResourceSpecification resourceSpec1 = new TestResourceSpecification(); + resourceSpec1.setUuid("testId"); + resourceSpec1.getId(); + resourceSpec1.setIsBundle(true); + resourceSpec1.setCategory("testCategory"); + + ResourceSpecification resourceSpec2 = new TestResourceSpecification(); + resourceSpec2.setUuid("testId"); + resourceSpec2.getId(); + resourceSpec2.setIsBundle(true); + resourceSpec2.setCategory("testCategory"); + + assertEquals(resourceSpec1.hashCode(), resourceSpec2.hashCode()); + + resourceSpec1.setUuid("differentId"); + resourceSpec1.getId(); + + assertNotEquals(resourceSpec1.hashCode(), resourceSpec2.hashCode()); + } + + @Test + void testHref() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String href = "testHref"; + resourceSpec.setHref(href); + assertEquals(href, resourceSpec.getHref()); + + ResourceSpecification newResourceSpec = resourceSpec.href("newTestHref"); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testCategory() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String category = "testCategory"; + resourceSpec.setCategory(category); + assertEquals(category, resourceSpec.getCategory()); + + ResourceSpecification newResourceSpec = resourceSpec.category("newTestCategory"); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testDescription() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String description = "testDescription"; + resourceSpec.setDescription(description); + assertEquals(description, resourceSpec.getDescription()); + + ResourceSpecification newResourceSpec = resourceSpec.description("newTestDescription"); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testIsBundle() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + Boolean isBundle = true; + resourceSpec.setIsBundle(isBundle); + assertEquals(isBundle, resourceSpec.isIsBundle()); + + ResourceSpecification newResourceSpec = resourceSpec.isBundle(false); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testLifecycleStatus() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String lifecycleStatus = "In study"; + resourceSpec.setLifecycleStatus(lifecycleStatus); + assertEquals(lifecycleStatus, resourceSpec.getLifecycleStatus()); + + ResourceSpecification newResourceSpec = resourceSpec.lifecycleStatus("In use"); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testName() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String name = "testName"; + resourceSpec.setName(name); + assertEquals(name, resourceSpec.getName()); + + ResourceSpecification newResourceSpec = resourceSpec.name("newTestName"); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testSettersAndGetters() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + + // Test id + String id = "testId"; + resourceSpec.setUuid(id); + resourceSpec.getId(); + assertEquals(id, resourceSpec.getId()); + + // Test href + String href = "testHref"; + resourceSpec.setHref(href); + assertEquals(href, resourceSpec.getHref()); + + // Test category + String category = "testCategory"; + resourceSpec.setCategory(category); + assertEquals(category, resourceSpec.getCategory()); + + // Test description + String description = "testDescription"; + resourceSpec.setDescription(description); + assertEquals(description, resourceSpec.getDescription()); + + // Test isBundle + Boolean isBundle = true; + resourceSpec.setIsBundle(isBundle); + assertEquals(isBundle, resourceSpec.isIsBundle()); + + // Test lifecycleStatus + String lifecycleStatus = "In study"; + resourceSpec.setLifecycleStatus(lifecycleStatus); + assertEquals(lifecycleStatus, resourceSpec.getLifecycleStatus()); + + // Test name + String name = "testName"; + resourceSpec.setName(name); + assertEquals(name, resourceSpec.getName()); + + // Test version + String version = "testVersion"; + resourceSpec.setVersion(version); + assertEquals(version, resourceSpec.getVersion()); + + // Test baseType + String baseType = "BaseRootEntity"; + resourceSpec.setBaseType(baseType); + assertEquals(baseType, resourceSpec.getBaseType()); + + // Test schemaLocation + String schemaLocation = "testSchemaLocation"; + resourceSpec.setAtSchemaLocation(schemaLocation); + assertEquals(schemaLocation, resourceSpec.getAtSchemaLocation()); + + // Test type + String type = "BaseEntity"; + resourceSpec.setType(type); + assertEquals(type, resourceSpec.getType()); + } + @Test + void testToString() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + resourceSpec.setUuid("testId"); + resourceSpec.getId(); + resourceSpec.setIsBundle(true); + resourceSpec.setCategory("testCategory"); + resourceSpec.setHref("testHref"); + resourceSpec.setLifecycleStatus("In study"); + resourceSpec.setName("testName"); + resourceSpec.setVersion("testVersion"); + resourceSpec.setBaseType("BaseRootEntity"); + resourceSpec.setAtSchemaLocation("testSchemaLocation"); + resourceSpec.setType("BaseEntity"); + + String expectedString = "class ResourceSpecification {\n" + + " id: testId\n" + + " href: testHref\n" + + " category: testCategory\n" + + " description: null\n" + + " isBundle: true\n" + + " lastUpdate: null\n" + + " lifecycleStatus: In study\n" + + " name: testName\n" + + " version: testVersion\n" + + " attachment: []\n" + + " featureSpecification: []\n" + + " relatedParty: []\n" + + " resourceSpecCharacteristic: []\n" + + " resourceSpecRelationship: []\n" + + " targetResourceSchema: null\n" + + " validFor: null\n" + + " baseType: BaseRootEntity\n" + + " schemaLocation: testSchemaLocation\n" + + " type: BaseEntity\n" + + "}"; + + assertEquals(expectedString, resourceSpec.toString()); + } + + @Test + void testFixResourceCharRelationhsipIDs() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + resourceSpec.setName("testResourceSpec"); + + ResourceSpecificationCharacteristic schar1 = new ResourceSpecificationCharacteristic(); + schar1.setName("schar1"); + schar1.setUuid("uuid1"); + + ResourceSpecificationCharacteristic schar2 = new ResourceSpecificationCharacteristic(); + schar2.setName("schar2"); + + ResourceSpecCharRelationship charRel1 = new ResourceSpecCharRelationship(); + charRel1.setName("schar1"); // same name as schar1 + + ResourceSpecCharRelationship charRel2 = new ResourceSpecCharRelationship(); + charRel2.setName("schar2"); // same name as schar2 + + schar1.addResourceSpecCharRelationshipItem(charRel1); + schar2.addResourceSpecCharRelationshipItem(charRel2); + + resourceSpec.addResourceSpecCharacteristicItem(schar1); + resourceSpec.addResourceSpecCharacteristicItem(schar2); + + resourceSpec.fixResourceCharRelationhsipIDs(); + + assertEquals("uuid1", charRel1.getId()); // id should be set to the uuid of schar1 + assertEquals("testResourceSpec-schar2", charRel2.getId()); // id should be set to "resourceSpecName-scharName" + } + + @Test + void testRelatedParty() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + Set relatedPartySet = new HashSet<>(); + relatedPartySet.add(new RelatedParty()); + resourceSpec.setRelatedParty(relatedPartySet); + assertEquals(relatedPartySet, resourceSpec.getRelatedParty()); + + relatedPartySet.add(new RelatedParty()); + resourceSpec.setRelatedParty(relatedPartySet); + assertEquals(relatedPartySet, resourceSpec.getRelatedParty()); + } + + @Test + void testFindSpecCharacteristicByName() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + ResourceSpecificationCharacteristic characteristic1 = new ResourceSpecificationCharacteristic(); + characteristic1.setName("testName1"); + resourceSpec.getResourceSpecCharacteristic().add(characteristic1); + + ResourceSpecificationCharacteristic characteristic2 = new ResourceSpecificationCharacteristic(); + characteristic2.setName("testName2"); + resourceSpec.getResourceSpecCharacteristic().add(characteristic2); + + assertEquals(characteristic1, resourceSpec.findSpecCharacteristicByName("testName1")); + assertEquals(characteristic2, resourceSpec.findSpecCharacteristicByName("testName2")); + assertNull(resourceSpec.findSpecCharacteristicByName("nonexistentName")); + } + + + + @Test + void testResourceSpecRelationship() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + Set relationships = new HashSet<>(); + relationships.add(new ResourceSpecificationRelationship()); + resourceSpec.setResourceSpecRelationship(relationships); + assertEquals(relationships, resourceSpec.getResourceSpecRelationship()); + + ResourceSpecificationRelationship newRelationship = new ResourceSpecificationRelationship(); + resourceSpec.addResourceSpecRelationshipItem(newRelationship); + assertTrue(resourceSpec.getResourceSpecRelationship().contains(newRelationship)); + } + + @Test + void testResourceCandidateObjId() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String resourceCandidateObjId = "testResourceCandidateObjId"; + resourceSpec.setResourceCandidateObjId(resourceCandidateObjId); + assertEquals(resourceCandidateObjId, resourceSpec.getResourceCandidateObjId()); + } + + + @Test + void testBaseType() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String baseType = "testBaseType"; + resourceSpec.setBaseType(baseType); + assertEquals(baseType, resourceSpec.getBaseType()); + + ResourceSpecification newResourceSpec = resourceSpec.baseType("newTestBaseType"); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testSchemaLocation() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String schemaLocation = "testSchemaLocation"; + resourceSpec.setAtSchemaLocation(schemaLocation); + assertEquals(schemaLocation, resourceSpec.getAtSchemaLocation()); + + ResourceSpecification newResourceSpec = resourceSpec.schemaLocation("newTestSchemaLocation"); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testVersion() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String version = "testVersion"; + resourceSpec.setVersion(version); + assertEquals(version, resourceSpec.getVersion()); + + ResourceSpecification newResourceSpec = resourceSpec.version("newTestVersion"); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testAttachment() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + Set attachments = new HashSet<>(); + attachments.add(new AttachmentRefOrValue()); + resourceSpec.setAttachment(attachments); + assertEquals(attachments, resourceSpec.getAttachment()); + + AttachmentRefOrValue newAttachment = new AttachmentRefOrValue(); + resourceSpec.addAttachmentItem(newAttachment); + assertTrue(resourceSpec.getAttachment().contains(newAttachment)); + } + + @Test + void testFeatureSpecification() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + Set featureSpecifications = new HashSet<>(); + featureSpecifications.add(new FeatureSpecification()); + resourceSpec.setFeatureSpecification(featureSpecifications); + assertEquals(featureSpecifications, resourceSpec.getFeatureSpecification()); + + FeatureSpecification newFeatureSpecification = new FeatureSpecification(); + resourceSpec.addFeatureSpecificationItem(newFeatureSpecification); + assertTrue(resourceSpec.getFeatureSpecification().contains(newFeatureSpecification)); + } + + @Test + void testResourceSpecCharacteristic() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + Set characteristics = new HashSet<>(); + characteristics.add(new ResourceSpecificationCharacteristic()); + resourceSpec.setResourceSpecCharacteristic(characteristics); + assertEquals(characteristics, resourceSpec.getResourceSpecCharacteristic()); + + ResourceSpecification newResourceSpec = resourceSpec.resourceSpecCharacteristic(characteristics); + assertEquals(resourceSpec, newResourceSpec); + } + + + @Test + void testTargetResourceSchema() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + TargetResourceSchema targetResourceSchema = new TargetResourceSchema(); + resourceSpec.setTargetResourceSchema(targetResourceSchema); + assertEquals(targetResourceSchema, resourceSpec.getTargetResourceSchema()); + + ResourceSpecification newResourceSpec = resourceSpec.targetResourceSchema(targetResourceSchema); + assertEquals(resourceSpec, newResourceSpec); + } + + @Test + void testType() { + ResourceSpecification resourceSpec = new TestResourceSpecification(); + String type = "testType"; + resourceSpec.setType(type); + assertEquals(type, resourceSpec.getType()); + + ResourceSpecification newResourceSpec = resourceSpec.type("newTestType"); + assertEquals(resourceSpec, newResourceSpec); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/ri639/CommonTests.java b/src/test/java/org/etsi/osl/services/api/ri639/CommonTests.java new file mode 100644 index 0000000000000000000000000000000000000000..a78c4eb5d2956aaa5935289dbe8fed5bdd8dfd0e --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ri639/CommonTests.java @@ -0,0 +1,142 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 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.services.api.ri639; + +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.etsi.osl.tmf.ri639.api.*; +import org.junit.jupiter.api.Test; +import org.springframework.mock.web.MockHttpServletRequest; + +import java.io.IOException; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +public class CommonTests { + + @Test + public void testApiException() { + int errorCode = 404; + String errorMessage = "Not Found"; + + ApiException exception = new ApiException(errorCode, errorMessage); + + assertEquals(errorMessage, exception.getMessage()); + } + + @Test + public void testApiOriginFilter() throws IOException, ServletException { + HttpServletRequest request = mock(HttpServletRequest.class); + HttpServletResponse response = mock(HttpServletResponse.class); + FilterChain chain = mock(FilterChain.class); + + ApiOriginFilter filter = new ApiOriginFilter(); + filter.doFilter(request, response, chain); + + verify(response).addHeader("Access-Control-Allow-Origin", "*"); + verify(response).addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + verify(response).addHeader("Access-Control-Allow-Headers", "Content-Type"); + verify(chain).doFilter(request, response); + } + + @Test + public void testApiResponseMessage() { + int[] codes = {ApiResponseMessage.ERROR, ApiResponseMessage.WARNING, ApiResponseMessage.INFO, ApiResponseMessage.OK, ApiResponseMessage.TOO_BUSY, 6}; + + String[] types = {"error", "warning", "info", "ok", "too busy", "unknown"}; + + String[] messages = {"An error occured", "This is a warning", "Given info", "ok", "System is too busy", "unknown code"}; + + for (int i = 0; i < codes.length; i++) { + int code = codes[i]; + String type = types[i]; + String message = messages[i]; + + ApiResponseMessage responseMessage = new ApiResponseMessage(code, message); + + assertEquals(message, responseMessage.getMessage()); + assertEquals(code, responseMessage.getCode()); + assertEquals(type, responseMessage.getType()); + + } + + ApiResponseMessage responseMessage = new ApiResponseMessage(); + responseMessage.setMessage("Error"); + assertEquals("Error", responseMessage.getMessage()); + responseMessage.setType("ok"); + assertEquals("ok", responseMessage.getType()); + responseMessage.setCode(ApiResponseMessage.OK); + assertEquals(ApiResponseMessage.OK, responseMessage.getCode()); + } + + @Test + public void testHubApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + HubApiController controller = new HubApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testListenerApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + ListenerApiController controller = new ListenerApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testNotFoundException() { + int errorCode = 404; + String errorMessage = "Not Found"; + + NotFoundException exception = new NotFoundException(errorCode, errorMessage); + + assertEquals(errorMessage, exception.getMessage()); + } + +} + 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 new file mode 100644 index 0000000000000000000000000000000000000000..9e2f8df94245b1dd78af3745ecdfbd2efeb737e5 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ri639/ResourceApiControllerTest.java @@ -0,0 +1,213 @@ +package org.etsi.osl.services.api.ri639; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; + +import java.security.Principal; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.JsonUtils; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.ri639.api.ResourceApiController; +import org.etsi.osl.tmf.ri639.model.LogicalResource; +import org.etsi.osl.tmf.ri639.model.Resource; + +import org.etsi.osl.tmf.ri639.model.ResourceCreate; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +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.HttpStatus; +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 org.springframework.http.ResponseEntity; + + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") + +public class ResourceApiControllerTest { + + private static final int FIXED_BOOTSTRAPS_RESOURCES = 0; + + @Autowired + private MockMvc mvc; + + @Autowired + ResourceRepoService resourceRepoService; + + @Autowired + private WebApplicationContext context; + + @Autowired + private ObjectMapper objectMapper; + + private ResourceApiController mockResourceApiController; + + private ResourceRepoService mockResourceRepoService; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + + // Mocks + mockResourceRepoService = mock(ResourceRepoService.class); + ObjectMapper mockObjectMapper = mock(ObjectMapper.class); + mockResourceApiController = new ResourceApiController(mockObjectMapper, null); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListResource() throws Exception { + + String response = mvc.perform(MockMvcRequestBuilders.get("/resourceInventoryManagement/v4/resource") + + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + List resourceList = objectMapper.readValue(response, new TypeReference>() {}); + + assertThat(resourceList.size()).isEqualTo(resourceRepoService.findAll().size()); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteResource() throws Exception { + + String response = createResource(); + + Resource responsesResource = JsonUtils.toJsonObj(response, LogicalResource.class); + String id = responsesResource.getId(); + + mvc.perform(MockMvcRequestBuilders.delete("/resourceInventoryManagement/v4/resource/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( resourceRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_RESOURCES ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testCreateResourceHandleException(){ + + ResourceCreate resourceCreate = createResourceObject(); + + when(mockResourceRepoService.addResource(any())) + .thenThrow(new RuntimeException("Test exception")); + + ResponseEntity response = mockResourceApiController.createResource(mock(Principal.class), resourceCreate); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteResourceHandleException() throws Exception{ + + String response = createResource(); + + Resource responsesResource = JsonUtils.toJsonObj(response, LogicalResource.class); + String id = responsesResource.getId(); + + when(mockResourceRepoService.deleteByUuid(any())) + .thenThrow(new RuntimeException("Test exception")); + + ResponseEntity responseDelete = mockResourceApiController.deleteResource(id); + + assertThat(responseDelete.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListResourceHandleException(){ + + when(mockResourceRepoService.findAll()) + .thenThrow(new RuntimeException("Test exception")); + + ResponseEntity> response = mockResourceApiController.listResource(mock(Principal.class), null, null, null, null); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveResourceHandleException(){ + + when(mockResourceRepoService.findByUuid(any())) + .thenThrow(new RuntimeException("Test exception")); + + ResponseEntity response = mockResourceApiController.retrieveResource(mock(Principal.class), "test id", ""); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + } + + + private String createResource() throws Exception{ + + ResourceCreate resourceCreate = createResourceObject(); + + String response = mvc.perform(MockMvcRequestBuilders.post("/resourceInventoryManagement/v4/resource") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( resourceCreate ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( resourceRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_RESOURCES + 1 ); + return response; + } + + + private ResourceCreate createResourceObject() { + ResourceCreate resourceCreate = new ResourceCreate(); + resourceCreate.setName("Test Resource"); + resourceCreate.setCategory("Experimentation"); + resourceCreate.setDescription("A Test Resource"); + resourceCreate.setStartOperatingDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + resourceCreate.setEndOperatingDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + + ResourceSpecificationRef aServiceSpecificationRef = new ResourceSpecificationRef(); + + resourceCreate.setResourceSpecification( aServiceSpecificationRef ); + + return resourceCreate; + } +} diff --git a/src/test/java/org/etsi/osl/services/api/ri639/ResourceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/api/ri639/ResourceRepoServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..632ab428567593708e5cdf346ac21caf4d3fcb78 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/ri639/ResourceRepoServiceTest.java @@ -0,0 +1,342 @@ +package org.etsi.osl.services.api.ri639; + + +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.etsi.osl.services.api.ResourceInventoryIntegrationTest; +import org.etsi.osl.tmf.JsonUtils; +import org.etsi.osl.tmf.OpenAPISpringBoot; +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.common.model.service.ResourceRef; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.*; +import org.etsi.osl.tmf.ri639.model.*; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +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 java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URI; +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 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.*; + + +@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 ResourceRepoServiceTest { + + private static final transient Log logger = LogFactory.getLog( ResourceInventoryIntegrationTest.class.getName()); + + @Autowired + private MockMvc mvc; + + @Autowired + ResourceRepoService resourceRepoService; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testFindAll() throws Exception { + + // Test with not null fields and params + String fields = "resourceVersion, usageState"; + Map params = new HashMap<>(); + params.put("category", "Non existing category"); + + List resourceList = resourceRepoService.findAll(fields, params); + assertThat(resourceList.size()).isEqualTo(resourceRepoService.findAll().size()); + + } + + +// // 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 testUpdateResource() throws Exception { + + // Test with non-existing resource +// String nonExistingResourceId = "nonExistingId"; +// ResourceUpdate ru = new ResourceUpdate(); +// +// Resource nullResource = resourceRepoService.updateResource(nonExistingResourceId, ru, false); +// assertThat(nullResource).isEqualTo(null); + + // Test with existing resource +// String response = createResource(); +// +// Resource responsesResource = JsonUtils.toJsonObj(response, LogicalResource.class); +// String id = responsesResource.getId(); +// +// ResourceUpdate resourceUpdate = new ResourceUpdate(); +// resourceUpdate.setAtType("New atType"); +// resourceUpdate.setName("New name"); +// resourceUpdate.setCategory("New category"); +// resourceUpdate.setDescription("New description"); +// resourceUpdate.setStartOperatingDate(OffsetDateTime.now(ZoneOffset.UTC ).toString()); +// resourceUpdate.setUsageState(responsesResource.getUsageState()); +// resourceUpdate.setResourceStatus(ResourceStatusType.ALARM); +// resourceUpdate.setResourceVersion("New version"); +// resourceUpdate.setAdministrativeState(responsesResource.getAdministrativeState()); +// resourceUpdate.setResourceSpecification(responsesResource.getResourceSpecification()); +// resourceUpdate.setPlace(new RelatedPlaceRefOrValue()); +// +// RelatedParty relatedParty = new RelatedParty(); +// relatedParty.setName("Related Party"); +// List relatedPartyList = new ArrayList<>(); +// relatedPartyList.add(relatedParty); +// +// resourceUpdate.setRelatedParty(relatedPartyList); +// +// Resource updatedResource = resourceRepoService.updateResource(id, resourceUpdate, false); +// +// assertThat(updatedResource.getName()).isEqualTo("New name"); +// assertThat(updatedResource.getCategory()).isEqualTo("New category"); +// assertThat(updatedResource.getDescription()).isEqualTo("New description"); +// assertThat(updatedResource.getResourceVersion()).isEqualTo("New version"); +// assertThat(updatedResource.getResourceStatus()).isEqualTo(ResourceStatusType.ALARM); +// } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testFindAllActiveResourcesToTerminate() throws Exception { + + String response = createResource(); + + Resource responsesResource = JsonUtils.toJsonObj(response, LogicalResource.class); + String id = responsesResource.getId(); + + List resourcesList = resourceRepoService.findAllActiveResourcesToTerminate(); + assertThat(resourcesList).contains(id); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testFindAllActiveAndReservedResourcesOfPartners() throws Exception { + + String response = createResource(); + + Resource responsesResource = JsonUtils.toJsonObj(response, LogicalResource.class); + String id = responsesResource.getId(); + + List resourcesList = resourceRepoService.findAllActiveAndReservedResourcesOfPartners(); + assertThat(resourcesList).contains(id); + } + +// // 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 testAddOrUpdateResourceByNameCategoryVersion() throws Exception { +// +// String response = createResource(); +// +// Resource responsesResource = JsonUtils.toJsonObj(response, LogicalResource.class); +// String name = responsesResource.getName(); +// String category = responsesResource.getCategory(); +// String version = responsesResource.getResourceVersion(); +// +// ResourceCreate aResource = new ResourceCreate(); +// aResource.setName("A new name"); +// aResource.setCategory("A new category"); +// +// Resource response2 = resourceRepoService.addOrUpdateResourceByNameCategoryVersion(name, category, version, aResource); +// assertThat(response2.getName()).isEqualTo("A new name"); +// assertThat(response2.getCategory()).isEqualTo("A new category"); +// } + + + private String createResource() throws 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() ); + aResource.setResourceStatus(ResourceStatusType.AVAILABLE); + + + + Note noteItem = new Note(); + noteItem.text("test note"); + aResource.addNoteItem(noteItem); + + Characteristic resCharacteristicItem = new Characteristic(); + + resCharacteristicItem.setName( "externalPartnerServiceId" ); + 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( "externalPartnerServiceId" ) ).isNotNull(); + assertThat( responseRsc.getResourceCharacteristicByName( "externalPartnerServiceId" ).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 ); + + return responseResource; + } + + + private ResourceSpecification createResourceSpec(ResourceSpecificationUpdate sspeccr1) throws Exception{ + + URI url = new URI("/resourceCatalogManagement/v4/resourceSpecification"); + if (sspeccr1 instanceof PhysicalResourceSpecificationUpdate ) { + url = new URI("/resourceCatalogManagement/v4/resourceSpecification"); + } + String responseSpec = mvc.perform(MockMvcRequestBuilders.post( url ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ResourceSpecification responsesSpec1; + if (sspeccr1 instanceof PhysicalResourceSpecificationUpdate ) { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, PhysicalResourceSpecification.class); + }else { + responsesSpec1 = JsonUtils.toJsonObj(responseSpec, LogicalResourceSpecification.class); + } + + return responsesSpec1; + } +} diff --git a/src/test/java/org/etsi/osl/services/api/scm633/ExportJobApiController633Test.java b/src/test/java/org/etsi/osl/services/api/scm633/ExportJobApiController633Test.java new file mode 100644 index 0000000000000000000000000000000000000000..14a8a40ff6d3965ec67e6c2221fdd5fac3c114a5 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/scm633/ExportJobApiController633Test.java @@ -0,0 +1,130 @@ +package org.etsi.osl.services.api.scm633; + +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.scm633.model.*; +import org.etsi.osl.tmf.JsonUtils; + +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; + + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ExportJobApiController633Test { + + @Autowired + private MockMvc mvc; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testCreateExportJob() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testExportJob.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String exportJobString = IOUtils.toString(in, "UTF-8"); + ExportJobCreate exportJobCreate = JsonUtils.toJsonObj(exportJobString, ExportJobCreate.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/exportJob") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( exportJobCreate ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/exportJob") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( exportJobCreate ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteExportJob() throws Exception { + + mvc.perform(MockMvcRequestBuilders.delete("/serviceCatalogManagement/v4/exportJob/testId") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListExportJob() throws Exception { + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/exportJob") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/exportJob") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveExportJob() throws Exception { + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/exportJob?testId") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/exportJob/testId") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..048ad19c20ee3c49ee427bf373885f4daa118d15 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/scm633/HubApiControllerTest.java @@ -0,0 +1,92 @@ +package org.etsi.osl.services.api.scm633; + +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.scm633.model.*; +import org.etsi.osl.tmf.JsonUtils; + +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; + + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class HubApiControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRegisterListener() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testEventSubscriptionInput.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String eventSubscriptionInputString = IOUtils.toString(in, "UTF-8"); + EventSubscriptionInput eventSubscriptionInput = JsonUtils.toJsonObj(eventSubscriptionInputString, EventSubscriptionInput.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/hub") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( eventSubscriptionInput ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/hub") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( eventSubscriptionInput ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testUnregisterListener() throws Exception { + + mvc.perform(MockMvcRequestBuilders.delete("/serviceCatalogManagement/v4/hub/testId") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/scm633/ImportJobApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/scm633/ImportJobApiControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0d3769881e3381b6d08eeb069f1e9935aa1d23c8 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/scm633/ImportJobApiControllerTest.java @@ -0,0 +1,130 @@ +package org.etsi.osl.services.api.scm633; + +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.scm633.model.*; +import org.etsi.osl.tmf.JsonUtils; + +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; + + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ImportJobApiControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testCreateImportJob() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testExportJob.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String exportJobString = IOUtils.toString(in, "UTF-8"); + ExportJobCreate exportJobCreate = JsonUtils.toJsonObj(exportJobString, ExportJobCreate.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/importJob") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( exportJobCreate ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/importJob") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( exportJobCreate ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteImportJob() throws Exception { + + mvc.perform(MockMvcRequestBuilders.delete("/serviceCatalogManagement/v4/importJob/testId") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListImportJob() throws Exception { + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/importJob") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/importJob") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveImportJob() throws Exception { + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/importJob?testId") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/importJob/testId") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501)); + } +} \ No newline at end of file diff --git a/src/test/java/org/etsi/osl/services/api/scm633/ListenerApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/scm633/ListenerApiControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9ed631a15bb0999c56f5dd8bbf9f03d524a2abad --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/scm633/ListenerApiControllerTest.java @@ -0,0 +1,392 @@ +package org.etsi.osl.services.api.scm633; + +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.scm633.model.*; +import org.etsi.osl.tmf.JsonUtils; + +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; + + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ListenerApiControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCandidateChangeNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String changeNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCandidateChangeNotification serviceCandidateChangeNotification = JsonUtils.toJsonObj(changeNotificationString, ServiceCandidateChangeNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCandidateChangeNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCandidateChangeNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCandidateChangeNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCandidateChangeNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCandidateCreateNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String createNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCandidateCreateNotification serviceCandidateCreateNotification = JsonUtils.toJsonObj(createNotificationString, ServiceCandidateCreateNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCandidateCreateNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCandidateCreateNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCandidateCreateNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCandidateCreateNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCandidateDeleteNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String deleteNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCandidateDeleteNotification serviceCandidateDeleteNotification = JsonUtils.toJsonObj(deleteNotificationString, ServiceCandidateDeleteNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCandidateDeleteNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCandidateDeleteNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCandidateDeleteNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCandidateDeleteNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCatalogBatchNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String batchNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCatalogBatchNotification serviceCatalogBatchNotification = JsonUtils.toJsonObj(batchNotificationString, ServiceCatalogBatchNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCatalogBatchNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCatalogBatchNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCatalogBatchNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCatalogBatchNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCatalogChangeNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String changeNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCatalogChangeNotification serviceCatalogChangeNotification = JsonUtils.toJsonObj(changeNotificationString, ServiceCatalogChangeNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCatalogChangeNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCatalogChangeNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCatalogChangeNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCatalogChangeNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCatalogCreateNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String createNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCatalogCreateNotification serviceCatalogCreateNotification = JsonUtils.toJsonObj(createNotificationString, ServiceCatalogCreateNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCatalogCreateNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCatalogCreateNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCatalogCreateNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCatalogCreateNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCatalogDeleteNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String deleteNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCatalogDeleteNotification serviceCatalogDeleteNotification = JsonUtils.toJsonObj(deleteNotificationString, ServiceCatalogDeleteNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCatalogDeleteNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCatalogDeleteNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCatalogDeleteNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCatalogDeleteNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCategoryChangeNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String changeNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCategoryChangeNotification serviceCategoryChangeNotification = JsonUtils.toJsonObj(changeNotificationString, ServiceCategoryChangeNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCategoryChangeNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCategoryChangeNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCategoryChangeNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCategoryChangeNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCategoryCreateNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String createNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCategoryCreateNotification serviceCategoryCreateNotification = JsonUtils.toJsonObj(createNotificationString, ServiceCategoryCreateNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCategoryCreateNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCategoryCreateNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCategoryCreateNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCategoryCreateNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceCategoryDeleteNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String deleteNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceCategoryDeleteNotification serviceCategoryDeleteNotification = JsonUtils.toJsonObj(deleteNotificationString, ServiceCategoryDeleteNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCategoryDeleteNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCategoryDeleteNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceCategoryDeleteNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCategoryDeleteNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceSpecificationChangeNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String changeNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceSpecificationChangeNotification serviceSpecificationChangeNotification = JsonUtils.toJsonObj(changeNotificationString, ServiceSpecificationChangeNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceSpecificationChangeNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceSpecificationChangeNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceSpecificationChangeNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceSpecificationChangeNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceSpecificationCreateNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String createNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceSpecificationCreateNotification serviceSpecificationCreateNotification = JsonUtils.toJsonObj(createNotificationString, ServiceSpecificationCreateNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceSpecificationCreateNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceSpecificationCreateNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceSpecificationCreateNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceSpecificationCreateNotification ) )) + .andExpect(status().is(501)); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListenToServiceSpecificationDeleteNotification() throws Exception { + + File resourceSpecFile = new File("src/test/resources/testServiceCandidateChangeNotification.json"); + InputStream in = new FileInputStream(resourceSpecFile); + String deleteNotificationString = IOUtils.toString(in, "UTF-8"); + ServiceSpecificationDeleteNotification serviceSpecificationDeleteNotification = JsonUtils.toJsonObj(deleteNotificationString, ServiceSpecificationDeleteNotification.class); + + // Test when providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceSpecificationDeleteNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceSpecificationDeleteNotification ) )) + .andExpect(status().is(501)); + + // Test when not providing an "Accept" request header + mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/listener/serviceSpecificationDeleteNotification") + .with(SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceSpecificationDeleteNotification ) )) + .andExpect(status().is(501)); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..c8ed3f474d664be8bc421378cd331111f479c8b2 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/scm633/ServiceCandidateApiControllerTest.java @@ -0,0 +1,201 @@ +package org.etsi.osl.services.api.scm633; + +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.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.List; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import net.minidev.json.JSONObject; +import org.apache.commons.io.IOUtils; + + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.scm633.model.*; +import org.etsi.osl.tmf.JsonUtils; + +import org.etsi.osl.tmf.scm633.reposervices.CandidateRepoService; +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; + + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ServiceCandidateApiControllerTest { + + private static final int FIXED_BOOTSTRAPS_SPECS = 1; + + @Autowired + private MockMvc mvc; + + @Autowired + private WebApplicationContext context; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + CandidateRepoService candidateRepoService; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testCreateServiceCandidate() throws Exception { + + String response = createServiceCandidate(); + + ServiceCandidate responsesServiceCandidate = JsonUtils.toJsonObj(response, ServiceCandidate.class); + assertThat( responsesServiceCandidate.getDescription() ).isEqualTo( "A Test Service Candidate" ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteServiceCandidate() throws Exception { + + String response = createServiceCandidate(); + + ServiceCandidate responsesServiceCandidate = JsonUtils.toJsonObj(response, ServiceCandidate.class); + String id = responsesServiceCandidate.getId(); + + mvc.perform(MockMvcRequestBuilders.delete("/serviceCatalogManagement/v4/serviceCandidate/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( candidateRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListServiceCandidate() throws Exception { + + String response = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceCandidate") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + List serviceCandidateList= objectMapper.readValue(response, new TypeReference>() {}); + + assertThat(serviceCandidateList.size()).isEqualTo(candidateRepoService.findAll().size()); + + String id = candidateRepoService.findAll().get(0).getId(); + + boolean idExists = false; + for (ServiceCandidate sc : serviceCandidateList) { + if ( sc.getId().equals( id ) ) { + idExists= true; + } + } + assertThat( idExists ).isTrue(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testPatchServiceCandidate() throws Exception { + + String response = createServiceCandidate(); + + ServiceCandidate responsesServiceCandidate = JsonUtils.toJsonObj(response, ServiceCandidate.class); + String id = responsesServiceCandidate.getId(); + + JSONObject obj = JsonUtils.toJsonObj(response, JSONObject.class); + obj.remove("uuid"); + obj.remove("id"); + obj.remove("lastUpdate"); + response = JsonUtils.toJsonString(obj); + + ServiceCandidateUpdate serviceCandidateUpdate = JsonUtils.toJsonObj(response, ServiceCandidateUpdate.class); + serviceCandidateUpdate.setDescription("Test Service Candidate new description"); + + String response2 = mvc.perform(MockMvcRequestBuilders.patch("/serviceCatalogManagement/v4/serviceCandidate/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCandidateUpdate ) )) + .andExpect(status().isOk() ) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("description", is("Test Service Candidate new description"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ServiceCandidate responsesServiceCandidate2 = JsonUtils.toJsonObj(response2, ServiceCandidate.class); + assertThat( responsesServiceCandidate2.getDescription() ).isEqualTo( "Test Service Candidate new description" ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveServiceCandidate() throws Exception { + + String response = createServiceCandidate(); + + ServiceCandidate responsesServiceCandidate = JsonUtils.toJsonObj(response, ServiceCandidate.class); + String id = responsesServiceCandidate.getId(); + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceCandidate/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + ServiceCandidate responsesServiceCandidate2 = JsonUtils.toJsonObj(response2, ServiceCandidate.class); + assertThat( responsesServiceCandidate2.getDescription() ).isEqualTo( "A Test Service Candidate" ); + } + + private String createServiceCandidate() throws Exception{ + File resourceSpecFile = new File("src/test/resources/testServiceCandidate.txt"); + InputStream in = new FileInputStream(resourceSpecFile); + String serviceCandidateString = IOUtils.toString(in, "UTF-8"); + ServiceCandidateCreate serviceCandidate = JsonUtils.toJsonObj(serviceCandidateString, ServiceCandidateCreate.class); + + assertThat( candidateRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS); + + String response = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceCandidate") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( serviceCandidate ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("description", is("A Test Service Candidate"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( candidateRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1 ); + return response; + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..92b48d54028defe00acaa5f26c1f1f55f3f38219 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/scm633/ServiceCatalogApiControllerTest.java @@ -0,0 +1,186 @@ +package org.etsi.osl.services.api.scm633; + +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.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import net.minidev.json.JSONObject; +import org.apache.commons.io.IOUtils; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.rcm634.model.ResourceCatalog; +import org.etsi.osl.tmf.scm633.model.*; +import org.etsi.osl.tmf.JsonUtils; + +import org.etsi.osl.tmf.scm633.reposervices.CatalogRepoService; + +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; + + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ServiceCatalogApiControllerTest { + + private static final int FIXED_BOOTSTRAPS_CATALOGS = 1; + + @Autowired + private MockMvc mvc; + + @Autowired + private WebApplicationContext context; + + @Autowired + CatalogRepoService catalogRepoService; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteServiceCatalog() throws Exception { + + String response = createServiceCatalog(); + + ResourceCatalog responsesCatalog = JsonUtils.toJsonObj(response, ResourceCatalog.class); + assertThat( responsesCatalog.getName() ).isEqualTo( "Test Catalog" ); + + String id = responsesCatalog.getId(); + + mvc.perform(MockMvcRequestBuilders.delete("/serviceCatalogManagement/v4/serviceCatalog/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( catalogRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATALOGS ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListServiceCatalog() throws Exception { + + createServiceCatalog(); + + String response = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceCatalog") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + List serviceCatalogList = JsonUtils.toJsonObj(response, ArrayList.class); + + assertThat(serviceCatalogList.size()).isEqualTo(FIXED_BOOTSTRAPS_CATALOGS + 1); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testPatchServiceCatalog() throws Exception { + + String response = createServiceCatalog(); + + ServiceCatalog responsesServiceCatalog = JsonUtils.toJsonObj(response, ServiceCatalog.class); + String id = responsesServiceCatalog.getId(); + + JSONObject obj = JsonUtils.toJsonObj(response, JSONObject.class); + obj.remove("uuid"); + obj.remove("id"); + obj.remove("lastUpdate"); + response = JsonUtils.toJsonString(obj); + + ServiceCatalogUpdate ServiceCatalogUpdate = JsonUtils.toJsonObj(response, ServiceCatalogUpdate.class); + ServiceCatalogUpdate.setName( "Test Service Catalog new name" ); + ServiceCatalogUpdate.setVersion("2.x"); + + String response2 = mvc.perform(MockMvcRequestBuilders.patch("/serviceCatalogManagement/v4/serviceCatalog/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( ServiceCatalogUpdate ) )) + .andExpect(status().isOk() ) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Service Catalog new name"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ServiceCatalog responsesServiceCatalog2 = JsonUtils.toJsonObj(response2, ServiceCatalog.class); + assertThat( responsesServiceCatalog2.getName() ).isEqualTo( "Test Service Catalog new name" ); + assertThat( responsesServiceCatalog2.getVersion() ).isEqualTo( "2.x" ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveServiceCatalog() throws Exception { + + String response = createServiceCatalog(); + + ServiceCatalog responsesServiceCatalog = JsonUtils.toJsonObj(response, ServiceCatalog.class); + String id = responsesServiceCatalog.getId(); + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceCatalog/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + ServiceCatalog responsesServiceCatalog2 = JsonUtils.toJsonObj(response2, ServiceCatalog.class); + assertThat( responsesServiceCatalog2.getName() ).isEqualTo( "Test Catalog" ); + assertThat( responsesServiceCatalog2.getVersion() ).isEqualTo( "1.8" ); + } + + private String createServiceCatalog() throws Exception{ + assertThat( catalogRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATALOGS ); + + File scatalog = new File( "src/test/resources/testResourceCatalog.txt" ); + InputStream in = new FileInputStream( scatalog ); + String resvxf = IOUtils.toString(in, "UTF-8"); + + ServiceCatalogCreate scc = JsonUtils.toJsonObj( resvxf, ServiceCatalogCreate.class); + + String response = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceCatalog") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( scc ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Catalog"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( catalogRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_CATALOGS + 1 ); + + return response; + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..865ca45fc3cb0b2f30ac468a7ea1fbbe92f92606 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/scm633/ServiceCategoryApiControllerTest.java @@ -0,0 +1,85 @@ +package org.etsi.osl.services.api.scm633; + +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.status; + +import java.util.List; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.scm633.model.*; + +import org.etsi.osl.tmf.scm633.reposervices.CategoryRepoService; +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; + + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") + +public class ServiceCategoryApiControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + CategoryRepoService categoryRepoService; + + @Autowired + private WebApplicationContext context; + + @Autowired + private ObjectMapper objectMapper; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListServiceCategory() throws Exception { + + String response = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceCategory") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + List serviceCategoryList = objectMapper.readValue(response, new TypeReference>() {}); + + assertThat(serviceCategoryList.size()).isEqualTo(categoryRepoService.findAll().size()); + String id = categoryRepoService.findAll().get(0).getId(); + + boolean idExists = false; + for (ServiceCategory ss : serviceCategoryList) { + if ( ss.getId().equals( id ) ) { + idExists= true; + } + } + assertThat( idExists ).isTrue(); + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..e5aa51e2679c9804c6b0b34e2a7703b5a0d39abb --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/scm633/ServiceSpecificationApiControllerTest.java @@ -0,0 +1,425 @@ +package org.etsi.osl.services.api.scm633; + +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.*; + +import java.io.*; +import java.util.List; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import net.minidev.json.JSONObject; +import org.apache.commons.io.IOUtils; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.Attachment; +import org.etsi.osl.tmf.rcm634.model.*; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.scm633.model.*; +import org.etsi.osl.tmf.JsonUtils; + +import org.etsi.osl.tmf.scm633.reposervices.ServiceSpecificationRepoService; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecification; +import org.etsi.osl.tmf.stm653.model.ServiceTestSpecificationCreate; +import org.etsi.osl.tmf.stm653.reposervices.ServiceTestSpecificationRepoService; +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.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.mock.web.MockMultipartFile; +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; + + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.MOCK , classes = OpenAPISpringBoot.class) +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ServiceSpecificationApiControllerTest { + + private static final int FIXED_BOOTSTRAPS_SPECS = 1; + + @Autowired + private MockMvc mvc; + + @Autowired + ServiceTestSpecificationRepoService aServiceTestSpecRpoService; + + @Autowired + ResourceSpecificationRepoService resourceSpecificationRepoService; + + @Autowired + private WebApplicationContext context; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + ServiceSpecificationRepoService specRepoService; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteServiceSpecification() throws Exception { + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + String response = createServiceSpecification(); + + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + String id = responsesSpec.getId(); + + mvc.perform(MockMvcRequestBuilders.delete("/serviceCatalogManagement/v4/serviceSpecification/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListServiceSpecification() throws Exception { + + String response = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification") + + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + List serviceSpecificationList = objectMapper.readValue(response, new TypeReference>() {}); + + assertThat(serviceSpecificationList.size()).isEqualTo(specRepoService.findAll().size()); + String id = specRepoService.findAll().get(0).getId(); + + boolean idExists = false; + for (ServiceSpecification ss : serviceSpecificationList) { + if ( ss.getId().equals( id ) ) { + idExists= true; + } + } + assertThat( idExists ).isTrue(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testPatchServiceSpecification() throws Exception { + + String response = createServiceSpecification(); + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1); + + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + String id = responsesSpec.getId(); + + JSONObject obj = JsonUtils.toJsonObj(response, JSONObject.class); + obj.remove("uuid"); + obj.remove("id"); + obj.remove("lastUpdate"); + response = JsonUtils.toJsonString(obj); + + ServiceSpecificationUpdate ServiceSpecUpdate = JsonUtils.toJsonObj(response, ServiceSpecificationUpdate.class); + ServiceSpecUpdate.setName( "Test Spec new name" ); + ServiceSpecUpdate.setVersion("2.x"); + + String response2 = mvc.perform(MockMvcRequestBuilders.patch("/serviceCatalogManagement/v4/serviceSpecification/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( ServiceSpecUpdate ) )) + .andExpect(status().isOk() ) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Spec new name"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ServiceSpecification responsesServiceSpec2 = JsonUtils.toJsonObj(response2, ServiceSpecification.class); + assertThat( responsesServiceSpec2.getName() ).isEqualTo( "Test Spec new name" ); + assertThat( responsesServiceSpec2.getVersion() ).isEqualTo( "2.x" ); + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveServiceSpecification() throws Exception { + + String response = createServiceSpecification(); + + ServiceSpecification responsesServiceSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + String id = responsesServiceSpec.getId(); + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + ServiceSpecification responsesServiceSpec2 = JsonUtils.toJsonObj(response2, ServiceSpecification.class); + assertThat( responsesServiceSpec2.getName() ).isEqualTo( "Test Spec" ); + assertThat( responsesServiceSpec2.getVersion() ).isEqualTo( "1.8.0" ); + } + + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testGetAttachment() throws Exception { + + // Create a Service Specification + String response = createServiceSpecification(); + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + String specId = responsesSpec.getId(); + + // Test method for non-existing logo attachment + String attId = "logo"; + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/" + specId + "/attachment/" + attId) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isNotFound() ) + .andReturn().getResponse().getContentAsString(); + + // Test method for non-existing non-logo attachment + attId = "random"; + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/" + specId + "/attachment/" + attId) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isNotFound() ) + .andReturn().getResponse().getContentAsString(); + + + // Test method for existing attachment + + // Add a new attachment to the Service Specification + String response2 = createAttachmentAndAddToServiceSpecification(specId); + Attachment attachment = JsonUtils.toJsonObj(response2, Attachment.class); + attId = attachment.getId(); + String attName = attachment.getName(); + String attMimeType = attachment.getMimeType(); + + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/" + specId + "/attachment/" + attId) + ) + .andExpect(content().contentTypeCompatibleWith(MediaType.ALL_VALUE)) + .andExpect(status().isOk() ) + .andExpect(header().string(HttpHeaders.CACHE_CONTROL, "no-cache")) + .andExpect(header().string(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + attName)) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, attMimeType)) + .andReturn().getResponse().getContentAsString(); + } + + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testGetAttachmentWithFilename() throws Exception { + + // Create a Service Specification + String response = createServiceSpecification(); + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + String specId = responsesSpec.getId(); + + String response2 = createAttachmentAndAddToServiceSpecification(specId); + Attachment attachment = JsonUtils.toJsonObj(response2, Attachment.class); + String attId = attachment.getId(); + String attName = attachment.getName(); + String attMimeType = attachment.getMimeType(); + + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/" + specId + "/attachment/" + attId + "/" + attName) + ) + .andExpect(content().contentTypeCompatibleWith(MediaType.ALL_VALUE)) + .andExpect(status().isOk() ) + .andExpect(header().string(HttpHeaders.CACHE_CONTROL, "no-cache")) + .andExpect(header().string(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + attName)) + .andExpect(header().string(HttpHeaders.CONTENT_TYPE, attMimeType)) + .andReturn().getResponse().getContentAsString(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveServiceSpecificationDescriptor() throws Exception { + + // Test a non-existing spec + mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/" + "fakeId" + "/sd") + ) + .andExpect(status().isNotFound()) + .andReturn().getResponse().getContentAsString(); + } + + + @WithMockUser(username = "osadmin", roles = { "ADMIN","USER" }) + @Test + public void testSpecFromTestSpec() throws Exception { + + // Creeate a Test Spec + File sspec = new File( "src/test/resources/testServiceTestSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + ServiceTestSpecificationCreate spec = JsonUtils.toJsonObj( sspectext, ServiceTestSpecificationCreate.class); + + int originalSize = aServiceTestSpecRpoService.findAll().size(); + + String response = mvc.perform(MockMvcRequestBuilders.post("/serviceTestManagement/v4/serviceTestSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( spec ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("A test name"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + + assertThat( aServiceTestSpecRpoService.findAll().size() ).isEqualTo( originalSize + 1 ); + ServiceTestSpecification sts = JsonUtils.toJsonObj(response, ServiceTestSpecification.class); + assertThat(sts.getName()).isEqualTo("A test name"); + String stsId = sts.getId(); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS); + + // Create a Service Spec from the Test Spec + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/specFromTestSpec/" + stsId) + .with( SecurityMockMvcRequestPostProcessors.csrf())) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1 ); + + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response2, ServiceSpecification.class); + assertThat( responsesSpec.getName() ).isEqualTo( "A test name" ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testGetImageSpecificationRelationshipGraph() throws Exception { + + // Create a Service Specification + String response = createServiceSpecification(); + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + String specId = responsesSpec.getId(); + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/" + specId + "/relationship_graph") + ) + .andExpect(status().is(302) ) + .andReturn().getResponse().getRedirectedUrl(); + + assertThat( response2 ).contains("/blockdiag/svg/"); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN"}) + @Test + public void testSpecFromResourceSpec() throws Exception { + + File rspec = new File( "src/test/resources/testResourceSpec.json" ); + InputStream in = new FileInputStream( rspec ); + String rspectext = IOUtils.toString(in, "UTF-8"); + ResourceSpecificationCreate rspeccr = JsonUtils.toJsonObj( rspectext, ResourceSpecificationCreate.class); + + int originalSize = resourceSpecificationRepoService.findAll().size(); + + String responseSpec = mvc.perform(MockMvcRequestBuilders.post( "/resourceCatalogManagement/v4/resourceSpecification" ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( rspeccr ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( resourceSpecificationRepoService.findAll().size() ).isEqualTo( originalSize + 1 ); + ResourceSpecification responsesSpec1 = JsonUtils.toJsonObj(responseSpec, PhysicalResourceSpecification.class); + assertThat(responsesSpec1.getName()).isEqualTo("Test Resource Spec"); + String rSpecId = responsesSpec1.getId(); + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS); + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceCatalogManagement/v4/serviceSpecification/specFromResourceSpec/" + rSpecId) + .with( SecurityMockMvcRequestPostProcessors.csrf())) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1 ); + + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response2, ServiceSpecification.class); + assertThat( responsesSpec.getName() ).isEqualTo( "Test Resource Spec" ); + } + + + private String createServiceSpecification() throws Exception{ + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + + File sspec = new File( "src/test/resources/testServiceSpec.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(); + + assertThat( specRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1 ); + + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + assertThat( responsesSpec.getName() ).isEqualTo( "Test Spec" ); + + return response; + } + + private String createAttachmentAndAddToServiceSpecification(String serviceSpecId) throws Exception { + + Attachment att = new Attachment(); + + File gz = new File( "src/test/resources/cirros_vnf.tar.gz" ); + InputStream ing = new FileInputStream( gz ); + MockMultipartFile prodFile = new MockMultipartFile("afile", "cirros_vnf.tar.gz", "application/x-gzip", IOUtils.toByteArray(ing)); + + String response = mvc.perform(MockMvcRequestBuilders + .multipart("/serviceCatalogManagement/v4/serviceSpecification/" + serviceSpecId + "/attachment" ) + .file(prodFile) + .param("attachment", JsonUtils.toJsonString(att)) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + ) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("cirros_vnf.tar.gz"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + Attachment attachment = JsonUtils.toJsonObj( response, Attachment.class); + + assertThat(attachment.getName()).isEqualTo("cirros_vnf.tar.gz"); + assertThat(attachment.getUrl()).contains(serviceSpecId); + + return response; + } +} diff --git a/src/test/java/org/etsi/osl/services/api/sim638/CommonTests.java b/src/test/java/org/etsi/osl/services/api/sim638/CommonTests.java new file mode 100644 index 0000000000000000000000000000000000000000..1ce2ccf9b17d03c77bd9fec72b2e38a9c50b9742 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/sim638/CommonTests.java @@ -0,0 +1,142 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 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.services.api.sim638; + +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.etsi.osl.tmf.sim638.api.*; +import org.junit.jupiter.api.Test; +import org.springframework.mock.web.MockHttpServletRequest; + +import java.io.IOException; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +public class CommonTests { + + @Test + public void testApiException() { + int errorCode = 404; + String errorMessage = "Not Found"; + + ApiException exception = new ApiException(errorCode, errorMessage); + + assertEquals(errorMessage, exception.getMessage()); + } + + @Test + public void testApiOriginFilter() throws IOException, ServletException { + HttpServletRequest request = mock(HttpServletRequest.class); + HttpServletResponse response = mock(HttpServletResponse.class); + FilterChain chain = mock(FilterChain.class); + + ApiOriginFilter filter = new ApiOriginFilter(); + filter.doFilter(request, response, chain); + + verify(response).addHeader("Access-Control-Allow-Origin", "*"); + verify(response).addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + verify(response).addHeader("Access-Control-Allow-Headers", "Content-Type"); + verify(chain).doFilter(request, response); + } + + @Test + public void testApiResponseMessage() { + int[] codes = {ApiResponseMessage.ERROR, ApiResponseMessage.WARNING, ApiResponseMessage.INFO, ApiResponseMessage.OK, ApiResponseMessage.TOO_BUSY, 6}; + + String[] types = {"error", "warning", "info", "ok", "too busy", "unknown"}; + + String[] messages = {"An error occured", "This is a warning", "Given info", "ok", "System is too busy", "unknown code"}; + + for (int i = 0; i < codes.length; i++) { + int code = codes[i]; + String type = types[i]; + String message = messages[i]; + + ApiResponseMessage responseMessage = new ApiResponseMessage(code, message); + + assertEquals(message, responseMessage.getMessage()); + assertEquals(code, responseMessage.getCode()); + assertEquals(type, responseMessage.getType()); + + } + + ApiResponseMessage responseMessage = new ApiResponseMessage(); + responseMessage.setMessage("Error"); + assertEquals("Error", responseMessage.getMessage()); + responseMessage.setType("ok"); + assertEquals("ok", responseMessage.getType()); + responseMessage.setCode(ApiResponseMessage.OK); + assertEquals(ApiResponseMessage.OK, responseMessage.getCode()); + } + + @Test + public void testHubApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + HubApiController controller = new HubApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testListenerApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + ListenerApiController controller = new ListenerApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testNotFoundException() { + int errorCode = 404; + String errorMessage = "Not Found"; + + NotFoundException exception = new NotFoundException(errorCode, errorMessage); + + assertEquals(errorMessage, exception.getMessage()); + } + +} + diff --git a/src/test/java/org/etsi/osl/services/api/sim638/RFC3339DateFormatTest.java b/src/test/java/org/etsi/osl/services/api/sim638/RFC3339DateFormatTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8f53698db868f4f7c9a18813645697c2036b4bfb --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/sim638/RFC3339DateFormatTest.java @@ -0,0 +1,25 @@ +package org.etsi.osl.services.api.sim638; + +import java.text.FieldPosition; +import java.util.Date; + +import org.etsi.osl.tmf.sim638.api.RFC3339DateFormat; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; + + +public class RFC3339DateFormatTest { + + @Test + public void testFormat() { + RFC3339DateFormat rfc3339DateFormat = new RFC3339DateFormat(); + Date date = new Date(1637484321000L); + + StringBuffer stringBuffer = new StringBuffer(); + FieldPosition fieldPosition = new FieldPosition(0); + StringBuffer formattedDate = rfc3339DateFormat.format(date, stringBuffer, fieldPosition); + + assertEquals("2021-11-21T08:45:21.000Z", formattedDate.toString()); + } +} diff --git a/src/test/java/org/etsi/osl/services/api/sim638/ServiceApiControllerTest.java b/src/test/java/org/etsi/osl/services/api/sim638/ServiceApiControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5c59431d0b5ac8e2852034a9cf4afb292078ac99 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/sim638/ServiceApiControllerTest.java @@ -0,0 +1,238 @@ +package org.etsi.osl.services.api.sim638; + +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.common.model.service.ServiceSpecificationRef; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.sim638.api.ServiceApiController; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import org.etsi.osl.tmf.so641.model.*; +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; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +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 java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.security.Principal; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +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 ServiceApiControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + ServiceRepoService serviceRepoService; + + @Autowired + private WebApplicationContext context; + + @Autowired + private ObjectMapper objectMapper; + + private ServiceApiController mockServiceApiController; + + private ServiceRepoService mockServiceRepoService; + + @Before + public void setup() throws Exception { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + + // Mocks + mockServiceRepoService = mock(ServiceRepoService.class); + ObjectMapper mockObjectMapper = mock(ObjectMapper.class); + mockServiceApiController = new ServiceApiController(mockObjectMapper, null); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteService() throws Exception { + String response = createService(); + Service responsesService = JsonUtils.toJsonObj(response, Service.class); + String id = responsesService.getId(); + + mvc.perform(MockMvcRequestBuilders.delete("/serviceInventory/v4/service/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().is(501) ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListService() throws Exception { + String response = mvc.perform(MockMvcRequestBuilders.get("/serviceInventory/v4/service" ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + List serviceList = objectMapper.readValue(response, new TypeReference>() {}); + assertThat(serviceList.size()).isEqualTo(serviceRepoService.findAll().size()); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveService() throws Exception { + String response = createService(); + Service responsesService = JsonUtils.toJsonObj(response, Service.class); + String id = responsesService.getId(); + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceInventory/v4/service/" + id) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + Service responsesService2 = JsonUtils.toJsonObj(response2, Service.class); + + assertThat(responsesService2.getId()).isEqualTo(responsesService.getId()); + assertThat(responsesService2.getCategory()).isEqualTo(responsesService.getCategory()); + assertThat(responsesService2.getName()).isEqualTo(responsesService.getName()); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testCreateServiceHandleException() { + ServiceCreate serviceCreate = new ServiceCreate(); + serviceCreate.setName("Test name"); + + when(mockServiceRepoService.addService(any())) + .thenThrow(new RuntimeException("Test exception")); + + ResponseEntity response = mockServiceApiController.createService(mock(Principal.class), serviceCreate); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListServiceHandleException(){ + when(mockServiceRepoService.findAll()) + .thenThrow(new RuntimeException("Test exception")); + + ResponseEntity> response = mockServiceApiController.listService(mock(Principal.class), null, null, null); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveServiceHandleException(){ + when(mockServiceRepoService.findByUuid(any())) + .thenThrow(new RuntimeException("Test exception")); + + ResponseEntity response = mockServiceApiController.retrieveService(mock(Principal.class), "test id", ""); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); + } + + + private String createService() throws Exception { + int servicesCount = serviceRepoService.findAll().size(); + + File sspec = new File("src/test/resources/testServiceSpec.json"); + InputStream in = new FileInputStream(sspec); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ServiceSpecificationCreate sspeccr = JsonUtils.toJsonObj(sspectext, ServiceSpecificationCreate.class); + sspeccr.setName("Spec1"); + ServiceSpecification responsesSpec = createServiceSpec( sspeccr); + + ServiceOrderCreate serviceOrder = new ServiceOrderCreate(); + serviceOrder.setCategory("Test Category"); + serviceOrder.setDescription("A Test Service"); + serviceOrder.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + serviceOrder.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + + ServiceOrderItem soi = new ServiceOrderItem(); + serviceOrder.getOrderItem().add(soi); + soi.setState(ServiceOrderStateType.ACKNOWLEDGED); + + ServiceRestriction serviceRestriction = new ServiceRestriction(); + ServiceSpecificationRef aServiceSpecificationRef = new ServiceSpecificationRef(); + aServiceSpecificationRef.setId(responsesSpec.getId()); + aServiceSpecificationRef.setName(responsesSpec.getName()); + + serviceRestriction.setServiceSpecification(aServiceSpecificationRef); + serviceRestriction.setName("aServiceRestriction"); + soi.setService(serviceRestriction); + + String response = mvc + .perform(MockMvcRequestBuilders.post("/serviceInventory/v4/service") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(serviceOrder))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + Service responseService = JsonUtils.toJsonObj(response, Service.class); + + assertThat( serviceRepoService.findAll().size() ).isEqualTo( servicesCount + 1 ); + assertThat(responseService.getCategory()).isEqualTo("Test Category"); + assertThat(responseService.getDescription()).isEqualTo("A Test Service"); + + return response; + } + + + private ServiceSpecification createServiceSpec( ServiceSpecificationCreate serviceSpecificationCreate) throws Exception { + String response = mvc + .perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(serviceSpecificationCreate))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + + return responsesSpec; + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..7b6b52c8390833edec7a1462a0e3551444f03327 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/sim638/ServiceRepoServiceTest.java @@ -0,0 +1,478 @@ +package org.etsi.osl.services.api.sim638; + +import org.apache.commons.io.IOUtils; +import org.etsi.osl.model.nfv.DeploymentDescriptor; +import org.etsi.osl.tmf.JsonUtils; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.common.model.AttachmentRefOrValue; +import org.etsi.osl.tmf.common.model.UserPartRoleType; +import org.etsi.osl.tmf.common.model.service.*; +import org.etsi.osl.tmf.common.model.service.Characteristic; +import org.etsi.osl.tmf.common.model.service.Place; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification; +import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecificationCreate; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecificationRef; +import org.etsi.osl.tmf.ri639.model.*; +import org.etsi.osl.tmf.ri639.reposervices.ResourceRepoService; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceActionQueueItem; +import org.etsi.osl.tmf.sim638.model.ServiceCreate; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.context.WebApplicationContext; + +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.List; +import java.util.Set; + +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.*; + +@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 ServiceRepoServiceTest { + @Autowired + private MockMvc mvc; + + @Autowired + ServiceRepoService serviceRepoService; + + @Autowired + ResourceRepoService resourceRepoService; + + @Autowired + private WebApplicationContext context; + + @Before + public void setup() { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testFindAll() throws Exception { + String response = createService(); + Service responsesService = JsonUtils.toJsonObj(response, Service.class); + String id = responsesService.getId(); + + List serviceList = serviceRepoService.findAll("Test Party", UserPartRoleType.REQUESTER); + + boolean idExists = false; + for (Service s : serviceList) { + if ( s.getId().equals( id ) ) { + idExists= true; + } + } + assertThat( idExists ).isTrue(); + } + + // 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.] +// @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) +// @Test +// public void testUpdateService() throws Exception { +// String response = createService(); +// Service responsesService = JsonUtils.toJsonObj(response, Service.class); +// String id = responsesService.getId(); +// +// ServiceUpdate serviceUpdate = createServiceUpdateObject(); +// serviceRepoService.updateService(id, serviceUpdate, true, null, null); +// +// Service updatedService = serviceRepoService.findByUuid(id); +// assertThat(updatedService.getType()).isEqualTo("Updated type"); +// assertThat(updatedService.getName()).isEqualTo("Updated name"); +// assertThat(updatedService.getServiceType()).isEqualTo("Updated Service Type"); +// } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteServiceActionQueueItemByUuid() throws Exception { + ServiceActionQueueItem saqi = new ServiceActionQueueItem(); + ServiceActionQueueItem saqiResponse = serviceRepoService.addServiceActionQueueItem(saqi); + String uuid = saqiResponse.getUuid(); + + serviceRepoService.deleteServiceActionQueueItemByUuid(uuid); + List saqiList = serviceRepoService.findAllServiceActionQueueItems(); + + boolean idExists = false; + for (ServiceActionQueueItem s : saqiList) { + if ( s.getUuid().equals( uuid ) ) { + idExists= true; + break; + } + } + assertThat( idExists ).isFalse(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testFindAllActiveServicesToTerminate() throws Exception { + String response = createService(); + Service responsesService = JsonUtils.toJsonObj(response, Service.class); + String id = responsesService.getId(); + + List serviceList = serviceRepoService.findAllActiveServicesToTerminate(); + + boolean idExists = false; + for (String serviceId : serviceList) { + if (serviceId.equals(id)) { + idExists = true; + break; + } + } + assertThat( idExists ).isTrue(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testFindAllActiveAndReservedServicesOfPartners() throws Exception { + String response = createService(); + Service responsesService = JsonUtils.toJsonObj(response, Service.class); + String id = responsesService.getId(); + + List serviceList = serviceRepoService.findAllActiveAndReservedServicesOfPartners(); + + boolean idExists = false; + for (String serviceId : serviceList) { + if (serviceId.equals(id)) { + idExists = true; + break; + } + } + assertThat( idExists ).isTrue(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testFindDeploymentRequestID() throws Exception { + String response = createService(); + Service responsesService = JsonUtils.toJsonObj(response, Service.class); + String id = responsesService.getId(); + + List serviceList = serviceRepoService.findDeploymentRequestID("1234567890"); + + boolean idExists = false; + for (Service s : serviceList) { + if ( s.getId().equals( id ) ) { + idExists= true; + } + } + assertThat( idExists ).isTrue(); + } + + +// // 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 testNfvCatalogNSResourceChanged() throws Exception { +// String response = createService(); +// Service responsesService = JsonUtils.toJsonObj(response, Service.class); +// String id = responsesService.getId(); +// +// DeploymentDescriptor dd = new DeploymentDescriptor(); +// dd.setId(1234567890); +// +// serviceRepoService.nfvCatalogNSResourceChanged(dd); +// +// Service updatedService = serviceRepoService.findByUuid(id); +// Set noteList = updatedService.getNote(); +// +// boolean expectedNoteExists = false; +// for (Note n : noteList) { +// if ( n.getText().equals("NS Resource LCM Changed") && n.getAuthor().equals("SIM638-API")) { +// expectedNoteExists= true; +// break; +// } +// } +// assertThat( expectedNoteExists ).isTrue(); +// } + + +// // 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(); +// } + + + private String createService() throws Exception { + int servicesCount = serviceRepoService.findAll().size(); + + File sspec = new File( "src/test/resources/testServiceSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ServiceSpecificationCreate sspeccr1 = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + sspeccr1.setName("Spec1"); + ServiceSpecification responsesSpec1 = createServiceSpec(sspectext, sspeccr1); + + //service 2 is an RFS + ServiceSpecificationCreate sspeccr2 = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + sspeccr2.setName("Spec2"); + ResourceSpecificationRef resourceSpecificationItem = new ResourceSpecificationRef(); + resourceSpecificationItem.setId("resourceid"); + resourceSpecificationItem.setName("resourceName"); + sspeccr2.addResourceSpecificationItem(resourceSpecificationItem); + ServiceSpecification responsesSpec2 = createServiceSpec(sspectext, sspeccr2); + + // Add them as bundle + ServiceSpecificationCreate sspeccr3 = JsonUtils.toJsonObj( sspectext, ServiceSpecificationCreate.class); + sspeccr3.setName("BundleExampleSpec"); + sspeccr3.isBundle(true); + sspeccr3.addServiceSpecRelationshipWith( responsesSpec1 ); + sspeccr3.addServiceSpecRelationshipWith( responsesSpec2 ); + ServiceSpecification responsesSpec3 = createServiceSpec(sspectext, sspeccr3); + + ServiceCreate aService = new ServiceCreate(); + aService.setName("aNew Service"); + aService.setCategory("Test Category"); + aService.setDescription("A Test Service"); + aService.setStartDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + aService.setEndDate( OffsetDateTime.now(ZoneOffset.UTC ).toString() ); + aService.setState(ServiceStateType.ACTIVE); + + Note noteItem = new Note(); + noteItem.text("test note"); + aService.addNoteItem(noteItem); + + Characteristic serviceCharacteristicItem = new Characteristic(); + + serviceCharacteristicItem.setName( "ConfigStatus" ); + serviceCharacteristicItem.setValue( new Any("NONE")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "NSLCM" ); + serviceCharacteristicItem.setValue( new Any("nslcm_test")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "NSR" ); + serviceCharacteristicItem.setValue( new Any("nsr_test")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "externalPartnerServiceId" ); + serviceCharacteristicItem.setValue( new Any("ext_test")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "DeploymentRequestID" ); + serviceCharacteristicItem.setValue( new Any("1234567890")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + serviceCharacteristicItem = new Characteristic(); + serviceCharacteristicItem.setName( "long_string" ); + serviceCharacteristicItem.setValue( new Any("12345")); + aService.addServiceCharacteristicItem(serviceCharacteristicItem); + + ServiceSpecificationRef aServiceSpecificationRef = new ServiceSpecificationRef(); + aServiceSpecificationRef.setId(responsesSpec3.getId() ); + aServiceSpecificationRef.setName(responsesSpec3.getName()); + + aService.setServiceSpecificationRef(aServiceSpecificationRef ); + + List rpl = new ArrayList<>(); + RelatedParty rp = new RelatedParty(); + rp.setName("Test Party"); + rpl.add(rp); + aService.setRelatedParty(rpl); + + ResourceCreate rc = new ResourceCreate(); + rc.setName("Test Resource"); + rc.setCategory("Test Resource Category"); + LogicalResourceSpecification lrs = createLogicalResourceSpec(); + ResourceSpecificationRef rsRef = new ResourceSpecificationRef(); + rsRef.setId(lrs.getId()); + rsRef.setName(lrs.getName()); + rc.setResourceSpecification(rsRef); + Resource resourceResponse = resourceRepoService.addResource(rc); + List rrl = new ArrayList<>(); + ResourceRef rRef = new ResourceRef(); + rRef.setId(resourceResponse.getId()); + rRef.setName(resourceResponse.getName()); + rrl.add(rRef); + + aService.setSupportingResource(rrl); + + String response = mvc.perform(MockMvcRequestBuilders.post("/serviceInventory/v4/service") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( aService ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + Service responseService = JsonUtils.toJsonObj(response, Service.class); + + assertThat( serviceRepoService.findAll().size() ).isEqualTo( servicesCount + 1 ); + assertThat(responseService.getCategory()).isEqualTo("Test Category"); + assertThat(responseService.getDescription()).isEqualTo("A Test Service"); + + return response; + } + + + private ServiceSpecification createServiceSpec(String sspectext, ServiceSpecificationCreate sspeccr1) throws Exception{ + String response = mvc.perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr1 ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + return responsesSpec; + } + + + private LogicalResourceSpecification createLogicalResourceSpec() throws Exception{ + File sspec = new File( "src/test/resources/testResourceSpec.json" ); + InputStream in = new FileInputStream( sspec ); + String sspectext = IOUtils.toString(in, "UTF-8"); + LogicalResourceSpecificationCreate sspeccr = JsonUtils.toJsonObj( sspectext, LogicalResourceSpecificationCreate.class); + + AttachmentRefOrValue attachmentItem = new AttachmentRefOrValue(); + attachmentItem.setId( "a-ref-id" ); + attachmentItem.setDescription("an attachment"); + attachmentItem.setUrl("a url"); + attachmentItem.setName("aname"); + sspeccr.addAttachmentItem(attachmentItem); + String response = mvc.perform(MockMvcRequestBuilders.post("/resourceCatalogManagement/v4/resourceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( sspeccr ) )) + .andExpect(status().isOk()) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("name", is("Test Resource Spec"))) + .andExpect(status().isOk()) + .andReturn().getResponse().getContentAsString(); + + LogicalResourceSpecification responsesSpec = JsonUtils.toJsonObj(response, LogicalResourceSpecification.class); + return responsesSpec; + } + + +// private ServiceUpdate createServiceUpdateObject() throws Exception{ +// ServiceUpdate serviceUpdate = new ServiceUpdate(); +// serviceUpdate.setType("Updated type"); +// serviceUpdate.setName("Updated name"); +// serviceUpdate.setCategory("Updated category"); +// serviceUpdate.setDescription("Updated description"); +// serviceUpdate.setStartDate(OffsetDateTime.now(ZoneOffset.UTC ).toString()); +// serviceUpdate.hasStarted(true); +// serviceUpdate.isServiceEnabled(true); +// serviceUpdate.isStateful(true); +// serviceUpdate.setServiceDate(OffsetDateTime.now(ZoneOffset.UTC ).toString()); +// serviceUpdate.setServiceType("Updated Service Type"); +// serviceUpdate.setStartMode("Updated Start Mode"); +// serviceUpdate.setState(ServiceStateType.FEASIBILITYCHECKED); + +// List placeList = new ArrayList<>(); +// Place place = new Place(); +// place.setName("Updated place"); +// place.setType("Updated type"); +// placeList.add(place); +// serviceUpdate.setPlace(placeList); +// +// List partyList = new ArrayList<>(); +// RelatedParty party = new RelatedParty(); +// party.setName("Updated party"); +// party.setType("Updated type"); +// partyList.add(party); +// serviceUpdate.setRelatedParty(partyList); +// +// ResourceCreate rc = new ResourceCreate(); +// rc.setName("Updated Resource"); +// rc.setCategory("Updated Resource Category"); +// LogicalResourceSpecification lrs = createLogicalResourceSpec(); +// ResourceSpecificationRef rsRef = new ResourceSpecificationRef(); +// rsRef.setId(lrs.getId()); +// rsRef.setName(lrs.getName()); +// rc.setResourceSpecification(rsRef); +// Resource resourceResponse = resourceRepoService.addResource(rc); +// List rrl = new ArrayList<>(); +// ResourceRef rRef = new ResourceRef(); +// rRef.setId(resourceResponse.getId()); +// rRef.setName(resourceResponse.getName()); +// rrl.add(rRef); +// +// serviceUpdate.setSupportingResource(rrl); +// +// return serviceUpdate; +// } +} diff --git a/src/test/java/org/etsi/osl/services/api/so641/CommonTests.java b/src/test/java/org/etsi/osl/services/api/so641/CommonTests.java new file mode 100644 index 0000000000000000000000000000000000000000..2b935d8e4b2986b2fd1ce6d5e3bff654980dcef7 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/so641/CommonTests.java @@ -0,0 +1,142 @@ +/*- + * ========================LICENSE_START================================= + * org.etsi.osl.tmf.api + * %% + * Copyright (C) 2019 - 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.services.api.so641; + +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.etsi.osl.tmf.so641.api.*; +import org.junit.jupiter.api.Test; +import org.springframework.mock.web.MockHttpServletRequest; + +import java.io.IOException; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +public class CommonTests { + + @Test + public void testApiException() { + int errorCode = 404; + String errorMessage = "Not Found"; + + ApiException exception = new ApiException(errorCode, errorMessage); + + assertEquals(errorMessage, exception.getMessage()); + } + + @Test + public void testApiOriginFilter() throws IOException, ServletException { + HttpServletRequest request = mock(HttpServletRequest.class); + HttpServletResponse response = mock(HttpServletResponse.class); + FilterChain chain = mock(FilterChain.class); + + ApiOriginFilter filter = new ApiOriginFilter(); + filter.doFilter(request, response, chain); + + verify(response).addHeader("Access-Control-Allow-Origin", "*"); + verify(response).addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + verify(response).addHeader("Access-Control-Allow-Headers", "Content-Type"); + verify(chain).doFilter(request, response); + } + + @Test + public void testApiResponseMessage() { + int[] codes = {ApiResponseMessage.ERROR, ApiResponseMessage.WARNING, ApiResponseMessage.INFO, ApiResponseMessage.OK, ApiResponseMessage.TOO_BUSY, 6}; + + String[] types = {"error", "warning", "info", "ok", "too busy", "unknown"}; + + String[] messages = {"An error occured", "This is a warning", "Given info", "ok", "System is too busy", "unknown code"}; + + for (int i = 0; i < codes.length; i++) { + int code = codes[i]; + String type = types[i]; + String message = messages[i]; + + ApiResponseMessage responseMessage = new ApiResponseMessage(code, message); + + assertEquals(message, responseMessage.getMessage()); + assertEquals(code, responseMessage.getCode()); + assertEquals(type, responseMessage.getType()); + + } + + ApiResponseMessage responseMessage = new ApiResponseMessage(); + responseMessage.setMessage("Error"); + assertEquals("Error", responseMessage.getMessage()); + responseMessage.setType("ok"); + assertEquals("ok", responseMessage.getType()); + responseMessage.setCode(ApiResponseMessage.OK); + assertEquals(ApiResponseMessage.OK, responseMessage.getCode()); + } + + @Test + public void testHubApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + HubApiController controller = new HubApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testListenerApiController() { + ObjectMapper objectMapper = new ObjectMapper(); + HttpServletRequest request = new MockHttpServletRequest(); + + ListenerApiController controller = new ListenerApiController(objectMapper, request); + + Optional returnedObjectMapper = controller.getObjectMapper(); + Optional returnedRequest = controller.getRequest(); + + assertTrue(returnedObjectMapper.isPresent()); + assertTrue(returnedRequest.isPresent()); + + assertEquals(objectMapper, returnedObjectMapper.get()); + assertEquals(request, returnedRequest.get()); + } + + @Test + public void testNotFoundException() { + int errorCode = 404; + String errorMessage = "Not Found"; + + NotFoundException exception = new NotFoundException(errorCode, errorMessage); + + assertEquals(errorMessage, exception.getMessage()); + } + +} + 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 new file mode 100644 index 0000000000000000000000000000000000000000..305d454c0c3391b3f454e05b56e7a0d72d6e45b0 --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderApiControllerTest.java @@ -0,0 +1,321 @@ +package org.etsi.osl.services.api.so641; + +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.*; + +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.List; +import java.util.Set; +import java.util.Optional; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.io.IOUtils; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.so641.model.*; +import org.etsi.osl.tmf.so641.reposervices.ServiceOrderRepoService; +import org.etsi.osl.tmf.JsonUtils; + +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; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.MOCK, + classes = OpenAPISpringBoot.class +) +//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ServiceOrderApiControllerTest { + + private static final int FIXED_BOOTSTRAPS_SPECS = 0; + + @Autowired + private MockMvc mvc; + + @Autowired + ServiceOrderRepoService serviceOrderRepoService; + + @Autowired + private WebApplicationContext context; + + @Autowired + private ObjectMapper objectMapper; + + @Before + public void setup() throws Exception { + mvc = MockMvcBuilders + .webAppContextSetup(context) + .apply(springSecurity()) + .build(); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testCreateServiceOrder() throws Exception { + + String response = createServiceOrder(); + + ServiceOrder responsesServiceOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + assertThat( responsesServiceOrder.getDescription() ).isEqualTo( "A Test Service Order" ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testCreateServiceOrderWithNonExistingServiceSpecification() throws Exception { + + createServiceOrderWithNonExistingServiceSpecification(); + assertThat( serviceOrderRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testDeleteServiceOrder() throws Exception { + + String response = createServiceOrder(); + + ServiceOrder responsesServiceOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String id = responsesServiceOrder.getId(); + + mvc.perform(MockMvcRequestBuilders.delete("/serviceOrdering/v4/serviceOrder/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + assertThat( serviceOrderRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testListServiceOrder() throws Exception { + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceOrdering/v4/serviceOrder") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + List serviceOrderList= objectMapper.readValue(response2, new TypeReference>() {}); + assertThat(serviceOrderList.size()).isEqualTo(serviceOrderRepoService.findAll().size()); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testPatchServiceOrder() throws Exception { + + String response = createServiceOrder(); + ServiceOrder responsesServiceOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String soId = responsesServiceOrder.getId(); + + ServiceOrderUpdate servOrderUpd = new ServiceOrderUpdate(); + servOrderUpd.setState(ServiceOrderStateType.COMPLETED); + servOrderUpd.setCategory("New Test Category"); + servOrderUpd.setDescription("New Test Description"); + + String response2 = mvc.perform(MockMvcRequestBuilders.patch("/serviceOrdering/v4/serviceOrder/" + soId) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON) + .content( JsonUtils.toJson( servOrderUpd ) )) + .andExpect(status().isOk() ) + .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andReturn().getResponse().getContentAsString(); + + ServiceOrder responsesServiceOrder2 = JsonUtils.toJsonObj(response2, ServiceOrder.class); + assertThat(responsesServiceOrder2.getState().toString()).isEqualTo("COMPLETED"); + assertThat(responsesServiceOrder2.getDescription()).isEqualTo("New Test Description"); + assertThat(responsesServiceOrder2.getCategory()).isEqualTo("New Test Category"); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testRetrieveServiceOrder() throws Exception { + + String response = createServiceOrder(); + + ServiceOrder responsesServiceOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String id = responsesServiceOrder.getId(); + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceOrdering/v4/serviceOrder/" + id ) + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk() ) + .andReturn().getResponse().getContentAsString(); + + ServiceOrder responsesServiceOrder2 = JsonUtils.toJsonObj(response2, ServiceOrder.class); + assertThat( responsesServiceOrder2.getDescription() ).isEqualTo( "A Test Service Order" ); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testGetImageServiceOrderItemRelationshipGraph() throws Exception { + + // Create a Service Order + String response = createServiceOrder(); + ServiceOrder responsesOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String orderId = responsesOrder.getId(); + + String soiId = ""; + Set serviceOrderItemSet = responsesOrder.getOrderItem(); + + // Find the first element if present + Optional optionalFirstServiceOrderItem = serviceOrderItemSet.stream().findFirst(); + + if (optionalFirstServiceOrderItem.isPresent()) { + soiId = optionalFirstServiceOrderItem.get().getId(); + } + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceOrdering/v4/serviceOrder/" + orderId + "/item/" + soiId + "/relationship_graph") + ) + .andExpect(status().is(302) ) + .andReturn().getResponse().getRedirectedUrl(); + + assertThat( response2 ).contains("/blockdiag/svg/"); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testGetImageServiceOrderNotesGraph() throws Exception { + + // Create a Service Order + String response = createServiceOrder(); + ServiceOrder responsesOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String orderId = responsesOrder.getId(); + + String response2 = mvc.perform(MockMvcRequestBuilders.get("/serviceOrdering/v4/serviceOrder/" + orderId + "/notes_graph") + ) + .andExpect(status().is(302) ) + .andReturn().getResponse().getRedirectedUrl(); + + assertThat( response2 ).contains("/actdiag/svg/"); + } + + + private String createServiceOrder() throws Exception { + + assertThat( serviceOrderRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS); + + File sspec = new File("src/test/resources/testServiceSpec.json"); + InputStream in = new FileInputStream(sspec); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ServiceSpecificationCreate sspeccr = JsonUtils.toJsonObj(sspectext, ServiceSpecificationCreate.class); + sspeccr.setName("Spec1"); + ServiceSpecification responsesSpec = createServiceSpec( sspeccr); + + ServiceOrderCreate serviceOrder = new ServiceOrderCreate(); + serviceOrder.setCategory("Test Category"); + serviceOrder.setDescription("A Test Service Order"); + serviceOrder.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + serviceOrder.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + + ServiceOrderItem soi = new ServiceOrderItem(); + serviceOrder.getOrderItem().add(soi); + soi.setState(ServiceOrderStateType.ACKNOWLEDGED); + + ServiceRestriction serviceRestriction = new ServiceRestriction(); + ServiceSpecificationRef aServiceSpecificationRef = new ServiceSpecificationRef(); + aServiceSpecificationRef.setId(responsesSpec.getId()); + aServiceSpecificationRef.setName(responsesSpec.getName()); + + serviceRestriction.setServiceSpecification(aServiceSpecificationRef); + serviceRestriction.setName("aServiceRestriction"); + soi.setService(serviceRestriction); + + String response = mvc + .perform(MockMvcRequestBuilders.post("/serviceOrdering/v4/serviceOrder") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(serviceOrder))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + ServiceOrder responseSO = JsonUtils.toJsonObj(response, ServiceOrder.class); + + assertThat( serviceOrderRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS + 1 ); + assertThat(responseSO.getCategory()).isEqualTo("Test Category"); + assertThat(responseSO.getDescription()).isEqualTo("A Test Service Order"); + + return response; + + } + + + private ServiceSpecification createServiceSpec( ServiceSpecificationCreate serviceSpecificationCreate) throws Exception { + + String response = mvc + .perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(serviceSpecificationCreate))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + + return responsesSpec; + } + + + private void createServiceOrderWithNonExistingServiceSpecification() throws Exception { + + assertThat( serviceOrderRepoService.findAll().size() ).isEqualTo( FIXED_BOOTSTRAPS_SPECS); + + ServiceOrderCreate serviceOrder = new ServiceOrderCreate(); + serviceOrder.setCategory("Test Category"); + serviceOrder.setDescription("A Test Service Order"); + serviceOrder.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + serviceOrder.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + + ServiceOrderItem soi = new ServiceOrderItem(); + serviceOrder.getOrderItem().add(soi); + soi.setState(ServiceOrderStateType.ACKNOWLEDGED); + + ServiceRestriction serviceRestriction = new ServiceRestriction(); + ServiceSpecificationRef aServiceSpecificationRef = new ServiceSpecificationRef(); + aServiceSpecificationRef.setId("A random non-existing Id"); + aServiceSpecificationRef.setName("A random non-existing name"); + + serviceRestriction.setServiceSpecification(aServiceSpecificationRef); + serviceRestriction.setName("aServiceRestriction"); + soi.setService(serviceRestriction); + + mvc + .perform(MockMvcRequestBuilders.post("/serviceOrdering/v4/serviceOrder") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(serviceOrder))) + .andExpect(status().isBadRequest()).andReturn().getResponse().getContentAsString(); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..2cc5b0e9f819bc1a94867eeeca9afb03773014bf --- /dev/null +++ b/src/test/java/org/etsi/osl/services/api/so641/ServiceOrderRepoServiceTest.java @@ -0,0 +1,285 @@ +package org.etsi.osl.services.api.so641; + +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.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.*; + +import org.apache.commons.io.IOUtils; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.common.model.service.ServiceSpecificationRef; +import org.etsi.osl.tmf.scm633.model.ServiceSpecification; +import org.etsi.osl.tmf.scm633.model.ServiceSpecificationCreate; +import org.etsi.osl.tmf.so641.model.*; +import org.etsi.osl.tmf.so641.reposervices.ServiceOrderRepoService; +import org.etsi.osl.tmf.JsonUtils; + +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; + +@RunWith(SpringRunner.class) +@Transactional +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.MOCK, + classes = OpenAPISpringBoot.class +) +//@AutoConfigureTestDatabase //this automatically uses h2 +@AutoConfigureMockMvc +@ActiveProfiles("testing") +public class ServiceOrderRepoServiceTest { + + @Autowired + private MockMvc mvc; + + @Autowired + ServiceOrderRepoService serviceOrderRepoService; + + @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 = createServiceOrder(); + + ServiceOrder responsesServiceOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String soId = responsesServiceOrder.getId(); + String state = responsesServiceOrder.getState().toString(); + + // Test with not null params + Map params = new HashMap<>(); + params.put("state", state); + + List serviceOrderList = serviceOrderRepoService.findAllParams(params); + + boolean idExists = false; + for (ServiceOrder so : serviceOrderList) { + if ( so.getId().equals( soId ) ) { + idExists= true; + } + } + assertThat( idExists ).isTrue(); + + // Test with null params + Map paramsEmpty = new HashMap<>(); + List serviceOrderListEmptyParams = serviceOrderRepoService.findAllParams(paramsEmpty); + + boolean idExistsEmptyParams = false; + for (ServiceOrder so : serviceOrderListEmptyParams) { + if ( so.getId().equals( soId ) ) { + idExistsEmptyParams= true; + } + } + assertThat( idExistsEmptyParams ).isTrue(); + assertThat(serviceOrderListEmptyParams.size()).isEqualTo(serviceOrderRepoService.findAll().size()); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testFindAllParamsJsonOrderIDs() throws Exception { + + String response = createServiceOrder(); + String response2 = createServiceOrder(); + + ServiceOrder responsesServiceOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String soId = responsesServiceOrder.getId(); + + ServiceOrder responsesServiceOrder2 = JsonUtils.toJsonObj(response2, ServiceOrder.class); + String soId2 = responsesServiceOrder2.getId(); + + String state = responsesServiceOrder.getState().toString(); + Map params = new HashMap<>(); + params.put("state", state); + + String soIds = serviceOrderRepoService.findAllParamsJsonOrderIDs(params); + assertThat(soIds).contains(soId); + assertThat(soIds).contains(soId2); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testUpdateServiceOrder() throws Exception { + + String response = createServiceOrder(); + ServiceOrder responsesServiceOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String soId = responsesServiceOrder.getId(); + + ServiceOrderUpdate servOrderUpd = new ServiceOrderUpdate(); + servOrderUpd.setExpectedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + Note en = new Note(); + en.text("test note2"); + servOrderUpd.addNoteItem(en); + servOrderUpd.addOrderItemItem((new ArrayList<>(responsesServiceOrder.getOrderItem())).get(0)); + servOrderUpd.getOrderItem().get(0).setState(ServiceOrderStateType.INPROGRESS); + servOrderUpd.setState(ServiceOrderStateType.COMPLETED); + servOrderUpd.setCategory("New Test Category"); + servOrderUpd.setDescription("New Test Description"); + servOrderUpd.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + servOrderUpd.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + servOrderUpd.setStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + + List serviceOrderRelationshipList = new ArrayList<>(); + serviceOrderRelationshipList.add(new ServiceOrderRelationship()); + servOrderUpd.setOrderRelationship(serviceOrderRelationshipList); + + ServiceOrder responseSOUpd = serviceOrderRepoService.updateServiceOrder(soId, servOrderUpd); + assertThat(responseSOUpd.getState().toString()).isEqualTo("COMPLETED"); + assertThat(responseSOUpd.getDescription()).isEqualTo("New Test Description"); + } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testGetServiceOrderEagerAsString() throws Exception { + + String response = createServiceOrder(); + ServiceOrder responsesServiceOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String soId = responsesServiceOrder.getId(); + + String eager = serviceOrderRepoService.getServiceOrderEagerAsString(soId); + ServiceOrder eagerServiceOrder = JsonUtils.toJsonObj(eager, ServiceOrder.class); + assertThat(eagerServiceOrder.getDescription()).isEqualTo("A Test Service Order"); + assertThat(eagerServiceOrder.getCategory()).isEqualTo("Test Category"); + assertThat(eagerServiceOrder.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 testAddServiceOrderReturnEager() throws Exception { +// +// ServiceOrderCreate serviceOrder = new ServiceOrderCreate(); +// serviceOrder.setCategory("Test Category"); +// serviceOrder.setDescription("A Test Service Order"); +// serviceOrder.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); +// serviceOrder.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); +// +// Note noteItem = new Note(); +// noteItem.text("Test note"); +// serviceOrder.addNoteItem(noteItem); +// +// ServiceOrderItem soi = new ServiceOrderItem(); +// serviceOrder.getOrderItem().add(soi); +// soi.setState(ServiceOrderStateType.ACKNOWLEDGED); +// +// +// String eager = serviceOrderRepoService.addServiceOrderReturnEager(serviceOrder); +// ServiceOrder eagerServiceOrder = JsonUtils.toJsonObj(eager, ServiceOrder.class); +// assertThat(eagerServiceOrder.getDescription()).isEqualTo("A Test Service Order"); +// assertThat(eagerServiceOrder.getCategory()).isEqualTo("Test Category"); +// } + + + @WithMockUser(username="osadmin", roles = {"ADMIN","USER"}) + @Test + public void testGetImageServiceOrderItemRelationshipGraph() throws Exception { + + String response = createServiceOrder(); + ServiceOrder responsesServiceOrder = JsonUtils.toJsonObj(response, ServiceOrder.class); + String soId = responsesServiceOrder.getId(); + Set serviceOrderItemSet = responsesServiceOrder.getOrderItem(); + + for (ServiceOrderItem soi: serviceOrderItemSet) { + String responseGraph = serviceOrderRepoService.getImageServiceOrderItemRelationshipGraph(soId, soi.getId()); + assertThat( responseGraph ).isNotNull(); + } + } + + + private String createServiceOrder() throws Exception { + + int currSize = serviceOrderRepoService.findAll().size(); + + File sspec = new File("src/test/resources/testServiceSpec.json"); + InputStream in = new FileInputStream(sspec); + String sspectext = IOUtils.toString(in, "UTF-8"); + + ServiceSpecificationCreate sspeccr = JsonUtils.toJsonObj(sspectext, ServiceSpecificationCreate.class); + sspeccr.setName("Spec1"); + ServiceSpecification responsesSpec = createServiceSpec( sspeccr); + + ServiceOrderCreate serviceOrder = new ServiceOrderCreate(); + serviceOrder.setCategory("Test Category"); + serviceOrder.setDescription("A Test Service Order"); + serviceOrder.setRequestedStartDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + serviceOrder.setRequestedCompletionDate(OffsetDateTime.now(ZoneOffset.UTC).toString()); + + ServiceOrderItem soi = new ServiceOrderItem(); + serviceOrder.getOrderItem().add(soi); + soi.setState(ServiceOrderStateType.ACKNOWLEDGED); + + ServiceRestriction serviceRestriction = new ServiceRestriction(); + ServiceSpecificationRef aServiceSpecificationRef = new ServiceSpecificationRef(); + aServiceSpecificationRef.setId(responsesSpec.getId()); + aServiceSpecificationRef.setName(responsesSpec.getName()); + + serviceRestriction.setServiceSpecification(aServiceSpecificationRef); + serviceRestriction.setName("aServiceRestriction"); + soi.setService(serviceRestriction); + + String response = mvc + .perform(MockMvcRequestBuilders.post("/serviceOrdering/v4/serviceOrder") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(serviceOrder))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + + ServiceOrder responseSO = JsonUtils.toJsonObj(response, ServiceOrder.class); + + assertThat( serviceOrderRepoService.findAll().size() ).isEqualTo( currSize + 1 ); + assertThat(responseSO.getCategory()).isEqualTo("Test Category"); + assertThat(responseSO.getDescription()).isEqualTo("A Test Service Order"); + + return response; + + } + + + private ServiceSpecification createServiceSpec( ServiceSpecificationCreate serviceSpecificationCreate) throws Exception { + + String response = mvc + .perform(MockMvcRequestBuilders.post("/serviceCatalogManagement/v4/serviceSpecification") + .with( SecurityMockMvcRequestPostProcessors.csrf()) + .contentType(MediaType.APPLICATION_JSON).content(JsonUtils.toJson(serviceSpecificationCreate))) + .andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + ServiceSpecification responsesSpec = JsonUtils.toJsonObj(response, ServiceSpecification.class); + + return responsesSpec; + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..c5e308251e6bfdef4a532431393d966cc46d86fa --- /dev/null +++ b/src/test/java/org/etsi/osl/services/reposervices/scm633/ServiceSpecificationRepoServiceTest.java @@ -0,0 +1,528 @@ +/** + * @Author: Eduardo Santos + * @Date: 2024-05-30 12:52:02 + * @Last Modified by: Eduardo Santos + * @Last Modified time: 2024-05-31 13:30:14 + */ + +package org.etsi.osl.services.reposervices.scm633; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Set; + +import org.etsi.osl.model.nfv.NetworkServiceDescriptor; +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.Any; +import org.etsi.osl.tmf.rcm634.model.ResourceSpecification; +import org.etsi.osl.tmf.rcm634.reposervices.ResourceSpecificationRepoService; +import org.etsi.osl.tmf.scm633.api.ServiceSpecificationApiRouteBuilderNSD; +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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertNull; +import org.junit.runner.RunWith; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +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.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import jakarta.validation.Valid; + +@RunWith(SpringRunner.class) +@ActiveProfiles("testing") +@SpringBootTest(classes = OpenAPISpringBoot.class) +public class ServiceSpecificationRepoServiceTest { + + @Autowired + private ServiceSpecificationRepoService serviceSpecificationRepoService; + + @MockBean + private ServiceSpecificationApiRouteBuilderNSD serviceSpecificationApiRouteBuilderNSD; + + @Mock + private static ResourceSpecificationRepoService resourceSpecRepoService; + + private static NetworkServiceDescriptor nsd; + + private static ResourceSpecification resourceNSD; + + @BeforeClass + public static void setupBeforeClass() { + // Load NSD from JSON file to NetworkServiceDescriptor.class + try { + ObjectMapper mapper = new ObjectMapper(); + + nsd = mapper.readValue( + new File( + "src/test/resources/reposervices/scm633/nsd.json"), + NetworkServiceDescriptor.class); + + } catch (Exception ex) { + ex.printStackTrace(); + } + + // Assert that the NSD was properly loaded + assertNotNull(nsd); + + // Mock resourceNSD + resourceNSD = mock(ResourceSpecification.class); + resourceNSD.setName(nsd.getName()); + resourceNSD.setVersion(nsd.getVersion()); + resourceNSD.setDescription(nsd.getShortDescription()); + } + + @Before + public void setupBefore() { + when(serviceSpecificationApiRouteBuilderNSD.retrieveNSD(anyString())).thenReturn(nsd); + when(resourceSpecRepoService.addResourceSpec(any())).thenReturn(resourceNSD); + } + + + /** + * Tests that specFromNSDID returns a non-null result when retrieveNSD returns a non-null NetworkServiceDescriptor. + * + * 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 + public void testSpecFromNSDIDReturnsNonNullWhenRetrieveNSDReturnsNonNull() { + // Setup + String id = "testId"; + + NetworkServiceDescriptor mockNsd = mock(NetworkServiceDescriptor.class); + when(serviceSpecificationApiRouteBuilderNSD.retrieveNSD(id)).thenReturn(mockNsd); + + NetworkServiceDescriptor result = serviceSpecificationApiRouteBuilderNSD.retrieveNSD(id); + + // Assertion + assertNotNull("The result should not be null when NSD is not null", result); + } + + + /** + * Tests that retrieveNSD returns null when the method is mocked to return null. + * + * This test verifies that the method retrieveNSD correctly returns null when it is expected to. + */ + @Test + public void testRetrieveNSDReturnsNull() { + // When retrieveNSD return null + String id = "SomeId"; + when(serviceSpecificationApiRouteBuilderNSD.retrieveNSD(id)).thenReturn(null); + + // Act + NetworkServiceDescriptor result = serviceSpecificationApiRouteBuilderNSD.retrieveNSD(id); + + // Assert + assertNull(result); + } + + + /** + * Tests the basic properties of the ServiceSpecification. + * + * This test verifies that the ServiceSpecification object created from the NSD ID + * has the correct name, version, and description. It also checks that the correct number + * of ServiceSpecification objects are created. + */ + @Test + public void testServiceSpecificationBaseProperties() { + String testId = "validId"; + + // Invoke the SUT + List result = serviceSpecificationRepoService.specFromNSDID(testId); + + // Evaluate the obtained results + // Assert that two service specifications are created + assertEquals(1, result.size()); + + ServiceSpecification serviceSpec = result.get(0); + + // Assert that the name, version, and description are the correct ones + assertEquals("tutorial_ns@osm14", serviceSpec.getName()); + assertEquals("1.0", serviceSpec.getVersion()); + assertEquals("tutorial_ns", serviceSpec.getDescription()); + } + + + /** + * Tests the characteristics of the ServiceSpecification objects. + * + * This test verifies that the method specFromNSDID correctly creates a list of + * ServiceSpecification objects from a given NSD ID and that these objects have the expected + * characteristics. It checks that the list contains exactly one ServiceSpecification object and + * that this object has the expected characteristics, including the correct name, value, and alias + * for each characteristic. + */ + @Test + public void testServiceSpecificationCharacteristics() { + String testId = "validId"; + + // Invoke the SUT + List result = serviceSpecificationRepoService.specFromNSDID(testId); + + // Evaluate the obtained results + // Assert that two service specifications are created + assertEquals(1, result.size()); + + ServiceSpecification serviceSpec = result.get(0); + + // Evaluate each Service Specification Characteristic + // Get all Service Specification Characteristics + Set serviceSpecCharacteristics = serviceSpec.getServiceSpecCharacteristic(); + + // Cast Service Specification Characteristics Set to ArrayList + List serviceSpecCharacteristicsList = new ArrayList<>(serviceSpecCharacteristics); + + // Order Service Specification Characteristics list by characterists' name + Collections.sort(serviceSpecCharacteristicsList, Comparator.comparing(ServiceSpecCharacteristic::getName)); + + // Assert that the Service Specification Characterists are the ones desired + assertEquals(27, serviceSpec.getServiceSpecCharacteristic().size()); + + /********************* Assert Service Specification Characteristic APPLY_CONFIG *********************/ + + ServiceSpecCharacteristic serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(0); + @Valid Set serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + Any v = serviceSpecCharacteristicValues.iterator().next().getValue(); + String value = v.getValue(); + String alias = v.getAlias(); + + assertEquals("APPLY_CONFIG", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic ConfigStatus *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(1); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("ConfigStatus", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic ConstituentVnfrIps *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(2); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("ConstituentVnfrIps", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic DeploymentRequestID *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(3); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("DeploymentRequestID", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic InstanceId *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(4); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("InstanceId", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic MANOproviderID *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(5); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("MANOproviderID", serviceSpecCharacteristic.getName()); + assertEquals("1", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic MANOproviderName *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(6); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("MANOproviderName", serviceSpecCharacteristic.getName()); + assertEquals("osm14", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic MemberVNFIndex_vnf1 *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(7); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("MemberVNFIndex_vnf1", serviceSpecCharacteristic.getName()); + assertEquals("vnf1", value); + assertEquals("tutorial_vnf", alias); + + /********************* Assert Service Specification Characteristic MemberVNFIndex_vnf2 *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(8); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("MemberVNFIndex_vnf2", serviceSpecCharacteristic.getName()); + assertEquals("vnf2", value); + assertEquals("tutorial_vnf", alias); + + /********************* Assert Service Specification Characteristic NSDID *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(9); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("NSDID", serviceSpecCharacteristic.getName()); + assertEquals("4", value); + assertEquals("id", alias); + + /********************* Assert Service Specification Characteristic NSLCM *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(10); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("NSLCM", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic NSR *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(11); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("NSR", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic OSM_CONFIG *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(12); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("OSM_CONFIG", serviceSpecCharacteristic.getName()); + assertEquals("{\"nsdId\":\"9dc24900-e63e-4c0e-b686-ee2ef124c5c2\", \"vimAccountId\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\"}", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic OSM_NSDCATALOGID *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(13); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("OSM_NSDCATALOGID", serviceSpecCharacteristic.getName()); + assertEquals("9dc24900-e63e-4c0e-b686-ee2ef124c5c2", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic OnBoardDescriptorID *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(14); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("OnBoardDescriptorID", serviceSpecCharacteristic.getName()); + assertEquals("4", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic OnBoardDescriptorUUID *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(15); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("OnBoardDescriptorUUID", serviceSpecCharacteristic.getName()); + assertEquals("c271dcf1-d823-4458-99dc-7fd80ba93a06", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic OnBoardingStatus *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(16); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("OnBoardingStatus", serviceSpecCharacteristic.getName()); + assertEquals("ONBOARDED", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic OperationalStatus *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(17); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("OperationalStatus", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic PackageLocation *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(18); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("PackageLocation", serviceSpecCharacteristic.getName()); + assertEquals("http://10.255.28.246/osapi/packages/da63085b-12f9-48a7-b4bb-e7039b128bc3/tutorial_ns.tar.gz", value); + assertEquals("PackageLocation", alias); + + /********************* Assert Service Specification Characteristic PackagingFormat *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(19); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("PackagingFormat", serviceSpecCharacteristic.getName()); + assertEquals("OSMvTHIRTEEN", value); + assertEquals("PackagingFormat", alias); + + /********************* Assert Service Specification Characteristic Primitives *********************/ + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(20); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("PrimitivesList", serviceSpecCharacteristic.getName()); +// assertEquals("{\"vnfs\":[{\"config-primitive\":[{\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}],\"name\":\"run-touch-command\"}],\"id\":\"vnf1\",\"vdu-configs\":[{\"config-primitive\":[{\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}],\"name\":\"run-touch-command\"}],\"id\":\"vdu1\"},{\"config-primitive\":[{\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}],\"name\":\"run-touch-command\"}],\"id\":\"vdu2\"}]},{\"config-primitive\":[{\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}],\"name\":\"run-touch-command\"}],\"id\":\"vnf2\",\"vdu-configs\":[{\"config-primitive\":[{\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}],\"name\":\"run-touch-command\"}],\"id\":\"vdu1\"},{\"config-primitive\":[{\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}],\"name\":\"run-touch-command\"}],\"id\":\"vdu2\"}]}]}", value); + assertEquals("{\"vnfs\":[{\"config-primitive\":[{\"name\":\"run-touch-command\",\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}]}],\"id\":\"vnf1\",\"vdu-configs\":[{\"config-primitive\":[{\"name\":\"run-touch-command\",\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}]}],\"id\":\"vdu1\"},{\"config-primitive\":[{\"name\":\"run-touch-command\",\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}]}],\"id\":\"vdu2\"}]},{\"config-primitive\":[{\"name\":\"run-touch-command\",\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}]}],\"id\":\"vnf2\",\"vdu-configs\":[{\"config-primitive\":[{\"name\":\"run-touch-command\",\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}]}],\"id\":\"vdu1\"},{\"config-primitive\":[{\"name\":\"run-touch-command\",\"parameter\":[{\"name\":\"filename\",\"data-type\":\"STRING\"}]}],\"id\":\"vdu2\"}]}]}", value); + assertEquals("", alias); + + + /********************* Assert Service Specification Characteristic SSHKEY *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(21); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("SSHKEY", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic SSPEC_GRAPH_NOTATION *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(22); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("SSPEC_GRAPH_NOTATION", serviceSpecCharacteristic.getName()); + //assertEquals("blockdiag {default_textcolor = white;\r\ndefault_fontsize = 12;\r\n\r\n\"null\" -> \"7690ef08-e94f-4c9f-923d-e8a3ad125908\";\r\n\"7690ef08-e94f-4c9f-923d-e8a3ad125908\" [ label = \"tutorial_ns\", shape = roundedbox, color = \"#e28743\"]; \"null\" [ label = \"tutorial_ns@osm14\", color = \"#2596be\"]; }", value); + assertEquals("SSPEC_GRAPH_NOTATION", alias); + + /********************* Assert Service Specification Characteristic Status *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(23); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("Status", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic VNFINDEXREF_INFO_vnf1 *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(24); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("VNFINDEXREF_INFO_vnf1", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic VNFINDEXREF_INFO_vnf2 *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(25); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("VNFINDEXREF_INFO_vnf2", serviceSpecCharacteristic.getName()); + assertEquals("", value); + assertEquals("", alias); + + /********************* Assert Service Specification Characteristic Vendor *********************/ + + serviceSpecCharacteristic = serviceSpecCharacteristicsList.get(26); + serviceSpecCharacteristicValues = serviceSpecCharacteristic.getServiceSpecCharacteristicValue(); + v = serviceSpecCharacteristicValues.iterator().next().getValue(); + value = v.getValue(); + alias = v.getAlias(); + + assertEquals("Vendor", serviceSpecCharacteristic.getName()); + assertEquals(null, value); + assertEquals("Vendor", alias); + + } + +} diff --git a/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java b/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..255b054f7abdb1b13d889e96d21ec5f3dce897ea --- /dev/null +++ b/src/test/java/org/etsi/osl/services/service/ServiceRepoServiceTest.java @@ -0,0 +1,652 @@ +/** + * @Author: Eduardo Santos + * @Date: 2024-05-29 09:52:16 + * @Last Modified by: Eduardo Santos + * @Last Modified time: 2024-05-31 15:01:52 + */ +package org.etsi.osl.services.service; + +import java.io.File; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.etsi.osl.tmf.OpenAPISpringBoot; +import org.etsi.osl.tmf.common.model.service.Characteristic; +import org.etsi.osl.tmf.common.model.service.Note; +import org.etsi.osl.tmf.common.model.service.Place; +import org.etsi.osl.tmf.common.model.service.ResourceRef; +import org.etsi.osl.tmf.common.model.service.ServiceRef; +import org.etsi.osl.tmf.prm669.model.RelatedParty; +import org.etsi.osl.tmf.sim638.model.Service; +import org.etsi.osl.tmf.sim638.model.ServiceOrderRef; +import org.etsi.osl.tmf.sim638.model.ServiceUpdate; +import org.etsi.osl.tmf.sim638.repo.ServiceRepository; +import org.etsi.osl.tmf.sim638.service.ServiceRepoService; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.runner.RunWith; +import static org.mockito.ArgumentMatchers.anyString; +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.context.SpringBootTest; +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.ObjectMapper; + +@RunWith(SpringRunner.class) +@ActiveProfiles("testing") +@SpringBootTest(classes = OpenAPISpringBoot.class) +//@DataJpaTest +public class ServiceRepoServiceTest { + + @Mock + private ServiceRepository serviceRepository; + + @SpyBean + private ServiceRepoService serviceRepoService; + + private static Service initialService; + + private static ServiceUpdate servUpd; + + private static ObjectMapper objectMapper; + + @BeforeClass + public static void setupBeforeClass() { + } + + @Before + public void setupBefore() { + try { + objectMapper = new ObjectMapper(); + + initialService = objectMapper.readValue( + new File( + "src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/initial_service.json"), + Service.class + ); + + servUpd = objectMapper.readValue( + new File( + "src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/servUpd.json"), + ServiceUpdate.class + ); + + } catch (Exception ex) { + ex.printStackTrace(); + } + + assertNotNull(initialService); + + when(serviceRepoService.getServiceEager(anyString())).thenReturn(initialService); + } + + + /** + * Tests the updateService method when the service is not found. + * + * This test verifies that the method returns null when the service is not found + * in the repository. + */ + @Test + public void testUpdateServiceWhenServiceNotFound() { + // Setup the expectation + when(serviceRepoService.getServiceEager(anyString())).thenReturn(null); + + // Execute the method to be tested + Service result = serviceRepoService.updateService("910146b3-67e9-4d8f-8141-066c6ca7ab60", servUpd, false, null, null); + + // Assert the expected outcome + assertNull(result); + } + + + /** + * Tests the updateService method when the service is found. + * + * This test verifies that the method returns a non-null Service object when the + * service is found in the repository. + */ + @Test + public void testUpdateServiceWhenServiceFound() { + // Execute the method to be tested + Service result = serviceRepoService.updateService("910146b3-67e9-4d8f-8141-066c6ca7ab60", servUpd, false, null, null); + + // Assert the expected outcome + assertNotNull(result); + } + + + /** + * Tests that the getServiceEager method is called the correct number of times. + * + * This test verifies that the getServiceEager method is called twice during the + * execution of the updateService method. + */ + @Test + public void testVerifyGetServiceEagerIsCalled() { + // Execute the method to be tested + serviceRepoService.updateService("910146b3-67e9-4d8f-8141-066c6ca7ab60", servUpd, false, null, null); + serviceRepoService.getServiceEager("910146b3-67e9-4d8f-8141-066c6ca7ab60"); + + // Verify the expected outcome + verify(serviceRepoService, times(2)).getServiceEager(anyString()); + } + + + /** + * Tests the updateNSLCMCharacteristic method when the NSLCM value to update is null. + * + * This test verifies that if a service characteristic's name contains "NSLCM" and its value is updated to null, + * the characteristic value in the service is correctly updated. + */ + @Test + public void testUpdateNSLCMCharacteristicMethodWhenNSLCMValueToUpdateIsNull() { + Service service = initialService; + + // Mimic initial behaviour of the updateService method + updateServiceDetails(service, servUpd); + + if ( servUpd.getServiceCharacteristic()!=null ) { + + for (Characteristic n : servUpd.getServiceCharacteristic()) { + if ( service.getServiceCharacteristicByName( n.getName() )!= null ) { + Characteristic origChar = service.getServiceCharacteristicByName( n.getName() ); + if ( ( origChar !=null ) && ( origChar.getValue() !=null ) && ( origChar.getValue().getValue() !=null )) { + if ( !origChar.getValue().getValue().equals(n.getValue().getValue()) ) { + + // Check if the name contains "NSLCM" in any case + if (n.getName().toUpperCase().contains("NSLCM")) { + + // Set the value of NSLCM to null + n.getValue().setValue(null); + + serviceRepoService.updateNSLCMCharacteristic(service, n); + + assertEquals("[\"null\"]", service.getServiceCharacteristicByName(n.getName()).getValue().getValue()); + } + } + } + } + } + } + } + + + /** + * Tests the updateNSLCMCharacteristic method when the NSLCM value to update is not null and NSLCM does not already exist. + * + * This test verifies that if a service characteristic's name contains "NSLCM" and its value is updated to a non-null value, + * the characteristic value in the service is correctly updated when NSLCM does not already exist. + */ + @Test + public void testUpdateNSLCMCharacteristicMethodWhenNSLCMValueToUpdateIsNotNullAndNSLCMDoesntAlreadyExist() { + Service service = initialService; + + // Mimic initial behaviour of the updateService method + updateServiceDetails(service, servUpd); + + if ( servUpd.getServiceCharacteristic()!=null ) { + for (Characteristic n : servUpd.getServiceCharacteristic()) { + if ( service.getServiceCharacteristicByName( n.getName() )!= null ) { + Characteristic origChar = service.getServiceCharacteristicByName( n.getName() ); + if ( ( origChar !=null ) && ( origChar.getValue() !=null ) && ( origChar.getValue().getValue() !=null )) { + if ( !origChar.getValue().getValue().equals(n.getValue().getValue()) ) { + + // Check if the name contains "NSLCM" in any case + if (n.getName().toUpperCase().contains("NSLCM")) { + + service.getServiceCharacteristicByName(n.getName()).getValue().setValue(""); + + 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}\"]", + service.getServiceCharacteristicByName(n.getName()).getValue().getValue() + ); + } + } + } + } + } + } + } + + + /** + * Tests the updateNSLCMCharacteristic method when the NSLCM value to update is not null and NSLCM already exists. + * + * This test verifies that if a service characteristic's name contains "NSLCM" and its value is updated to a non-null value, + * the characteristic value in the service is correctly updated when NSLCM already exists. + */ + @Test + public void testUpdateNSLCMCharacteristicMethodWhenNSLCMValueToUpdateIsNotNullAndNSLCMAlreadyExists() { + Service service = initialService; + + // Mimic initial behaviour of the updateService method + updateServiceDetails(service, servUpd); + + if ( servUpd.getServiceCharacteristic()!=null ) { + for (Characteristic n : servUpd.getServiceCharacteristic()) { + if ( service.getServiceCharacteristicByName( n.getName() )!= null ) { + Characteristic origChar = service.getServiceCharacteristicByName( n.getName() ); + if ( ( origChar !=null ) && ( origChar.getValue() !=null ) && ( origChar.getValue().getValue() !=null )) { + if ( !origChar.getValue().getValue().equals(n.getValue().getValue()) ) { + + // 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\"]"); + + 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}\"]", + service.getServiceCharacteristicByName(n.getName()).getValue().getValue() + ); + } + } + } + } + } + } + } + + + /** + * Tests updating the service type. + * + * This test verifies that the service type is correctly updated in the service object. + */ + @Test + public void testUpdateService_Type() { + servUpd.setType("NewType"); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals("NewType", initialService.getType()); + } + + + /** + * Tests updating the service name. + * + * This test verifies that the service name is correctly updated in the service object. + */ + @Test + public void testUpdateService_Name() { + servUpd.setName("NewName"); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals("NewName", initialService.getName()); + } + + + /** + * Tests updating the service category. + * + * This test verifies that the service category is correctly updated in the service object. + */ + @Test + public void testUpdateService_Category() { + servUpd.setCategory("NewCategory"); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals("NewCategory", initialService.getCategory()); + } + + + /** + * Tests updating the service description. + * + * This test verifies that the service description is correctly updated in the service object. + */ + @Test + public void testUpdateService_Description() { + servUpd.setDescription("NewDescription"); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals("NewDescription", initialService.getDescription()); + } + + + /** + * Tests updating the service start date. + * + * This test verifies that the service start date is correctly updated in the service object. + */ + @Test + public void testUpdateService_StartDate() { + OffsetDateTime offsetDateTime = OffsetDateTime.now(); + servUpd.setStartDate(offsetDateTime); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals(offsetDateTime, initialService.getStartDate()); + } + + + /** + * Tests updating the service end date. + * + * This test verifies that the service end date is correctly updated in the service object. + */ + @Test + public void testUpdateService_EndDate() { + OffsetDateTime offsetDateTime = OffsetDateTime.now().plusDays(1); + servUpd.setEndDate(offsetDateTime); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals(offsetDateTime, initialService.getEndDate()); + } + + + /** + * Tests updating the hasStarted attribute of the service. + * + * This test verifies that the hasStarted attribute is correctly updated in the service object. + */ + @Test + public void testUpdateService_HasStarted() { + servUpd.setHasStarted(true); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertTrue(initialService.isHasStarted()); + } + + + /** + * Tests updating the isServiceEnabled attribute of the service. + * + * This test verifies that the isServiceEnabled attribute is correctly updated in the service object. + */ + @Test + public void testUpdateService_IsServiceEnabled() { + servUpd.setIsServiceEnabled(true); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertTrue(initialService.isIsServiceEnabled()); + } + + + /** + * Tests updating the isStateful attribute of the service. + * + * This test verifies that the isStateful attribute is correctly updated in the service object. + */ + @Test + public void testUpdateService_IsStateful() { + servUpd.setIsStateful(true); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertTrue(initialService.isIsStateful()); + } + + + /** + * Tests updating the service date. + * + * This test verifies that the service date is correctly updated in the service object. + */ + @Test + public void testUpdateService_ServiceDate() { + OffsetDateTime newServiceDate = OffsetDateTime.now(); + servUpd.setServiceDate(newServiceDate.toString()); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals(newServiceDate.toString(), initialService.getServiceDate()); + } + + + /** + * Tests updating the service type. + * + * This test verifies that the service type is correctly updated in the service object. + */ + @Test + public void testUpdateService_ServiceType() { + servUpd.setServiceType("NewServiceType"); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals("NewServiceType", initialService.getServiceType()); + } + + + /** + * Tests updating the start mode of the service. + * + * This test verifies that the start mode is correctly updated in the service object. + */ + @Test + public void testUpdateService_StartMode() { + servUpd.setStartMode("NewStartMode"); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals("NewStartMode", initialService.getStartMode()); + } + + + /** + * Tests adding notes to the service. + * + * This test verifies that notes with null UUIDs are added to the service, + * while notes with existing UUIDs are not. + */ + @Test + public void testUpdateService_AddNote() { + Note note1 = new Note(); + note1.setUuid(null); + Note note2 = new Note(); + note2.setUuid("existing-uuid"); + + List notes = new ArrayList<>(); + notes.add(note1); + notes.add(note2); + servUpd.setNote(notes); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertTrue(initialService.getNote().contains(note1)); + assertFalse(initialService.getNote().contains(note2)); + } + + + /** + * Tests adding places to the service. + * + * This test verifies that places with null UUIDs are added to the service, + * while places with existing UUIDs are not. + */ + @Test + public void testUpdateService_AddPlace() { + Place place1 = new Place(); + place1.setUuid(null); + Place place2 = new Place(); + place2.setUuid("existing-uuid"); + + List places = new ArrayList<>(); + places.add(place1); + places.add(place2); + servUpd.setPlace(places); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals(1, initialService.getPlace().size()); + assertTrue(initialService.getPlace().contains(place1)); + assertFalse(initialService.getPlace().contains(place2)); + } + + + /** + * Tests adding related parties to the service. + * + * This test verifies that related parties with null UUIDs are added to the service, + * while related parties with existing UUIDs are not. + */ + @Test + public void testUpdateService_AddRelatedParty() { + RelatedParty relatedParty1 = new RelatedParty(); + relatedParty1.setUuid(null); + RelatedParty relatedParty2 = new RelatedParty(); + relatedParty2.setUuid("existing-uuid"); + + List relatedParties = new ArrayList<>(); + relatedParties.add(relatedParty1); + relatedParties.add(relatedParty2); + servUpd.setRelatedParty(relatedParties); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals(1, initialService.getRelatedParty().size()); + assertTrue(initialService.getRelatedParty().contains(relatedParty1)); + assertFalse(initialService.getRelatedParty().contains(relatedParty2)); + } + + + /** + * Tests adding service orders to the service. + * + * This test verifies that service orders with null UUIDs are added to the service, + * while service orders with existing UUIDs are not. + */ + @Test + public void testUpdateService_AddServiceOrder() { + ServiceOrderRef order1 = new ServiceOrderRef(); + order1.setUuid(null); + ServiceOrderRef order2 = new ServiceOrderRef(); + order2.setUuid("existing-uuid"); + + List orders = new ArrayList<>(); + orders.add(order1); + orders.add(order2); + servUpd.setServiceOrder(orders); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertTrue(initialService.getServiceOrder().contains(order1)); + assertFalse(initialService.getServiceOrder().contains(order2)); + } + + + /** + * Tests adding service relationships to the service. + * + * This test verifies that service relationships with null UUIDs are added to the service, + * while service relationships with existing UUIDs are not. + */ + //@Test + //public void testUpdateService_AddServiceRelationship() { + // ServiceRelationship relationship1 = new ServiceRelationship(); + // relationship1.setUuid(null); + // ServiceRelationship relationship2 = new ServiceRelationship(); + // relationship2.setUuid("existing-uuid"); +// + // List relationships = new ArrayList<>(); + // relationships.add(relationship1); + // relationships.add(relationship2); + // servUpd.setServiceRelationship(relationships); +// + // serviceRepoService.updateService("test-id", servUpd, false, null, null); +// + // assertTrue(initialService.getServiceRelationship().contains(relationship1)); + // assertFalse(initialService.getServiceRelationship().contains(relationship2)); + //} + + + /** + * Tests adding supporting resources to the service. + * + * This test verifies that supporting resources with null UUIDs are added to the service, + * while supporting resources with existing UUIDs are not. + */ + @Test + public void testUpdateService_AddSupportingResource() { + ResourceRef resource1 = new ResourceRef(); + resource1.setUuid(null); + ResourceRef resource2 = new ResourceRef(); + resource2.setUuid("existing-uuid"); + + List resources = new ArrayList<>(); + resources.add(resource1); + resources.add(resource2); + servUpd.setSupportingResource(resources); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals(1, initialService.getSupportingResource().size()); + assertTrue(initialService.getSupportingResource().contains(resource1)); + assertFalse(initialService.getSupportingResource().contains(resource2)); + } + + + /** + * Tests adding supporting services to the service. + * + * This test verifies that supporting services with null UUIDs are added to the service, + * while supporting services with existing UUIDs are not. + */ + @Test + public void testUpdateService_AddSupportingService() { + ServiceRef serviceRef1 = new ServiceRef(); + serviceRef1.setUuid(null); + ServiceRef serviceRef2 = new ServiceRef(); + serviceRef2.setUuid("existing-uuid"); + + List serviceRefs = new ArrayList<>(); + serviceRefs.add(serviceRef1); + serviceRefs.add(serviceRef2); + servUpd.setSupportingService(serviceRefs); + + serviceRepoService.updateService("test-id", servUpd, false, null, null); + + assertEquals(1, initialService.getSupportingService().size()); + assertTrue(initialService.getSupportingService().contains(serviceRef1)); + assertFalse(initialService.getSupportingService().contains(serviceRef2)); + } + + /** + * Updates the details of the given service based on the non-null values of the provided service update object. + * + * @param service The service object to be updated. + * @param servUpd The service update object containing new values. + */ + public void updateServiceDetails(Service service, ServiceUpdate servUpd) { + if (servUpd.getType() != null) service.setType(servUpd.getType()); + if (servUpd.getName() != null) service.setName(servUpd.getName()); + if (servUpd.getCategory() != null) service.setCategory(servUpd.getCategory()); + if (servUpd.getDescription() != null) service.setDescription(servUpd.getDescription()); + if (servUpd.getStartDate() != null) service.setStartDate(servUpd.getStartDate()); + if (servUpd.getEndDate() != null) service.setEndDate(servUpd.getEndDate()); + if (servUpd.isHasStarted() != null) service.setHasStarted(servUpd.isHasStarted()); + if (servUpd.isIsServiceEnabled() != null) service.setIsServiceEnabled(servUpd.isIsServiceEnabled()); + if (servUpd.isIsStateful() != null) service.setIsStateful(servUpd.isIsStateful()); + if (servUpd.getServiceDate() != null) service.setServiceDate(servUpd.getServiceDate()); + if (servUpd.getServiceType() != null) service.setServiceType(servUpd.getServiceType()); + if (servUpd.getStartMode() != null) service.setStartMode(servUpd.getStartMode()); + if (servUpd.getState() != null) service.setState(servUpd.getState()); + if (servUpd.getServiceSpecificationRef() != null) service.setServiceSpecificationRef(servUpd.getServiceSpecificationRef()); + } + +} diff --git a/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/final_service.json b/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/final_service.json new file mode 100644 index 0000000000000000000000000000000000000000..f768212128cd0a4e0695a0fbc7271a6c30d7adb0 --- /dev/null +++ b/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/final_service.json @@ -0,0 +1 @@ +{"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":"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":"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":"11d93f65-8f9d-4eff-b93f-35bdcacdcfe8","date":"2024-05-29T10:44:26.353947147Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service Characteristic changed: NSLCM, NSR, OperationalStatus, VNFINDEXREF_INFO_1, ConfigStatus, Status, ConstituentVnfrIps, "},{"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":"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":"86471188-33e7-46bc-a895-7530d340cf2a","date":"2024-05-29T10:44:26.353725010Z","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"API","system":null,"text":"Service is active"},{"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":"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, "},{"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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"}],"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":"","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"ConstituentVnfrIps","valueType":"TEXT"},{"uuid":"89bd345e-d059-4747-919e-c3c4739b9b08","value":{"value":"[\"null\",\"{\\\"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}\"]","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\":\"Done\",\"nsd-ref\":\"tutorial_ns\",\"description\":\"\",\"operational-status\":\"running\",\"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\":\"IDLE\",\"deploymentStatus\":null,\"orchestration-progress\":{},\"errorDetail\":null,\"id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"resource-orchestrator\":\"osmopenmano\",\"nsd-id\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"currentOperationID\":null,\"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\":null,\"modified\":1.7169794444006174E9,\"nslcmop\":null,\"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\",\"config_sw_installed\":true,\"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\":null,\"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\":\"READY\"},{\"elementUnderConfiguration\":\"vdu1-0\",\"elementType\":\"VDU\",\"status\":\"READY\"},{\"elementUnderConfiguration\":\"vdu2-0\",\"elementType\":\"VDU\",\"status\":\"READY\"}],\"config-status\":\"configured\",\"name\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"nsState\":\"READY\",\"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":"running","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":"{\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\":{\"ip-address\":\"10.255.28.232\"},\"vnfd-ref\":\"tutorial_vnf\",\"vim-account-id\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"vnfd-id\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b\",\"nsr-id-ref\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"vca-id\":null,\"revision\":1,\"vld\":[{\"flavour\":[{\"id\":\"internal-vl-flavor\"}],\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vim_details\":\"{admin_state_up: true, availability_zone_hints: [], availability_zones: [nova], created_at: '2024-05-29T10:40:27Z', description: '', encapsulation: vxlan, encapsulation_id: 761, encapsulation_type: vxlan, id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, ipv4_address_scope: null,\\n ipv6_address_scope: null, mtu: 1450, name: Service_Order_65-internal-vl, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, 'provider:network_type': vxlan, 'provider:physical_network': null, 'provider:segmentation_id': 761, revision_number: 2,\\n 'router:external': false, segmentation_id: 761, shared: false, status: ACTIVE, subnets: [{subnet: {allocation_pools: [{end: 192.168.6.254, start: 192.168.6.1}], cidr: 192.168.6.0/24, created_at: '2024-05-29T10:40:28Z', description: '', dns_nameservers: [],\\n enable_dhcp: true, gateway_ip: null, host_routes: [], id: aa4f3222-b836-47db-aca8-6b52088ac4f1, ip_version: 4, ipv6_address_mode: null, ipv6_ra_mode: null, name: Service_Order_65-internal-vl-subnet, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, project_id: 810aa7702c3e450fb3189ed216787ae0,\\n revision_number: 0, service_types: [], subnetpool_id: null, tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:40:28Z'}}], tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, type: bridge, updated_at: '2024-05-29T10:40:28Z'}\\n\",\"vim_network_name\":null,\"vim_status\":\"ACTIVE\"}},\"id\":\"internal-vl\"}],\"additionalParamsForVnf\":null,\"ip-address\":\"10.255.28.232\",\"_admin\":{\"projects_write\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"created\":1.7169792184093206E9,\"modified\":1.7169792184093206E9,\"projects_read\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"nsState\":\"INSTANTIATED\"},\"member-vnf-index-ref\":\"1\",\"created-time\":1.7169792184089675E9,\"_id\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"id\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"vdur\":[{\"ssh-keys\":[\"\",\"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDOP8eWGdiUaeuElDX5Eup8GlnkejLKOPeCGxtmJCdGcMDrtDBnH1P4TQC6pIGEnbIOjYLxLKTc6N4+isl/NleLE/kn1W79JIA0lsLeXFsel+2NVMKyE2nczwP82GgVwoyJcb2fyvqPshP5REfk1n8GXqPjFGH4kov0HPQTrIhAa3AGBoSkvHeSiDLYxnx/ICtEy0odC57Mp2rNx9bATsmVXCbwVQd4TE6N3zZ4/LVSz3es0VWF8H9k+MiOI2gRPwa7rMv5aD65Jolh3fFl2XRLBFPDbr8NKIZgCprlpJcqnWuduEB6Jq1Dmn8YzRZlYRxlUy/mBPS5ougqj5WflnUfh5xN2dW5vMc3D9zcuP19aUDAB8UJgsgF2m0fArvknPn9+xyLvprbJCULl8TFTrA78ZOXSj6ACtGc3sHZzA27Eevy1b45YM5tOPxHdGT+YlPZWe+Sb+NwZJDAFaZzgd2wvLiuh/jqoVUld3U/4NBmLmnTidPkdgD1cR95vX22A5hWn3QAHvYx8+ZPPw2cphGvlGBXjTVJAfDpnObmaAs2OmR7Rn+aJCiRe6hEb9BoBeYqMKHOEctyeMNbwKBC9YiyG+hBLIMKJmnUjcpGUCBws0pmuEHmHpAgzyIkfsd/rQrPYDd3SbkS7QJUpOEfiwXGLvl/hrVUrMGXdWcM9B3KEQ== appuser@lcm-68fd4bb47d-wrb4f\\n\"],\"interfaces\":[{\"ns-vld-id\":\"mgmtnet_2\",\"mac-address\":\"fa:16:3e:cf:ee:2d\",\"ip-address\":\"10.255.28.232\",\"external-connection-point-ref\":\"vnf-vdu1-ext\",\"mgmt-interface\":true,\"vlan\":704,\"internal-connection-point-ref\":\"vdu1-int-out\",\"pci\":null,\"name\":\"vdu1-out\",\"mgmt-vnf\":true,\"type\":\"PARAVIRT\",\"compute_node\":\"jarvis-node2\"},{\"mac-address\":\"fa:16:3e:af:b4:f9\",\"ip-address\":\"192.168.6.252\",\"vlan\":null,\"internal-connection-point-ref\":\"vdu1-int-in\",\"vnf-vld-id\":\"internal-vl\",\"pci\":null,\"name\":\"vdu1-in\",\"type\":\"PARAVIRT\",\"compute_node\":\"jarvis-node2\"}],\"internal-connection-point\":[{\"name\":\"vdu1-int-out\",\"id\":\"vdu1-int-out\",\"connection-point-id\":\"vdu1-int-out\"},{\"name\":\"vdu1-int-in\",\"id\":\"vdu1-int-in\",\"connection-point-id\":\"vdu1-int-in\"}],\"additionalParams\":{\"OSM\":{\"vdu_id\":\"vdu1\",\"vnfd_id\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b\",\"vnf_id\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"ns_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"vdu\":{\"vdu2-0\":{\"vdu_id\":\"vdu2\",\"interfaces\":{\"vdu2-in\":{\"name\":\"vdu2-in\"},\"vdu2-out\":{\"name\":\"vdu2-out\"}},\"count_index\":0},\"vdu1-0\":{\"vdu_id\":\"vdu1\",\"interfaces\":{\"vdu1-out\":{\"name\":\"vdu1-out\"},\"vdu1-in\":{\"name\":\"vdu1-in\"}},\"count_index\":0}},\"count_index\":0,\"vim_account_id\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"member_vnf_index\":\"1\",\"vnfd_ref\":\"tutorial_vnf\"}},\"ns-flavor-id\":\"0\",\"virtual-storages\":[{\"size-of-storage\":\"10\",\"id\":\"vdu1-storage\"}],\"ip-address\":\"10.255.28.232\",\"ssh-access-required\":true,\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"interfaces\":[{\"mgmt_vnf_interface\":true,\"mgmt_vdu_interface\":true,\"vim_net_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:29Z', description: '', device_id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 10.255.28.232, subnet_id: f8851549-8399-4bdd-b86b-f7c4798cd9cd}], id: e3caf306-c383-4916-ab37-d92ea6a4090f,\\n mac_address: 'fa:16:3e:cf:ee:2d', name: vdu1-out, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:02Z'}\\n\",\"mac_address\":\"fa:16:3e:cf:ee:2d\",\"pci\":null,\"ip_address\":\"10.255.28.232\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"e3caf306-c383-4916-ab37-d92ea6a4090f\"},{\"vim_net_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:29Z', description: '', device_id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.6.252, subnet_id: aa4f3222-b836-47db-aca8-6b52088ac4f1}], id: d3604395-bdc1-4a36-80b9-6487695e7efb,\\n mac_address: 'fa:16:3e:af:b4:f9', name: vdu1-in, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:03Z'}\\n\",\"mac_address\":\"fa:16:3e:af:b4:f9\",\"pci\":null,\"ip_address\":\"192.168.6.252\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"d3604395-bdc1-4a36-80b9-6487695e7efb\"}],\"vim_message\":null,\"vim_id\":\"165d3c56-cf0e-4cfb-b53d-137a2763b258\",\"vim_name\":\"Service_Order_65-1-vdu1-0\",\"vim_details\":\"{'OS-DCF:diskConfig': MANUAL, 'OS-EXT-AZ:availability_zone': nova, 'OS-EXT-SRV-ATTR:host': jarvis-node2, 'OS-EXT-SRV-ATTR:hostname': service-order-65-1-vdu1-0, 'OS-EXT-SRV-ATTR:hypervisor_hostname': jarvis-node2, 'OS-EXT-SRV-ATTR:instance_name': instance-00001484,\\n 'OS-EXT-SRV-ATTR:kernel_id': '', 'OS-EXT-SRV-ATTR:launch_index': 0, 'OS-EXT-SRV-ATTR:ramdisk_id': '', 'OS-EXT-SRV-ATTR:reservation_id': r-ilrzja8f, 'OS-EXT-SRV-ATTR:root_device_name': /dev/vda, 'OS-EXT-STS:power_state': 1, 'OS-EXT-STS:task_state': null, 'OS-EXT-STS:vm_state': active,\\n 'OS-SRV-USG:launched_at': '2024-05-29T10:41:04.000000', 'OS-SRV-USG:terminated_at': null, accessIPv4: '', accessIPv6: '', addresses: {Service_Order_65-internal-vl: [{'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:af:b4:f9', 'OS-EXT-IPS:type': fixed, addr: 192.168.6.252,\\n version: 4}], new_5gasp: [{'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:cf:ee:2d', 'OS-EXT-IPS:type': fixed, addr: 10.255.28.232, version: 4}]}, config_drive: '', created: '2024-05-29T10:40:31Z', description: null, flavor: {disk: 10, ephemeral: 0, extra_specs: {},\\n id: b19b9b85-726a-4ee8-bdff-1768803aea5d, original_name: tunnel-as-a-service-sd-flv, ram: 1024, swap: 0, vcpus: 1}, hostId: ebb65622a6292c22fc116591712a658f3bb5037f33813f7f48d8d200, host_status: UP, id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, image: {id: c5af64b3-9505-4c27-a286-67da2b400ac8,\\n links: [{href: 'http://jarvis-controller:8774/images/c5af64b3-9505-4c27-a286-67da2b400ac8', rel: bookmark}]}, key_name: null, links: [{href: 'http://jarvis-controller:8774/v2.1/servers/165d3c56-cf0e-4cfb-b53d-137a2763b258', rel: self}, {href: 'http://jarvis-controller:8774/servers/165d3c56-cf0e-4cfb-b53d-137a2763b258',\\n rel: bookmark}], locked: false, metadata: {}, name: Service_Order_65-1-vdu1-0, 'os-extended-volumes:volumes_attached': [], progress: 0, security_groups: [{name: all_open}, {name: all_open}], status: ACTIVE, tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0,\\n updated: '2024-05-29T10:41:04Z', user_id: 5fe87522ac7039f5ef285f3642bbeb08af77eb40ad81798bc726db591ec79978}\\n\",\"interfaces_backup\":[{\"mgmt_vnf_interface\":true,\"mgmt_vdu_interface\":true,\"vim_net_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:29Z', description: '', device_id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 10.255.28.232, subnet_id: f8851549-8399-4bdd-b86b-f7c4798cd9cd}], id: e3caf306-c383-4916-ab37-d92ea6a4090f,\\n mac_address: 'fa:16:3e:cf:ee:2d', name: vdu1-out, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:02Z'}\\n\",\"mac_address\":\"fa:16:3e:cf:ee:2d\",\"pci\":null,\"ip_address\":\"10.255.28.232\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"e3caf306-c383-4916-ab37-d92ea6a4090f\"},{\"vim_net_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:29Z', description: '', device_id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.6.252, subnet_id: aa4f3222-b836-47db-aca8-6b52088ac4f1}], id: d3604395-bdc1-4a36-80b9-6487695e7efb,\\n mac_address: 'fa:16:3e:af:b4:f9', name: vdu1-in, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:03Z'}\\n\",\"mac_address\":\"fa:16:3e:af:b4:f9\",\"pci\":null,\"ip_address\":\"192.168.6.252\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"d3604395-bdc1-4a36-80b9-6487695e7efb\"}],\"vim_status\":\"ACTIVE\"}},\"name\":\"Service_Order_65-1-vdu1-0\",\"cloud-init\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b:file:cloud-config.txt\",\"ns-image-id\":\"0\",\"_id\":\"ebf2bc8a-c2e3-41b6-ac73-d4e279e1e3e4\",\"id\":\"ebf2bc8a-c2e3-41b6-ac73-d4e279e1e3e4\",\"vim-id\":\"165d3c56-cf0e-4cfb-b53d-137a2763b258\",\"vdu-id-ref\":\"vdu1\",\"count-index\":0,\"affinity-or-anti-affinity-group-id\":[],\"vdu-name\":\"vdu1\",\"status\":\"ACTIVE\"},{\"ssh-keys\":[\"\",\"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDOP8eWGdiUaeuElDX5Eup8GlnkejLKOPeCGxtmJCdGcMDrtDBnH1P4TQC6pIGEnbIOjYLxLKTc6N4+isl/NleLE/kn1W79JIA0lsLeXFsel+2NVMKyE2nczwP82GgVwoyJcb2fyvqPshP5REfk1n8GXqPjFGH4kov0HPQTrIhAa3AGBoSkvHeSiDLYxnx/ICtEy0odC57Mp2rNx9bATsmVXCbwVQd4TE6N3zZ4/LVSz3es0VWF8H9k+MiOI2gRPwa7rMv5aD65Jolh3fFl2XRLBFPDbr8NKIZgCprlpJcqnWuduEB6Jq1Dmn8YzRZlYRxlUy/mBPS5ougqj5WflnUfh5xN2dW5vMc3D9zcuP19aUDAB8UJgsgF2m0fArvknPn9+xyLvprbJCULl8TFTrA78ZOXSj6ACtGc3sHZzA27Eevy1b45YM5tOPxHdGT+YlPZWe+Sb+NwZJDAFaZzgd2wvLiuh/jqoVUld3U/4NBmLmnTidPkdgD1cR95vX22A5hWn3QAHvYx8+ZPPw2cphGvlGBXjTVJAfDpnObmaAs2OmR7Rn+aJCiRe6hEb9BoBeYqMKHOEctyeMNbwKBC9YiyG+hBLIMKJmnUjcpGUCBws0pmuEHmHpAgzyIkfsd/rQrPYDd3SbkS7QJUpOEfiwXGLvl/hrVUrMGXdWcM9B3KEQ== appuser@lcm-68fd4bb47d-wrb4f\\n\"],\"interfaces\":[{\"ns-vld-id\":\"mgmtnet_2\",\"mac-address\":\"fa:16:3e:d6:7b:f1\",\"ip-address\":\"10.255.28.243\",\"external-connection-point-ref\":\"vnf-vdu2-ext\",\"vlan\":704,\"internal-connection-point-ref\":\"vdu2-int-out\",\"pci\":null,\"name\":\"vdu2-out\",\"type\":\"PARAVIRT\",\"compute_node\":\"jarvis-node2\"},{\"mac-address\":\"fa:16:3e:41:22:24\",\"ip-address\":\"192.168.6.212\",\"vlan\":null,\"internal-connection-point-ref\":\"vdu2-int-in\",\"vnf-vld-id\":\"internal-vl\",\"pci\":null,\"name\":\"vdu2-in\",\"type\":\"PARAVIRT\",\"compute_node\":\"jarvis-node2\"}],\"internal-connection-point\":[{\"name\":\"vdu2-int-out\",\"id\":\"vdu2-int-out\",\"connection-point-id\":\"vdu2-int-out\"},{\"name\":\"vdu2-int-in\",\"id\":\"vdu2-int-in\",\"connection-point-id\":\"vdu2-int-in\"}],\"additionalParams\":{\"OSM\":{\"vdu_id\":\"vdu2\",\"vnfd_id\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b\",\"vnf_id\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"ns_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"vdu\":{\"vdu2-0\":{\"vdu_id\":\"vdu2\",\"interfaces\":{\"vdu2-in\":{\"name\":\"vdu2-in\"},\"vdu2-out\":{\"name\":\"vdu2-out\"}},\"count_index\":0},\"vdu1-0\":{\"vdu_id\":\"vdu1\",\"interfaces\":{\"vdu1-out\":{\"name\":\"vdu1-out\"},\"vdu1-in\":{\"name\":\"vdu1-in\"}},\"count_index\":0}},\"count_index\":0,\"vim_account_id\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"member_vnf_index\":\"1\",\"vnfd_ref\":\"tutorial_vnf\"}},\"ns-flavor-id\":\"1\",\"virtual-storages\":[{\"size-of-storage\":\"10\",\"id\":\"vdu2-storage\"}],\"ip-address\":\"10.255.28.243\",\"ssh-access-required\":true,\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"interfaces\":[{\"mgmt_vdu_interface\":true,\"vim_net_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:32Z', description: '', device_id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 10.255.28.243, subnet_id: f8851549-8399-4bdd-b86b-f7c4798cd9cd}], id: c2157c40-a481-48ca-9f3a-650a88f3a091,\\n mac_address: 'fa:16:3e:d6:7b:f1', name: vdu2-out, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:04Z'}\\n\",\"mac_address\":\"fa:16:3e:d6:7b:f1\",\"pci\":null,\"ip_address\":\"10.255.28.243\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"c2157c40-a481-48ca-9f3a-650a88f3a091\"},{\"vim_net_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:33Z', description: '', device_id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.6.212, subnet_id: aa4f3222-b836-47db-aca8-6b52088ac4f1}], id: 2165131f-b8ac-49b8-8492-3e6bf8e24da3,\\n mac_address: 'fa:16:3e:41:22:24', name: vdu2-in, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:05Z'}\\n\",\"mac_address\":\"fa:16:3e:41:22:24\",\"pci\":null,\"ip_address\":\"192.168.6.212\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"2165131f-b8ac-49b8-8492-3e6bf8e24da3\"}],\"vim_message\":null,\"vim_id\":\"99e24cc0-2210-4af3-ab60-071ef6d5c07f\",\"vim_name\":\"Service_Order_65-1-vdu2-0\",\"vim_details\":\"{'OS-DCF:diskConfig': MANUAL, 'OS-EXT-AZ:availability_zone': nova, 'OS-EXT-SRV-ATTR:host': jarvis-node2, 'OS-EXT-SRV-ATTR:hostname': service-order-65-1-vdu2-0, 'OS-EXT-SRV-ATTR:hypervisor_hostname': jarvis-node2, 'OS-EXT-SRV-ATTR:instance_name': instance-00001485,\\n 'OS-EXT-SRV-ATTR:kernel_id': '', 'OS-EXT-SRV-ATTR:launch_index': 0, 'OS-EXT-SRV-ATTR:ramdisk_id': '', 'OS-EXT-SRV-ATTR:reservation_id': r-g2b06h3q, 'OS-EXT-SRV-ATTR:root_device_name': /dev/vda, 'OS-EXT-STS:power_state': 1, 'OS-EXT-STS:task_state': null, 'OS-EXT-STS:vm_state': active,\\n 'OS-SRV-USG:launched_at': '2024-05-29T10:41:06.000000', 'OS-SRV-USG:terminated_at': null, accessIPv4: '', accessIPv6: '', addresses: {Service_Order_65-internal-vl: [{'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:41:22:24', 'OS-EXT-IPS:type': fixed, addr: 192.168.6.212,\\n version: 4}], new_5gasp: [{'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:d6:7b:f1', 'OS-EXT-IPS:type': fixed, addr: 10.255.28.243, version: 4}]}, config_drive: '', created: '2024-05-29T10:40:34Z', description: null, flavor: {disk: 10, ephemeral: 0, extra_specs: {},\\n id: b19b9b85-726a-4ee8-bdff-1768803aea5d, original_name: tunnel-as-a-service-sd-flv, ram: 1024, swap: 0, vcpus: 1}, hostId: ebb65622a6292c22fc116591712a658f3bb5037f33813f7f48d8d200, host_status: UP, id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, image: {id: c5af64b3-9505-4c27-a286-67da2b400ac8,\\n links: [{href: 'http://jarvis-controller:8774/images/c5af64b3-9505-4c27-a286-67da2b400ac8', rel: bookmark}]}, key_name: null, links: [{href: 'http://jarvis-controller:8774/v2.1/servers/99e24cc0-2210-4af3-ab60-071ef6d5c07f', rel: self}, {href: 'http://jarvis-controller:8774/servers/99e24cc0-2210-4af3-ab60-071ef6d5c07f',\\n rel: bookmark}], locked: false, metadata: {}, name: Service_Order_65-1-vdu2-0, 'os-extended-volumes:volumes_attached': [], progress: 0, security_groups: [{name: all_open}, {name: all_open}], status: ACTIVE, tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0,\\n updated: '2024-05-29T10:41:06Z', user_id: 5fe87522ac7039f5ef285f3642bbeb08af77eb40ad81798bc726db591ec79978}\\n\",\"interfaces_backup\":[{\"mgmt_vdu_interface\":true,\"vim_net_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:32Z', description: '', device_id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 10.255.28.243, subnet_id: f8851549-8399-4bdd-b86b-f7c4798cd9cd}], id: c2157c40-a481-48ca-9f3a-650a88f3a091,\\n mac_address: 'fa:16:3e:d6:7b:f1', name: vdu2-out, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:04Z'}\\n\",\"mac_address\":\"fa:16:3e:d6:7b:f1\",\"pci\":null,\"ip_address\":\"10.255.28.243\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"c2157c40-a481-48ca-9f3a-650a88f3a091\"},{\"vim_net_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:33Z', description: '', device_id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.6.212, subnet_id: aa4f3222-b836-47db-aca8-6b52088ac4f1}], id: 2165131f-b8ac-49b8-8492-3e6bf8e24da3,\\n mac_address: 'fa:16:3e:41:22:24', name: vdu2-in, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:05Z'}\\n\",\"mac_address\":\"fa:16:3e:41:22:24\",\"pci\":null,\"ip_address\":\"192.168.6.212\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"2165131f-b8ac-49b8-8492-3e6bf8e24da3\"}],\"vim_status\":\"ACTIVE\"}},\"name\":\"Service_Order_65-1-vdu2-0\",\"cloud-init\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b:file:cloud-config.txt\",\"ns-image-id\":\"0\",\"_id\":\"dc30efb3-e3df-4165-a89d-a0769a81d85e\",\"id\":\"dc30efb3-e3df-4165-a89d-a0769a81d85e\",\"vim-id\":\"99e24cc0-2210-4af3-ab60-071ef6d5c07f\",\"vdu-id-ref\":\"vdu2\",\"count-index\":0,\"affinity-or-anti-affinity-group-id\":[],\"vdu-name\":\"vdu2\",\"status\":\"ACTIVE\"}],\"connection-point\":[{\"name\":\"vnf-vdu1-ext\",\"id\":\"vnf-vdu1-ext\",\"connection-point-vdu-id\":\"vdu1\",\"connection-point-id\":\"vdu1-int-out\"},{\"name\":\"vnf-vdu2-ext\",\"id\":\"vnf-vdu2-ext\",\"connection-point-vdu-id\":\"vdu2\",\"connection-point-id\":\"vdu2-int-out\"}]}","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"VNFINDEXREF_INFO_1","valueType":"TEXT"},{"uuid":"08e48a23-c2b7-40b5-887f-e2a48cea72d4","value":{"value":"configured","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"ConfigStatus","valueType":"TEXT"},{"uuid":"37ad7be3-d9ff-463d-b4ee-b6a83a2d3a54","value":{"value":"RUNNING","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":"active","supportingResource":[],"supportingService":[]} \ No newline at end of file diff --git a/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/initial_service.json b/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/initial_service.json new file mode 100644 index 0000000000000000000000000000000000000000..eaf940892bbb3fcc1befe9fbd52bcfefe49e53ae --- /dev/null +++ b/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/initial_service.json @@ -0,0 +1 @@ +{"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 diff --git a/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/servUpd.json b/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/servUpd.json new file mode 100644 index 0000000000000000000000000000000000000000..e0e36dd4673d19f921882140985b1284df1f0efb --- /dev/null +++ b/src/test/resources/ServiceRepoServiceTestResources/104426_forTesting/servUpd.json @@ -0,0 +1 @@ +{"endDate":null,"startDate":null,"category":null,"description":null,"hasStarted":null,"isServiceEnabled":null,"isStateful":null,"name":null,"serviceDate":null,"serviceType":null,"startMode":null,"note":null,"place":null,"relatedParty":null,"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":"89bd345e-d059-4747-919e-c3c4739b9b08","value":{"value":"{\"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}","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\":\"Done\",\"nsd-ref\":\"tutorial_ns\",\"description\":\"\",\"operational-status\":\"running\",\"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\":\"IDLE\",\"deploymentStatus\":null,\"orchestration-progress\":{},\"errorDetail\":null,\"id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"resource-orchestrator\":\"osmopenmano\",\"nsd-id\":\"338d3a8c-af70-446a-af37-ed8bb97a6641\",\"currentOperationID\":null,\"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\":null,\"modified\":1.7169794444006174E9,\"nslcmop\":null,\"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\",\"config_sw_installed\":true,\"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\":null,\"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\":\"READY\"},{\"elementUnderConfiguration\":\"vdu1-0\",\"elementType\":\"VDU\",\"status\":\"READY\"},{\"elementUnderConfiguration\":\"vdu2-0\",\"elementType\":\"VDU\",\"status\":\"READY\"}],\"config-status\":\"configured\",\"name\":\"Service_Order_65bcf307-1a47-4a48-b211-be94c3390b81\",\"_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"nsState\":\"READY\",\"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":"running","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"OperationalStatus","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":"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":"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":"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":"58bc2253-0392-4543-8f28-14c1052feb2f","value":{"value":"2","alias":""},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"OnBoardDescriptorID","valueType":"TEXT"},{"uuid":"9ebc771d-2eb0-4bdb-a326-32f78a51cea2","value":{"value":"{\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\":{\"ip-address\":\"10.255.28.232\"},\"vnfd-ref\":\"tutorial_vnf\",\"vim-account-id\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"vnfd-id\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b\",\"nsr-id-ref\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"vca-id\":null,\"revision\":1,\"vld\":[{\"flavour\":[{\"id\":\"internal-vl-flavor\"}],\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"vim_message\":null,\"vim_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vim_details\":\"{admin_state_up: true, availability_zone_hints: [], availability_zones: [nova], created_at: '2024-05-29T10:40:27Z', description: '', encapsulation: vxlan, encapsulation_id: 761, encapsulation_type: vxlan, id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, ipv4_address_scope: null,\\n ipv6_address_scope: null, mtu: 1450, name: Service_Order_65-internal-vl, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, 'provider:network_type': vxlan, 'provider:physical_network': null, 'provider:segmentation_id': 761, revision_number: 2,\\n 'router:external': false, segmentation_id: 761, shared: false, status: ACTIVE, subnets: [{subnet: {allocation_pools: [{end: 192.168.6.254, start: 192.168.6.1}], cidr: 192.168.6.0/24, created_at: '2024-05-29T10:40:28Z', description: '', dns_nameservers: [],\\n enable_dhcp: true, gateway_ip: null, host_routes: [], id: aa4f3222-b836-47db-aca8-6b52088ac4f1, ip_version: 4, ipv6_address_mode: null, ipv6_ra_mode: null, name: Service_Order_65-internal-vl-subnet, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, project_id: 810aa7702c3e450fb3189ed216787ae0,\\n revision_number: 0, service_types: [], subnetpool_id: null, tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:40:28Z'}}], tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, type: bridge, updated_at: '2024-05-29T10:40:28Z'}\\n\",\"vim_network_name\":null,\"vim_status\":\"ACTIVE\"}},\"id\":\"internal-vl\"}],\"additionalParamsForVnf\":null,\"ip-address\":\"10.255.28.232\",\"_admin\":{\"projects_write\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"created\":1.7169792184093206E9,\"modified\":1.7169792184093206E9,\"projects_read\":[\"92636b50-d607-4801-98b5-f0da541363be\"],\"nsState\":\"INSTANTIATED\"},\"member-vnf-index-ref\":\"1\",\"created-time\":1.7169792184089675E9,\"_id\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"id\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"vdur\":[{\"ssh-keys\":[\"\",\"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDOP8eWGdiUaeuElDX5Eup8GlnkejLKOPeCGxtmJCdGcMDrtDBnH1P4TQC6pIGEnbIOjYLxLKTc6N4+isl/NleLE/kn1W79JIA0lsLeXFsel+2NVMKyE2nczwP82GgVwoyJcb2fyvqPshP5REfk1n8GXqPjFGH4kov0HPQTrIhAa3AGBoSkvHeSiDLYxnx/ICtEy0odC57Mp2rNx9bATsmVXCbwVQd4TE6N3zZ4/LVSz3es0VWF8H9k+MiOI2gRPwa7rMv5aD65Jolh3fFl2XRLBFPDbr8NKIZgCprlpJcqnWuduEB6Jq1Dmn8YzRZlYRxlUy/mBPS5ougqj5WflnUfh5xN2dW5vMc3D9zcuP19aUDAB8UJgsgF2m0fArvknPn9+xyLvprbJCULl8TFTrA78ZOXSj6ACtGc3sHZzA27Eevy1b45YM5tOPxHdGT+YlPZWe+Sb+NwZJDAFaZzgd2wvLiuh/jqoVUld3U/4NBmLmnTidPkdgD1cR95vX22A5hWn3QAHvYx8+ZPPw2cphGvlGBXjTVJAfDpnObmaAs2OmR7Rn+aJCiRe6hEb9BoBeYqMKHOEctyeMNbwKBC9YiyG+hBLIMKJmnUjcpGUCBws0pmuEHmHpAgzyIkfsd/rQrPYDd3SbkS7QJUpOEfiwXGLvl/hrVUrMGXdWcM9B3KEQ== appuser@lcm-68fd4bb47d-wrb4f\\n\"],\"interfaces\":[{\"ns-vld-id\":\"mgmtnet_2\",\"mac-address\":\"fa:16:3e:cf:ee:2d\",\"ip-address\":\"10.255.28.232\",\"external-connection-point-ref\":\"vnf-vdu1-ext\",\"mgmt-interface\":true,\"vlan\":704,\"internal-connection-point-ref\":\"vdu1-int-out\",\"pci\":null,\"name\":\"vdu1-out\",\"mgmt-vnf\":true,\"type\":\"PARAVIRT\",\"compute_node\":\"jarvis-node2\"},{\"mac-address\":\"fa:16:3e:af:b4:f9\",\"ip-address\":\"192.168.6.252\",\"vlan\":null,\"internal-connection-point-ref\":\"vdu1-int-in\",\"vnf-vld-id\":\"internal-vl\",\"pci\":null,\"name\":\"vdu1-in\",\"type\":\"PARAVIRT\",\"compute_node\":\"jarvis-node2\"}],\"internal-connection-point\":[{\"name\":\"vdu1-int-out\",\"id\":\"vdu1-int-out\",\"connection-point-id\":\"vdu1-int-out\"},{\"name\":\"vdu1-int-in\",\"id\":\"vdu1-int-in\",\"connection-point-id\":\"vdu1-int-in\"}],\"additionalParams\":{\"OSM\":{\"vdu_id\":\"vdu1\",\"vnfd_id\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b\",\"vnf_id\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"ns_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"vdu\":{\"vdu2-0\":{\"vdu_id\":\"vdu2\",\"interfaces\":{\"vdu2-in\":{\"name\":\"vdu2-in\"},\"vdu2-out\":{\"name\":\"vdu2-out\"}},\"count_index\":0},\"vdu1-0\":{\"vdu_id\":\"vdu1\",\"interfaces\":{\"vdu1-out\":{\"name\":\"vdu1-out\"},\"vdu1-in\":{\"name\":\"vdu1-in\"}},\"count_index\":0}},\"count_index\":0,\"vim_account_id\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"member_vnf_index\":\"1\",\"vnfd_ref\":\"tutorial_vnf\"}},\"ns-flavor-id\":\"0\",\"virtual-storages\":[{\"size-of-storage\":\"10\",\"id\":\"vdu1-storage\"}],\"ip-address\":\"10.255.28.232\",\"ssh-access-required\":true,\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"interfaces\":[{\"mgmt_vnf_interface\":true,\"mgmt_vdu_interface\":true,\"vim_net_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:29Z', description: '', device_id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 10.255.28.232, subnet_id: f8851549-8399-4bdd-b86b-f7c4798cd9cd}], id: e3caf306-c383-4916-ab37-d92ea6a4090f,\\n mac_address: 'fa:16:3e:cf:ee:2d', name: vdu1-out, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:02Z'}\\n\",\"mac_address\":\"fa:16:3e:cf:ee:2d\",\"pci\":null,\"ip_address\":\"10.255.28.232\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"e3caf306-c383-4916-ab37-d92ea6a4090f\"},{\"vim_net_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:29Z', description: '', device_id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.6.252, subnet_id: aa4f3222-b836-47db-aca8-6b52088ac4f1}], id: d3604395-bdc1-4a36-80b9-6487695e7efb,\\n mac_address: 'fa:16:3e:af:b4:f9', name: vdu1-in, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:03Z'}\\n\",\"mac_address\":\"fa:16:3e:af:b4:f9\",\"pci\":null,\"ip_address\":\"192.168.6.252\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"d3604395-bdc1-4a36-80b9-6487695e7efb\"}],\"vim_message\":null,\"vim_id\":\"165d3c56-cf0e-4cfb-b53d-137a2763b258\",\"vim_name\":\"Service_Order_65-1-vdu1-0\",\"vim_details\":\"{'OS-DCF:diskConfig': MANUAL, 'OS-EXT-AZ:availability_zone': nova, 'OS-EXT-SRV-ATTR:host': jarvis-node2, 'OS-EXT-SRV-ATTR:hostname': service-order-65-1-vdu1-0, 'OS-EXT-SRV-ATTR:hypervisor_hostname': jarvis-node2, 'OS-EXT-SRV-ATTR:instance_name': instance-00001484,\\n 'OS-EXT-SRV-ATTR:kernel_id': '', 'OS-EXT-SRV-ATTR:launch_index': 0, 'OS-EXT-SRV-ATTR:ramdisk_id': '', 'OS-EXT-SRV-ATTR:reservation_id': r-ilrzja8f, 'OS-EXT-SRV-ATTR:root_device_name': /dev/vda, 'OS-EXT-STS:power_state': 1, 'OS-EXT-STS:task_state': null, 'OS-EXT-STS:vm_state': active,\\n 'OS-SRV-USG:launched_at': '2024-05-29T10:41:04.000000', 'OS-SRV-USG:terminated_at': null, accessIPv4: '', accessIPv6: '', addresses: {Service_Order_65-internal-vl: [{'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:af:b4:f9', 'OS-EXT-IPS:type': fixed, addr: 192.168.6.252,\\n version: 4}], new_5gasp: [{'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:cf:ee:2d', 'OS-EXT-IPS:type': fixed, addr: 10.255.28.232, version: 4}]}, config_drive: '', created: '2024-05-29T10:40:31Z', description: null, flavor: {disk: 10, ephemeral: 0, extra_specs: {},\\n id: b19b9b85-726a-4ee8-bdff-1768803aea5d, original_name: tunnel-as-a-service-sd-flv, ram: 1024, swap: 0, vcpus: 1}, hostId: ebb65622a6292c22fc116591712a658f3bb5037f33813f7f48d8d200, host_status: UP, id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, image: {id: c5af64b3-9505-4c27-a286-67da2b400ac8,\\n links: [{href: 'http://jarvis-controller:8774/images/c5af64b3-9505-4c27-a286-67da2b400ac8', rel: bookmark}]}, key_name: null, links: [{href: 'http://jarvis-controller:8774/v2.1/servers/165d3c56-cf0e-4cfb-b53d-137a2763b258', rel: self}, {href: 'http://jarvis-controller:8774/servers/165d3c56-cf0e-4cfb-b53d-137a2763b258',\\n rel: bookmark}], locked: false, metadata: {}, name: Service_Order_65-1-vdu1-0, 'os-extended-volumes:volumes_attached': [], progress: 0, security_groups: [{name: all_open}, {name: all_open}], status: ACTIVE, tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0,\\n updated: '2024-05-29T10:41:04Z', user_id: 5fe87522ac7039f5ef285f3642bbeb08af77eb40ad81798bc726db591ec79978}\\n\",\"interfaces_backup\":[{\"mgmt_vnf_interface\":true,\"mgmt_vdu_interface\":true,\"vim_net_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:29Z', description: '', device_id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 10.255.28.232, subnet_id: f8851549-8399-4bdd-b86b-f7c4798cd9cd}], id: e3caf306-c383-4916-ab37-d92ea6a4090f,\\n mac_address: 'fa:16:3e:cf:ee:2d', name: vdu1-out, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:02Z'}\\n\",\"mac_address\":\"fa:16:3e:cf:ee:2d\",\"pci\":null,\"ip_address\":\"10.255.28.232\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"e3caf306-c383-4916-ab37-d92ea6a4090f\"},{\"vim_net_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:29Z', description: '', device_id: 165d3c56-cf0e-4cfb-b53d-137a2763b258, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.6.252, subnet_id: aa4f3222-b836-47db-aca8-6b52088ac4f1}], id: d3604395-bdc1-4a36-80b9-6487695e7efb,\\n mac_address: 'fa:16:3e:af:b4:f9', name: vdu1-in, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:03Z'}\\n\",\"mac_address\":\"fa:16:3e:af:b4:f9\",\"pci\":null,\"ip_address\":\"192.168.6.252\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"d3604395-bdc1-4a36-80b9-6487695e7efb\"}],\"vim_status\":\"ACTIVE\"}},\"name\":\"Service_Order_65-1-vdu1-0\",\"cloud-init\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b:file:cloud-config.txt\",\"ns-image-id\":\"0\",\"_id\":\"ebf2bc8a-c2e3-41b6-ac73-d4e279e1e3e4\",\"id\":\"ebf2bc8a-c2e3-41b6-ac73-d4e279e1e3e4\",\"vim-id\":\"165d3c56-cf0e-4cfb-b53d-137a2763b258\",\"vdu-id-ref\":\"vdu1\",\"count-index\":0,\"affinity-or-anti-affinity-group-id\":[],\"vdu-name\":\"vdu1\",\"status\":\"ACTIVE\"},{\"ssh-keys\":[\"\",\"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDOP8eWGdiUaeuElDX5Eup8GlnkejLKOPeCGxtmJCdGcMDrtDBnH1P4TQC6pIGEnbIOjYLxLKTc6N4+isl/NleLE/kn1W79JIA0lsLeXFsel+2NVMKyE2nczwP82GgVwoyJcb2fyvqPshP5REfk1n8GXqPjFGH4kov0HPQTrIhAa3AGBoSkvHeSiDLYxnx/ICtEy0odC57Mp2rNx9bATsmVXCbwVQd4TE6N3zZ4/LVSz3es0VWF8H9k+MiOI2gRPwa7rMv5aD65Jolh3fFl2XRLBFPDbr8NKIZgCprlpJcqnWuduEB6Jq1Dmn8YzRZlYRxlUy/mBPS5ougqj5WflnUfh5xN2dW5vMc3D9zcuP19aUDAB8UJgsgF2m0fArvknPn9+xyLvprbJCULl8TFTrA78ZOXSj6ACtGc3sHZzA27Eevy1b45YM5tOPxHdGT+YlPZWe+Sb+NwZJDAFaZzgd2wvLiuh/jqoVUld3U/4NBmLmnTidPkdgD1cR95vX22A5hWn3QAHvYx8+ZPPw2cphGvlGBXjTVJAfDpnObmaAs2OmR7Rn+aJCiRe6hEb9BoBeYqMKHOEctyeMNbwKBC9YiyG+hBLIMKJmnUjcpGUCBws0pmuEHmHpAgzyIkfsd/rQrPYDd3SbkS7QJUpOEfiwXGLvl/hrVUrMGXdWcM9B3KEQ== appuser@lcm-68fd4bb47d-wrb4f\\n\"],\"interfaces\":[{\"ns-vld-id\":\"mgmtnet_2\",\"mac-address\":\"fa:16:3e:d6:7b:f1\",\"ip-address\":\"10.255.28.243\",\"external-connection-point-ref\":\"vnf-vdu2-ext\",\"vlan\":704,\"internal-connection-point-ref\":\"vdu2-int-out\",\"pci\":null,\"name\":\"vdu2-out\",\"type\":\"PARAVIRT\",\"compute_node\":\"jarvis-node2\"},{\"mac-address\":\"fa:16:3e:41:22:24\",\"ip-address\":\"192.168.6.212\",\"vlan\":null,\"internal-connection-point-ref\":\"vdu2-int-in\",\"vnf-vld-id\":\"internal-vl\",\"pci\":null,\"name\":\"vdu2-in\",\"type\":\"PARAVIRT\",\"compute_node\":\"jarvis-node2\"}],\"internal-connection-point\":[{\"name\":\"vdu2-int-out\",\"id\":\"vdu2-int-out\",\"connection-point-id\":\"vdu2-int-out\"},{\"name\":\"vdu2-int-in\",\"id\":\"vdu2-int-in\",\"connection-point-id\":\"vdu2-int-in\"}],\"additionalParams\":{\"OSM\":{\"vdu_id\":\"vdu2\",\"vnfd_id\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b\",\"vnf_id\":\"1da45dc4-6e45-4eb7-a2ed-7a91e64dcea1\",\"ns_id\":\"420fa806-f2f8-405e-8348-11e4fcd13f25\",\"vdu\":{\"vdu2-0\":{\"vdu_id\":\"vdu2\",\"interfaces\":{\"vdu2-in\":{\"name\":\"vdu2-in\"},\"vdu2-out\":{\"name\":\"vdu2-out\"}},\"count_index\":0},\"vdu1-0\":{\"vdu_id\":\"vdu1\",\"interfaces\":{\"vdu1-out\":{\"name\":\"vdu1-out\"},\"vdu1-in\":{\"name\":\"vdu1-in\"}},\"count_index\":0}},\"count_index\":0,\"vim_account_id\":\"479356bf-72ff-4dfd-8483-5c23f48dd0bc\",\"member_vnf_index\":\"1\",\"vnfd_ref\":\"tutorial_vnf\"}},\"ns-flavor-id\":\"1\",\"virtual-storages\":[{\"size-of-storage\":\"10\",\"id\":\"vdu2-storage\"}],\"ip-address\":\"10.255.28.243\",\"ssh-access-required\":true,\"vim_info\":{\"vim:479356bf-72ff-4dfd-8483-5c23f48dd0bc\":{\"interfaces\":[{\"mgmt_vdu_interface\":true,\"vim_net_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:32Z', description: '', device_id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 10.255.28.243, subnet_id: f8851549-8399-4bdd-b86b-f7c4798cd9cd}], id: c2157c40-a481-48ca-9f3a-650a88f3a091,\\n mac_address: 'fa:16:3e:d6:7b:f1', name: vdu2-out, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:04Z'}\\n\",\"mac_address\":\"fa:16:3e:d6:7b:f1\",\"pci\":null,\"ip_address\":\"10.255.28.243\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"c2157c40-a481-48ca-9f3a-650a88f3a091\"},{\"vim_net_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:33Z', description: '', device_id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.6.212, subnet_id: aa4f3222-b836-47db-aca8-6b52088ac4f1}], id: 2165131f-b8ac-49b8-8492-3e6bf8e24da3,\\n mac_address: 'fa:16:3e:41:22:24', name: vdu2-in, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:05Z'}\\n\",\"mac_address\":\"fa:16:3e:41:22:24\",\"pci\":null,\"ip_address\":\"192.168.6.212\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"2165131f-b8ac-49b8-8492-3e6bf8e24da3\"}],\"vim_message\":null,\"vim_id\":\"99e24cc0-2210-4af3-ab60-071ef6d5c07f\",\"vim_name\":\"Service_Order_65-1-vdu2-0\",\"vim_details\":\"{'OS-DCF:diskConfig': MANUAL, 'OS-EXT-AZ:availability_zone': nova, 'OS-EXT-SRV-ATTR:host': jarvis-node2, 'OS-EXT-SRV-ATTR:hostname': service-order-65-1-vdu2-0, 'OS-EXT-SRV-ATTR:hypervisor_hostname': jarvis-node2, 'OS-EXT-SRV-ATTR:instance_name': instance-00001485,\\n 'OS-EXT-SRV-ATTR:kernel_id': '', 'OS-EXT-SRV-ATTR:launch_index': 0, 'OS-EXT-SRV-ATTR:ramdisk_id': '', 'OS-EXT-SRV-ATTR:reservation_id': r-g2b06h3q, 'OS-EXT-SRV-ATTR:root_device_name': /dev/vda, 'OS-EXT-STS:power_state': 1, 'OS-EXT-STS:task_state': null, 'OS-EXT-STS:vm_state': active,\\n 'OS-SRV-USG:launched_at': '2024-05-29T10:41:06.000000', 'OS-SRV-USG:terminated_at': null, accessIPv4: '', accessIPv6: '', addresses: {Service_Order_65-internal-vl: [{'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:41:22:24', 'OS-EXT-IPS:type': fixed, addr: 192.168.6.212,\\n version: 4}], new_5gasp: [{'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:d6:7b:f1', 'OS-EXT-IPS:type': fixed, addr: 10.255.28.243, version: 4}]}, config_drive: '', created: '2024-05-29T10:40:34Z', description: null, flavor: {disk: 10, ephemeral: 0, extra_specs: {},\\n id: b19b9b85-726a-4ee8-bdff-1768803aea5d, original_name: tunnel-as-a-service-sd-flv, ram: 1024, swap: 0, vcpus: 1}, hostId: ebb65622a6292c22fc116591712a658f3bb5037f33813f7f48d8d200, host_status: UP, id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, image: {id: c5af64b3-9505-4c27-a286-67da2b400ac8,\\n links: [{href: 'http://jarvis-controller:8774/images/c5af64b3-9505-4c27-a286-67da2b400ac8', rel: bookmark}]}, key_name: null, links: [{href: 'http://jarvis-controller:8774/v2.1/servers/99e24cc0-2210-4af3-ab60-071ef6d5c07f', rel: self}, {href: 'http://jarvis-controller:8774/servers/99e24cc0-2210-4af3-ab60-071ef6d5c07f',\\n rel: bookmark}], locked: false, metadata: {}, name: Service_Order_65-1-vdu2-0, 'os-extended-volumes:volumes_attached': [], progress: 0, security_groups: [{name: all_open}, {name: all_open}], status: ACTIVE, tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0,\\n updated: '2024-05-29T10:41:06Z', user_id: 5fe87522ac7039f5ef285f3642bbeb08af77eb40ad81798bc726db591ec79978}\\n\",\"interfaces_backup\":[{\"mgmt_vdu_interface\":true,\"vim_net_id\":\"6314ca29-199c-47bc-b070-cd2fc6c3b23e\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:32Z', description: '', device_id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 10.255.28.243, subnet_id: f8851549-8399-4bdd-b86b-f7c4798cd9cd}], id: c2157c40-a481-48ca-9f3a-650a88f3a091,\\n mac_address: 'fa:16:3e:d6:7b:f1', name: vdu2-out, network_id: 6314ca29-199c-47bc-b070-cd2fc6c3b23e, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:04Z'}\\n\",\"mac_address\":\"fa:16:3e:d6:7b:f1\",\"pci\":null,\"ip_address\":\"10.255.28.243\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"c2157c40-a481-48ca-9f3a-650a88f3a091\"},{\"vim_net_id\":\"4cdb16a5-38b6-4500-bfac-b6b6ff2870ad\",\"vlan\":null,\"vim_info\":\"{admin_state_up: true, allowed_address_pairs: [], 'binding:host_id': jarvis-node2, 'binding:profile': {}, 'binding:vif_details': {bound_drivers: {'0': linuxbridge}, connectivity: l2, port_filter: true}, 'binding:vif_type': bridge, 'binding:vnic_type': normal,\\n created_at: '2024-05-29T10:40:33Z', description: '', device_id: 99e24cc0-2210-4af3-ab60-071ef6d5c07f, device_owner: 'compute:nova', extra_dhcp_opts: [], fixed_ips: [{ip_address: 192.168.6.212, subnet_id: aa4f3222-b836-47db-aca8-6b52088ac4f1}], id: 2165131f-b8ac-49b8-8492-3e6bf8e24da3,\\n mac_address: 'fa:16:3e:41:22:24', name: vdu2-in, network_id: 4cdb16a5-38b6-4500-bfac-b6b6ff2870ad, port_security_enabled: true, project_id: 810aa7702c3e450fb3189ed216787ae0, revision_number: 5, security_groups: [5e1eda52-019d-49a3-ae40-5a9b7ed4b6a9], status: ACTIVE,\\n tags: [], tenant_id: 810aa7702c3e450fb3189ed216787ae0, updated_at: '2024-05-29T10:41:05Z'}\\n\",\"mac_address\":\"fa:16:3e:41:22:24\",\"pci\":null,\"ip_address\":\"192.168.6.212\",\"compute_node\":\"jarvis-node2\",\"vim_interface_id\":\"2165131f-b8ac-49b8-8492-3e6bf8e24da3\"}],\"vim_status\":\"ACTIVE\"}},\"name\":\"Service_Order_65-1-vdu2-0\",\"cloud-init\":\"d37d8b98-668f-4d27-8e54-3a62d3cc052b:file:cloud-config.txt\",\"ns-image-id\":\"0\",\"_id\":\"dc30efb3-e3df-4165-a89d-a0769a81d85e\",\"id\":\"dc30efb3-e3df-4165-a89d-a0769a81d85e\",\"vim-id\":\"99e24cc0-2210-4af3-ab60-071ef6d5c07f\",\"vdu-id-ref\":\"vdu2\",\"count-index\":0,\"affinity-or-anti-affinity-group-id\":[],\"vdu-name\":\"vdu2\",\"status\":\"ACTIVE\"}],\"connection-point\":[{\"name\":\"vnf-vdu1-ext\",\"id\":\"vnf-vdu1-ext\",\"connection-point-vdu-id\":\"vdu1\",\"connection-point-id\":\"vdu1-int-out\"},{\"name\":\"vnf-vdu2-ext\",\"id\":\"vnf-vdu2-ext\",\"connection-point-vdu-id\":\"vdu2\",\"connection-point-id\":\"vdu2-int-out\"}]}","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"VNFINDEXREF_INFO_1","valueType":"TEXT"},{"uuid":"08e48a23-c2b7-40b5-887f-e2a48cea72d4","value":{"value":"configured","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"ConfigStatus","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":"37ad7be3-d9ff-463d-b4ee-b6a83a2d3a54","value":{"value":"RUNNING","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"},{"uuid":"7bec87f6-66ce-4bc2-a75b-64cf01b60306","value":{"value":"","alias":null},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"ConstituentVnfrIps","valueType":"TEXT"}],"serviceOrder":null,"serviceSpecification":null,"state":"active","supportingResource":null,"supportingService":null,"serviceRelationship":null,"@baseType":null,"@schemaLocation":null,"@type":null} \ No newline at end of file diff --git a/src/test/resources/TestServiceOrderDates.json b/src/test/resources/TestServiceOrderDates.json new file mode 100644 index 0000000000000000000000000000000000000000..8c17acc86c82f78985630a200bdf0fdc78a8ad31 --- /dev/null +++ b/src/test/resources/TestServiceOrderDates.json @@ -0,0 +1 @@ +{"uuid":"93b9928c-de35-4495-a157-1100f6e71c92","orderDate":"2019-12-13T13:27:56Z","completionDate":null,"expectedCompletionDate":null,"requestedCompletionDate":"2039-12-13T13:27:49Z","requestedStartDate":"2039-12-13T13:27:49Z","startDate":"2039-12-13T13:27:49Z","@baseType":"BaseRootEntity","@schemaLocation":null,"@type":"ServiceOrder","href":null,"id":"93b9928c-de35-4495-a157-1100f6e71c92","category":null,"description":null,"externalId":null,"notificationContact":null,"priority":null,"note":[{"uuid":"1aa5412c-20eb-4266-91cc-95e5a9e464a7","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"author":"admin","date":null,"system":null,"text":"Note"}],"orderItem":[{"uuid":"5b08f277-c776-43c8-9834-8791de4124e6","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"id":"5b08f277-c776-43c8-9834-8791de4124e6","action":"add","orderItemRelationship":[],"state":"INITIAL","service":{"uuid":"cc344ee1-271b-4614-92f4-5f9d16524edc","serviceSpecification":{"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":null,"version":null,"targetServiceSchema":null,"@referredType":null,"id":"ce3afc23-1422-49e3-8475-f8965548f90b"},"@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":null,"id":"cc344ee1-271b-4614-92f4-5f9d16524edc","category":null,"serviceType":null,"place":[],"relatedParty":[],"serviceCharacteristic":[{"uuid":"13f444e5-72ab-41d0-a651-8c51f72319cf","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"5G-VINNI Service Type","valueType":"SET","value":{"value":"[{\"value\":\"1\",\"alias\":\"eMBB\"},{\"value\":\"3\",\"alias\":\"mIoT\"}]","alias":null}},{"uuid":"dc42c2a9-6957-4ddf-ae5b-23beec743725","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"Delivery Time","valueType":"TIMESTAMP","value":{"value":"2020-01-01T18:11:47Z","alias":"TimeStamp"}},{"uuid":"d59efa76-4dca-4fac-b6fc-28426b337d07","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"Sticker Text","valueType":"TEXT","value":{"value":"lorem ipsum dolor","alias":"FreeText"}},{"uuid":"3cba2460-7584-439b-a129-70b7cf9e6606","@baseType":"BaseEntity","@schemaLocation":null,"@type":null,"href":null,"name":"Color","valueType":"ENUM","value":{"value":"3","alias":"Black"}}],"state":"feasibilityChecked","supportingResource":[],"serviceRelationship":[],"supportingService":[]},"appointment":null}],"orderRelationship":[],"relatedParty":[{"uuid":"aa9da197-fc7d-4bd4-8eb3-a3a3297537ce","@baseType":"BaseRootEntity","@schemaLocation":null,"@type":"org.etsi.osl.tmf.prm669.model.RelatedParty","href":null,"name":"anonymousUser","role":"REQUESTER","@referredType":"SimpleUsername_Individual","id":"aa9da197-fc7d-4bd4-8eb3-a3a3297537ce"}],"state":"INPROGRESS"} \ No newline at end of file diff --git a/src/test/resources/cirros_vnf.tar.gz b/src/test/resources/cirros_vnf.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..10e4a9142416b497ecfd8a9c0862e5cea2d6ae56 Binary files /dev/null and b/src/test/resources/cirros_vnf.tar.gz differ diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 0000000000000000000000000000000000000000..5ddaf25da6ab1fb5ca6bdf00f5349e41fbec630a --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,32 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + diff --git a/src/test/resources/reposervices/scm633/nsd.json b/src/test/resources/reposervices/scm633/nsd.json new file mode 100644 index 0000000000000000000000000000000000000000..bf9085b36957fee8120e8d0c56c316ebe136269d --- /dev/null +++ b/src/test/resources/reposervices/scm633/nsd.json @@ -0,0 +1 @@ +{"id":4,"owner":{"id":2,"organization":null,"firstname":null,"lastname":null,"email":null,"username":"admin","createdAt":null},"uuid":"da63085b-12f9-48a7-b4bb-e7039b128bc3","name":"tutorial_ns","iconsrc":null,"shortDescription":"tutorial_ns","longDescription":"tutorial_ns","version":"1.0","packageLocation":"http://10.255.28.246/osapi/packages/da63085b-12f9-48a7-b4bb-e7039b128bc3/tutorial_ns.tar.gz","dateCreated":1717002820596,"dateUpdated":1717002820596,"categories":null,"extensions":null,"validationJobs":null,"screenshots":null,"vendor":null,"published":false,"termsOfUse":null,"descriptor":"nsd:\n nsd:\n - description: Simple NS with one VNF and a single Virtual Link\n df:\n - id: default-df\n vnf-profile:\n - id: \"vnf1\"\n virtual-link-connectivity:\n - constituent-cpd-id:\n - constituent-base-element-id: \"1\"\n constituent-cpd-id: vnf-vdu1-ext # this must be equal to the vdu's ext-cpd's id \n virtual-link-profile-id: mgmtnet_2\n - constituent-cpd-id:\n - constituent-base-element-id: \"1\"\n constituent-cpd-id: vnf-vdu2-ext # this must be equal to the vdu's ext-cpd's id \n virtual-link-profile-id: mgmtnet_2\n vnfd-id: tutorial_vnf\n - id: \"vnf2\"\n virtual-link-connectivity:\n - constituent-cpd-id:\n - constituent-base-element-id: \"1\"\n constituent-cpd-id: vnf-vdu1-ext # this must be equal to the vdu's ext-cpd's id \n virtual-link-profile-id: mgmtnet_2\n - constituent-cpd-id:\n - constituent-base-element-id: \"1\"\n constituent-cpd-id: vnf-vdu2-ext # this must be equal to the vdu's ext-cpd's id \n virtual-link-profile-id: mgmtnet_2\n vnfd-id: tutorial_vnf\n id: tutorial_ns\n name: tutorial_ns\n version: \"1.0\"\n virtual-link-desc:\n - id: mgmtnet_2\n mgmt-network: true\n vim-network-name: new_5gasp\n vnfd-id:\n - tutorial_vnf","descriptorHTML":"

tutorial_ns


Vendor: null
Version: 1.0
Description: tutorial_ns
VNF Count: 1
VM Count: 0
vCPU Count: 0
Memory: 0 MB
Storage: 0 GB

ConstituentVnfds


VnfdId: default-df
","valid":false,"validationStatus":"NOT_STARTED","packagingFormat":"OSMvTHIRTEEN","experimentOnBoardDescriptors":[{"id":4,"obMANOprovider":{"id":1,"name":"osm14","description":null,"vims":[{"id":1,"organization":null,"name":"Jarvis","email":null,"infrastructureStatus":"UNKNOWN","dateCreated":null,"datacentername":"osm14","vimid":"479356bf-72ff-4dfd-8483-5c23f48dd0bc","mp":null,"refSupportedImages":[]}],"supportedMANOplatform":{"id":1,"name":"OSMFOURTEEN","version":"OSMvTHIRTEEN","description":null},"apiEndpoint":"https://10.255.28.219:9999","authorizationBasicHeader":null,"username":"admin","password":"admin","project":"admin","enabledForONBOARDING":true,"enabledForSYNC":true},"onBoardingStatus":"ONBOARDED","lastOnboarding":1717002821939,"deployId":"9dc24900-e63e-4c0e-b686-ee2ef124c5c2","feedbackMessage":"NSD Onboarded Successfully","uuid":"c271dcf1-d823-4458-99dc-7fd80ba93a06","experimentMANOProviderID":"tutorial_ns","experimentid":4}],"constituentVxF":[{"membervnfIndex":"vnf2","vnfdidRef":"tutorial_vnf","vxfref":{"id":3,"owner":{"id":2,"organization":null,"firstname":null,"lastname":null,"email":null,"username":"admin","createdAt":null},"uuid":"0c3bb7df-5063-4844-818f-3a6b6507718e","name":"tutorial_vnf","iconsrc":null,"shortDescription":"tutorial_vnf","longDescription":null,"version":"1.0","packageLocation":"http://10.255.28.246/osapi/packages/0c3bb7df-5063-4844-818f-3a6b6507718e/tutorial_vnf.tar.gz","dateCreated":1717002803785,"dateUpdated":1717002803785,"categories":null,"extensions":null,"validationJobs":null,"screenshots":null,"vendor":null,"published":false,"termsOfUse":null,"descriptor":"vnfd:\n description: A basic VNF descriptor with two VDUs\n mgmt-cp: vnf-vdu1-ext\n int-virtual-link-desc:\n - id: internal-vl\n flavour:\n - id: internal-vl-flavor\n product-name: tutorial_vnf\n id: tutorial_vnf\n df:\n - id: default-df\n instantiation-level:\n - id: default-instantiation-level\n vdu-level:\n - number-of-instances: \"1\"\n vdu-id: vdu1\n - number-of-instances: \"1\"\n vdu-id: vdu2\n vdu-profile:\n - id: vdu1\n min-number-of-instances: \"1\"\n - id: vdu2\n min-number-of-instances: \"1\"\n # Juju/LCM Actions\n lcm-operations-configuration:\n operate-vnf-op-config:\n day1-2:\n - execution-environment-list:\n - id: configure-vnf\n external-connection-point-ref: vnf-vdu1-ext\n juju:\n charm: simple-touch\n proxy: true\n id: tutorial_vnf\n config-access:\n ssh-access:\n default-user: ubuntu\n required: true\n initial-config-primitive:\n - execution-environment-ref: configure-vnf\n name: config\n parameter:\n - name: ssh-hostname\n value: \n - name: ssh-username\n value: ubuntu\n - name: ssh-password\n value: tutorial\n seq: 1\n config-primitive:\n - name: run-touch-command\n execution-environment-ref: configure-vnf\n parameter:\n - name: filename\n data-type: STRING\n #####################################\n - execution-environment-list:\n - id: vdu1-ee\n external-connection-point-ref: vnf-vdu1-ext\n juju:\n charm: simple-touch\n proxy: true\n id: vdu1 # this must be equal to the vdu's id\n config-access:\n ssh-access:\n default-user: ubuntu\n required: true\n initial-config-primitive:\n - execution-environment-ref: vdu1-ee\n name: config\n parameter:\n - name: ssh-hostname\n value: \n - name: ssh-username\n value: ubuntu\n - name: ssh-password\n value: tutorial\n seq: 1\n config-primitive:\n - name: run-touch-command\n execution-environment-ref: vdu1-ee\n parameter:\n - name: filename\n data-type: STRING\n - execution-environment-list:\n - id: vdu2-ee\n #external-connection-point-ref: vnf-cp2-ext\n juju:\n charm: simple-touch\n proxy: true\n id: vdu2 # this must be equal to the vdu's id\n config-access:\n ssh-access:\n default-user: ubuntu\n required: true\n initial-config-primitive:\n - execution-environment-ref: vdu2-ee\n name: config\n parameter:\n - name: ssh-hostname\n value: \n - name: ssh-username\n value: ubuntu\n - name: ssh-password\n value: tutorial\n seq: 1\n config-primitive:\n - name: run-touch-command\n execution-environment-ref: vdu2-ee\n parameter:\n - name: filename\n data-type: STRING\n ext-cpd:\n - id: vnf-vdu1-ext\n int-cpd:\n cpd: vdu1-int-out\n vdu-id: vdu1\n - id: vnf-vdu2-ext\n int-cpd:\n cpd: vdu2-int-out\n vdu-id: vdu2\n sw-image-desc:\n - id: \"ubuntu-20.04-server-cloudimg-amd64\"\n image: \"ubuntu-20.04-server-cloudimg-amd64\"\n name: \"ubuntu-20.04-server-cloudimg-amd64\"\n vdu:\n - cloud-init-file: cloud-config.txt\n id: vdu1\n int-cpd:\n - id: vdu1-int-out\n virtual-network-interface-requirement:\n - name: vdu1-out\n virtual-interface:\n type: PARAVIRT\n - id: vdu1-int-in\n int-virtual-link-desc: internal-vl\n virtual-network-interface-requirement:\n - name: vdu1-in\n virtual-interface:\n type: PARAVIRT\n name: vdu1\n sw-image-desc: \"ubuntu-20.04-server-cloudimg-amd64\"\n virtual-compute-desc: vdu1-compute\n virtual-storage-desc:\n - vdu1-storage\n - cloud-init-file: cloud-config.txt\n id: vdu2\n int-cpd:\n - id: vdu2-int-out\n virtual-network-interface-requirement:\n - name: vdu2-out\n virtual-interface:\n type: PARAVIRT\n - id: vdu2-int-in\n int-virtual-link-desc: internal-vl\n virtual-network-interface-requirement:\n - name: vdu2-in\n virtual-interface:\n type: PARAVIRT\n name: vdu2\n sw-image-desc: \"ubuntu-20.04-server-cloudimg-amd64\"\n virtual-compute-desc: vdu2-compute\n virtual-storage-desc:\n - vdu2-storage\n version: \"1.0\"\n virtual-compute-desc:\n - id: vdu1-compute\n virtual-cpu:\n num-virtual-cpu: \"1\"\n virtual-memory:\n size: \"1.0\"\n - id: vdu2-compute\n virtual-cpu:\n num-virtual-cpu: \"1\"\n virtual-memory:\n size: \"1.0\"\n virtual-storage-desc:\n - id: vdu1-storage\n size-of-storage: \"10\"\n - id: vdu2-storage\n size-of-storage: \"10\"","descriptorHTML":"

tutorial_vnf


Vendor: null
Version: 1.0
Description: null
VM Count: 2
vCPU Count: 1
Memory: 1 MB
Storage: 10 GB
","certified":false,"certifiedBy":null,"validationStatus":"UNDER_REVIEW","packagingFormat":"OSMvTHIRTEEN","supportedMANOPlatforms":null,"vxfOnBoardedDescriptors":null,"vfimagesVDU":null}},{"membervnfIndex":"vnf1","vnfdidRef":"tutorial_vnf","vxfref":{"id":3,"owner":{"id":2,"organization":null,"firstname":null,"lastname":null,"email":null,"username":"admin","createdAt":null},"uuid":"0c3bb7df-5063-4844-818f-3a6b6507718e","name":"tutorial_vnf","iconsrc":null,"shortDescription":"tutorial_vnf","longDescription":null,"version":"1.0","packageLocation":"http://10.255.28.246/osapi/packages/0c3bb7df-5063-4844-818f-3a6b6507718e/tutorial_vnf.tar.gz","dateCreated":1717002803785,"dateUpdated":1717002803785,"categories":null,"extensions":null,"validationJobs":null,"screenshots":null,"vendor":null,"published":false,"termsOfUse":null,"descriptor":"vnfd:\n description: A basic VNF descriptor with two VDUs\n mgmt-cp: vnf-vdu1-ext\n int-virtual-link-desc:\n - id: internal-vl\n flavour:\n - id: internal-vl-flavor\n product-name: tutorial_vnf\n id: tutorial_vnf\n df:\n - id: default-df\n instantiation-level:\n - id: default-instantiation-level\n vdu-level:\n - number-of-instances: \"1\"\n vdu-id: vdu1\n - number-of-instances: \"1\"\n vdu-id: vdu2\n vdu-profile:\n - id: vdu1\n min-number-of-instances: \"1\"\n - id: vdu2\n min-number-of-instances: \"1\"\n # Juju/LCM Actions\n lcm-operations-configuration:\n operate-vnf-op-config:\n day1-2:\n - execution-environment-list:\n - id: configure-vnf\n external-connection-point-ref: vnf-vdu1-ext\n juju:\n charm: simple-touch\n proxy: true\n id: tutorial_vnf\n config-access:\n ssh-access:\n default-user: ubuntu\n required: true\n initial-config-primitive:\n - execution-environment-ref: configure-vnf\n name: config\n parameter:\n - name: ssh-hostname\n value: \n - name: ssh-username\n value: ubuntu\n - name: ssh-password\n value: tutorial\n seq: 1\n config-primitive:\n - name: run-touch-command\n execution-environment-ref: configure-vnf\n parameter:\n - name: filename\n data-type: STRING\n #####################################\n - execution-environment-list:\n - id: vdu1-ee\n external-connection-point-ref: vnf-vdu1-ext\n juju:\n charm: simple-touch\n proxy: true\n id: vdu1 # this must be equal to the vdu's id\n config-access:\n ssh-access:\n default-user: ubuntu\n required: true\n initial-config-primitive:\n - execution-environment-ref: vdu1-ee\n name: config\n parameter:\n - name: ssh-hostname\n value: \n - name: ssh-username\n value: ubuntu\n - name: ssh-password\n value: tutorial\n seq: 1\n config-primitive:\n - name: run-touch-command\n execution-environment-ref: vdu1-ee\n parameter:\n - name: filename\n data-type: STRING\n - execution-environment-list:\n - id: vdu2-ee\n #external-connection-point-ref: vnf-cp2-ext\n juju:\n charm: simple-touch\n proxy: true\n id: vdu2 # this must be equal to the vdu's id\n config-access:\n ssh-access:\n default-user: ubuntu\n required: true\n initial-config-primitive:\n - execution-environment-ref: vdu2-ee\n name: config\n parameter:\n - name: ssh-hostname\n value: \n - name: ssh-username\n value: ubuntu\n - name: ssh-password\n value: tutorial\n seq: 1\n config-primitive:\n - name: run-touch-command\n execution-environment-ref: vdu2-ee\n parameter:\n - name: filename\n data-type: STRING\n ext-cpd:\n - id: vnf-vdu1-ext\n int-cpd:\n cpd: vdu1-int-out\n vdu-id: vdu1\n - id: vnf-vdu2-ext\n int-cpd:\n cpd: vdu2-int-out\n vdu-id: vdu2\n sw-image-desc:\n - id: \"ubuntu-20.04-server-cloudimg-amd64\"\n image: \"ubuntu-20.04-server-cloudimg-amd64\"\n name: \"ubuntu-20.04-server-cloudimg-amd64\"\n vdu:\n - cloud-init-file: cloud-config.txt\n id: vdu1\n int-cpd:\n - id: vdu1-int-out\n virtual-network-interface-requirement:\n - name: vdu1-out\n virtual-interface:\n type: PARAVIRT\n - id: vdu1-int-in\n int-virtual-link-desc: internal-vl\n virtual-network-interface-requirement:\n - name: vdu1-in\n virtual-interface:\n type: PARAVIRT\n name: vdu1\n sw-image-desc: \"ubuntu-20.04-server-cloudimg-amd64\"\n virtual-compute-desc: vdu1-compute\n virtual-storage-desc:\n - vdu1-storage\n - cloud-init-file: cloud-config.txt\n id: vdu2\n int-cpd:\n - id: vdu2-int-out\n virtual-network-interface-requirement:\n - name: vdu2-out\n virtual-interface:\n type: PARAVIRT\n - id: vdu2-int-in\n int-virtual-link-desc: internal-vl\n virtual-network-interface-requirement:\n - name: vdu2-in\n virtual-interface:\n type: PARAVIRT\n name: vdu2\n sw-image-desc: \"ubuntu-20.04-server-cloudimg-amd64\"\n virtual-compute-desc: vdu2-compute\n virtual-storage-desc:\n - vdu2-storage\n version: \"1.0\"\n virtual-compute-desc:\n - id: vdu1-compute\n virtual-cpu:\n num-virtual-cpu: \"1\"\n virtual-memory:\n size: \"1.0\"\n - id: vdu2-compute\n virtual-cpu:\n num-virtual-cpu: \"1\"\n virtual-memory:\n size: \"1.0\"\n virtual-storage-desc:\n - id: vdu1-storage\n size-of-storage: \"10\"\n - id: vdu2-storage\n size-of-storage: \"10\"","descriptorHTML":"

tutorial_vnf


Vendor: null
Version: 1.0
Description: null
VM Count: 2
vCPU Count: 1
Memory: 1 MB
Storage: 10 GB
","certified":false,"certifiedBy":null,"validationStatus":"UNDER_REVIEW","packagingFormat":"OSMvTHIRTEEN","supportedMANOPlatforms":null,"vxfOnBoardedDescriptors":null,"vfimagesVDU":null}}]} \ No newline at end of file diff --git a/src/test/resources/testEventSubscriptionInput.json b/src/test/resources/testEventSubscriptionInput.json new file mode 100644 index 0000000000000000000000000000000000000000..bccdb0cdb7f50e92a7ac57abcd18cbe28d5be28e --- /dev/null +++ b/src/test/resources/testEventSubscriptionInput.json @@ -0,0 +1,3 @@ +{ + "query": "test" +} \ No newline at end of file diff --git a/src/test/resources/testExportJob.json b/src/test/resources/testExportJob.json new file mode 100644 index 0000000000000000000000000000000000000000..cb006da88796f2874e9c144291833106c0c747ba --- /dev/null +++ b/src/test/resources/testExportJob.json @@ -0,0 +1,4 @@ +{ + "contentType": "application/json", + "url": "https://my/daily/job/NHCFD6" +} \ No newline at end of file diff --git a/src/test/resources/testPhysicalResourceSpec.json b/src/test/resources/testPhysicalResourceSpec.json new file mode 100644 index 0000000000000000000000000000000000000000..b3eed3483978b495eed29150349f5dc437029914 --- /dev/null +++ b/src/test/resources/testPhysicalResourceSpec.json @@ -0,0 +1,180 @@ +{ + "name": "Test Resource Spec", + "description": "Test Resource Spec example", + "version": "1.8.0", + "isBundle": false, + "@type": "PhysicalResourceSpecification", + "validFor": { + "startDateTime": "2017-08-12T00:00:00.999Z", + "endDateTime": "2018-03-07T00:00:00.999Z" + }, + "category": "Router resource", + "attachment": [ + { + "id": "25553", + "href": "https://mycsp.com:8080/tmf-api/documentManagement/v4/attachment/25553", + "name": "Data Sheet", + "mimeType": "application/pdf", + "url": "https://onestore.nokia.com/asset/205421" + } + ], + "relatedParty": [ + { + "id": "5855", + "href": "https://mycsp.com:8080/tmf-api/partyRoleManagement/organization/5855", + "role": "Supplier", + "name": "Nokia Networks" + } + ], + "resourceSpecRelationship": [ + { + "id": "556234", + "href": "https://mycsp.com:8080/tmf-api/resourceCatalogManagement/resourceSpecification/556234", + "name": "SR OS Operating System", + "relationshipType": "dependency" + } + ], + "resourceSpecCharacteristic": [ + { + "name": "CoverageSpec", + "configurable": true, + "description": "This attribute specifies the coverage area of the network slice - the area where the terminals can access a particular network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + "resourceSpecCharRelationship": [ + { + "name": "Character Attribute", + "relationshipType": "dependency" + }, + { + "name": "Operational", + "relationshipType": "dependency" + }, + { + "name": "Scalability Attribute", + "relationshipType": "dependency" + }, + { + "name": "KPI", + "relationshipType": "dependency" + } + ], + "resourceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "SMALLINT", + "validFor": null, + "value": { + "value": "4", + "alias": "Local (outdoor)" + } + } + ] + } + ], + "featureSpecification": [ + { + "id": "l22m455f-671a-499d-a95j-8h46fe3bc88c", + "name": "log", + "validFor": { + "startDateTime": "2015-11-21T00:00:00.999Z", + "endDateTime": "2019-12-31T23:59:59.999Z" + }, + "featureSpecCharacteristic": [ + { + "name": "logSize", + "description": "Log Size in MB", + "valueType": "integer", + "configurable": true, + "validFor": { + "startDateTime": "2015-11-22T00:00:00.999Z", + "endDateTime": "2019-12-31T23:59:59.999Z" + }, + "@type": "FeatureSpecificationCharacteristic", + "minCardinality": 0, + "maxCardinality": 1, + "isUnique": true, + "extensible": false, + "featureSpecCharacteristicValue": [ + { + "isDefault": true, + "valueType": "integer", + "value": 2000, + "validFor": { + "startDateTime": "2015-11-22T00:00:00.999Z", + "endDateTime": "2019-12-31T23:59:59.999Z" + } + }, + { + "isDefault": false, + "valueType": "integer", + "value": 4000, + "validFor": { + "startDateTime": "2015-11-22T00:00:00.999Z", + "endDateTime": "2019-12-31T23:59:59.999Z" + } + } + ] + } + ] + }, + { + "id": "db723e27-58d3-4120-b564-af199cb32bd3", + "name": "IPAddressing", + "isBundle": true, + "validFor": { + "startDateTime": "2017-05-24T00:00:00.999Z", + "endDateTime": "2019-12-31T23:59:59.999Z" + }, + "constraint": [ + { + "id": "34", + "version": "1.0", + "href": "https://mycsp.com:8080/tmf-api/resourceCatalogManagement/v4/constraint/34", + "name": "ReliesOnIPv4OrIPv6" + } + ], + "featureSpecRelationship": [ + { + "relationshipType": "requires", + "featureId": "43883a81-58ef-45af-ace4-993298ae8361", + "resourceSpecificationId": "755232457686", + "resourceSpecificationHref": "https://mycsp.com:8080/tmf-api/resourceCatalogManagement/resourceSpecification/755232457686", + "name": "IPv4Addressing", + "validFor": { + "startDateTime": "2017-05-24T00:00:00.999Z", + "endDateTime": "2019-12-31T23:59:59.999Z" + } + }, + { + "relationshipType": "requires", + "featureId": "b85f845f-011a-468f-a90e-9e07fe3bc90a", + "resourceSpecificationId": "755232457686", + "resourceSpecificationHref": "https://mycsp.com:8080/tmf-api/resourceCatalogManagement/resourceSpecification/755232457686", + "name": "IPv6Addressing", + "validFor": { + "startDateTime": "2017-05-24T00:00:00.999Z", + "endDateTime": "2019-12-31T23:59:59.999Z" + } + } + ] + } + ], + "targetResourceSchema": { + "@type": "NokiaRouter", + "@schemaLocation": "https://mycsp.com:8080/tmf-api/schema/Resource/NokiaRouter.schema.json" + }, + "model": "7750 SR", + "part": "2s", + "sku": "3HE09264AA", + "vendor": "Nokia Networks" +} \ No newline at end of file diff --git a/src/test/resources/testProductCatalog.txt b/src/test/resources/testProductCatalog.txt new file mode 100644 index 0000000000000000000000000000000000000000..02c2185e0ac6bac88fb7e6572ab59e1ad608d5b9 --- /dev/null +++ b/src/test/resources/testProductCatalog.txt @@ -0,0 +1,5 @@ +{ + "name": "Test Product Catalog", + "description": "A Test Product Catalog", + "version": "1.8" +} \ No newline at end of file diff --git a/src/test/resources/testProductCategory.txt b/src/test/resources/testProductCategory.txt new file mode 100644 index 0000000000000000000000000000000000000000..4b71154c97c5eadef1e00abe29d0b17bbba63b88 --- /dev/null +++ b/src/test/resources/testProductCategory.txt @@ -0,0 +1,5 @@ +{ + "name": "Test Product Category 2", + "description": "A Test Product Category", + "version": "1.8" +} \ No newline at end of file diff --git a/src/test/resources/testProductOfferingPrice.txt b/src/test/resources/testProductOfferingPrice.txt new file mode 100644 index 0000000000000000000000000000000000000000..737065bb9d83ba927470e3b514815537ee94bf99 --- /dev/null +++ b/src/test/resources/testProductOfferingPrice.txt @@ -0,0 +1,65 @@ +{ + "name": "Recurring Charge for Business Firewall", + "description": "This pricing describes the recurring charge for a firewall service that can be deployed in business customer premise.", + "version": "2.1", + "validFor": { + "startDateTime": "2017-08-23T13:27:56Z", + "endDateTime": "2018-03-25T13:27:56Z" + }, + "priceType": "recurring", + "recurringChargePeriodType": "monthly", + "recurringChargePeriodLength": 1, + "isBundle": false, + "lifecycleStatus": "Active", + "price": { + "unit": "EUR", + "value": 50 + }, + "percentage": 0, + "productOfferingTerm": [ + { + "name": "12 Month", + "description": "12 month contract", + "duration": { + "amount": 12, + "units": "Month" + }, + "validFor": { + "startDateTime": "2017-04-19T16:42:23.0Z", + "endDateTime": "2017-06-19T00:00:00.0Z" + } + } + ], + "place": [ + { + "id": "9979", + "name": "San Francisco Bay Area" + } + ], + "constraint": [ + { + "name": "PriceRuleNo1", + "id": "525" + } + ], + "pricingLogicAlgorithm": [{ + "id": "533", + "name": "PLA_rec", + "description": "Algorithm that rates Recurring event", + "plaSpecId": "525", + "validFor": { + "startDateTime": "2017-04-19T16:42:23.0Z", + "endDateTime": "2018-06-19T00:00:00.0Z" + } + }], + "tax": [ + { + "taxAmount": { + "unit": "EUR", + "value": 10 + }, + "taxCategory": "VAT", + "taxRate": 20 + } + ] +} \ No newline at end of file diff --git a/src/test/resources/testProductOfferingSpec.json b/src/test/resources/testProductOfferingSpec.json new file mode 100644 index 0000000000000000000000000000000000000000..59c5df723e56337a3da50172a6b4fc969e5f156e --- /dev/null +++ b/src/test/resources/testProductOfferingSpec.json @@ -0,0 +1,24 @@ +{ + "name": "Test Product offering Spec", + "description": "Test Spec example", + "lifecycleStatus": "In study", + "version": "1.8.0", + "validFor": null, + "isBundle": false, + "isSellable": null, + "statusReason": null, + "agreement": [], + "attachment": [], + "bundledProductOffering": [], + "category": [], + "channel": [], + "marketSegment": [], + "place": [], + "prodSpecCharValueUse": [], + "productOfferingPrice": [], + "productOfferingTerm": [], + "productSpecification": null, + "resourceCandidate": null, + "serviceCandidate": null, + "serviceLevelAgreement": null +} \ No newline at end of file diff --git a/src/test/resources/testProductSpec.json b/src/test/resources/testProductSpec.json new file mode 100644 index 0000000000000000000000000000000000000000..007ef92ee51ff97f305fb3d834300bd45901f43d --- /dev/null +++ b/src/test/resources/testProductSpec.json @@ -0,0 +1,145 @@ +{ + "name": "Acme Firepower NGFW", + "brand": "Acme", + "productNumber": "CSC-340-NGFW", + "description": "Powerful product that integrates with a firewall, including intrusion prevention, advanced malware protection, cloud-based sandboxing, URL filtering, endpoint protection, web gateway, email security, network traffic analysis, network access control and CASB.", + "isBundle": true, + "lifecycleStatus": "Active", + "validFor": { + "startDateTime": "2017-06-19T00:00:00.0Z", + "endDateTime": "2018-04-19T16:42:23.0Z" + }, + "version": "2.1", + "relatedParty": [ + { + "id": "1234", + "role": "Owner", + "name": "Gustave Flaubert" + } + ], + "attachment": [ + { + "id": "15", + "name": "Product Picture", + "mimeType": "image/jpeg", + "url": "https://mycsp.com:7070/docloader?docnum=774451234" + }, + { + "id": "16", + "name": "Product Manual", + "mimeType": "application/pdf", + "url": "https://mycsp.com:7070/docloader?docnum=774454321" + } + ], + "bundledProductSpecification": [ + { + "id": "15", + "name": "URL Filter" + }, + { + "id": "64", + "name": "Malware Protector" + } + ], + "productSpecificationRelationship": [ + { + "id": "23", + "relationshipType": "Dependency", + "validFor": { + "startDateTime": "2017-04-19T16:42:23.0Z" + } + } + ], + "serviceSpecification": [ + { + "id": "22", + "name": "Firewall", + "version": "1.0" + } + ], + "resourceSpecification": [ + { + "id": "63", + "name": "Firewall Port", + "version": "1.0" + } + ], + "productSpecCharacteristic": [ + { + "name": "Number of Ports", + "description": "The total Number of Ports for this product", + "valueType": "number", + "configurable": true, + "minCardinality": 1, + "maxCardinality": 1, + "isUnique": true, + "productSpecCharRelationship": [ + { + "id": "43", + "relationshipType": "Dependency", + "name": "Bandwidth", + "validFor": { + "startDateTime": "2018-04-19T16:42:23.0Z" + } + } + ], + "productSpecCharacteristicValue": [ + { + "isDefault": true, + "valueType": "number", + "validFor": { + "startDateTime": "2017-06-16T00:00:23.0Z", + "endDateTime": "2018-01-13T00:00:23.0Z" + }, + "value": 8 + }, + { + "isDefault": false, + "valueType": "number", + "validFor": { + "startDateTime": "2017-06-16T00:00:23.0Z", + "endDateTime": "2018-01-13T00:00:23.0Z" + }, + "value": 16 + }, + { + "isDefault": false, + "valueType": "number", + "validFor": { + "startDateTime": "2017-06-16T00:00:23.0Z", + "endDateTime": "2018-01-13T00:00:23.0Z" + }, + "value": 24 + } + ], + "validFor": { + "startDateTime": "2017-04-19T16:42:23.0Z" + } + }, + { + "name": "Color", + "description": "Color of the Firewall housing", + "valueType": "string", + "configurable": true, + "minCardinality": 1, + "maxCardinality": 1, + "extensible": true, + "isUnique": true, + "productSpecCharacteristicValue": [ + { + "isDefault": true, + "valueType": " string", + "value": "Black" + }, + { + "isDefault": false, + "valueType": " string", + "value": "White" + } + ], + "validFor": { + "startDateTime": "2017-04-19T16:42:23.0Z" + } + } + ] +} \ No newline at end of file diff --git a/src/test/resources/testResourceCatalog.txt b/src/test/resources/testResourceCatalog.txt new file mode 100644 index 0000000000000000000000000000000000000000..8f23bdb6d544a2b6cb5f5487ed2d6457a36f1de7 --- /dev/null +++ b/src/test/resources/testResourceCatalog.txt @@ -0,0 +1,5 @@ +{ + "name": "Test Catalog", + "description": "A Test Catalog", + "version": "1.8" +} \ No newline at end of file diff --git a/src/test/resources/testResourceCategory.txt b/src/test/resources/testResourceCategory.txt new file mode 100644 index 0000000000000000000000000000000000000000..59ddc545f2980c0b2f24d8b15695c6dcfc7ab298 --- /dev/null +++ b/src/test/resources/testResourceCategory.txt @@ -0,0 +1,5 @@ +{ + "name": "Test Category 2", + "description": "A Test Category", + "version": "1.8" +} \ No newline at end of file diff --git a/src/test/resources/testResourcePool.json b/src/test/resources/testResourcePool.json new file mode 100644 index 0000000000000000000000000000000000000000..ea80de1473be78f347e049aca4fbf736ba48942b --- /dev/null +++ b/src/test/resources/testResourcePool.json @@ -0,0 +1,86 @@ +{ + "id": "42", + "href": "/hostname:port/ResourcePoolManagement/resourcePool/42", + "name": "StorageCapacity", + "@schemaLocation": "http://hostname:port/ResourcePoolManagement/v1/schema/storageCapacity ", + "@type": "Storage", + + "capacity": [{ + "capacitySpec": { + "id": "44", + "href": "http://hostname:port/ResourcePoolManagement/capacitySpecificatoin/44" + }, + "capacityAmount": "500GB", + "relatedParty": { + "partyRole": "EnterpriseConpany" + }, + "place": { + "id": "00555", + "type": "CITY", + "name": "Mitaka" + }, + "apricableTimePeriod": { + "from": "2017.11.11 11:11" + }, + "appliedCapacitylist": [{ + "appliedCapacityamount": "200GB", + "capacityDemand": { + "capacityDemandAmount": "200GB" + }, + "Resource": [{ + "id": "3", + "href": "http://server:port/resourceInventoryManagement/logicalResource/3" + }] + }, + { + "appliedCapacityamount": "300GB", + "capacityDemand": { + "capacityDemandAmount": "300GB" + }, + "resource": [{ + "id": "3", + "href": " http://server:port/resourceInventoryManagement/logicalResource/3" + }, + { + "id": "5", + "href": " http://server:port/resourceInventoryManagement/logicalResource/5" + } + ] + } + ], + "resourceRef": [{ + "id": "3", + "href": " http://server:port/resourceInventoryManagement/logicalResource/3" + }, + { + "id": "5", + "href": " http://server:port/resourceInventoryManagement/logicalResource/5" + } + ] + }, + { + "capacitySpec": { + "id": "54", + "href": "http://hostname:port/ResourcePoolManagement/CapacitySpecificatoin/54" + }, + "capacityAmount": "1TB", + "relatedParty": { + "partyRole": "EnterpriseConpany" + }, + "place": { + "id": "00555", + "type": "CITY", + "name": "Mitaka" + }, + "apricableTimePeriod": { + "from": "2017.12.11 11:11" + }, + "appliedCapacitylist": [{ + "resourceRef": [{ + "id": "9", + "href": "http://server:port/resourceInventoryManagement/logicalResource/9" + }] + }] + } + ] +} \ No newline at end of file diff --git a/src/test/resources/testResourceSpec.json b/src/test/resources/testResourceSpec.json new file mode 100644 index 0000000000000000000000000000000000000000..5809ccc601dad43c29d5aee78cfa09b57b19b841 --- /dev/null +++ b/src/test/resources/testResourceSpec.json @@ -0,0 +1,46 @@ +{ + "name": "Test Resource Spec", + "description": "Test Resource Spec example", + "version": "1.8.0", + "isBundle": false, + "@type": "LogicalResourceSpecification", + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecCharacteristic": [ + { + "name": "CoverageSpec", + "configurable": true, + "description": "This attribute specifies the coverage area of the network slice - the area where the terminals can access a particular network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + "resourceSpecCharRelationship": [ + { "name": "Character Attribute", "relationshipType": "dependency" }, + { "name": "Operational", "relationshipType": "dependency" }, + { "name": "Scalability Attribute", "relationshipType": "dependency" }, + { "name": "KPI", "relationshipType": "dependency" } + ], + "resourceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "SMALLINT", + "validFor": null, + "value": { + "value": "4", + "alias": "Local (outdoor)" + } + } + ] + } + ] +} diff --git a/src/test/resources/testServiceCandidate.txt b/src/test/resources/testServiceCandidate.txt new file mode 100644 index 0000000000000000000000000000000000000000..e499cc0699beaec54c04d95e62e7126b83df0599 --- /dev/null +++ b/src/test/resources/testServiceCandidate.txt @@ -0,0 +1,5 @@ +{ + "description": "A Test Service Candidate", + "version": "1.8", + "name": "Test Service Candidate" +} \ No newline at end of file diff --git a/src/test/resources/testServiceCandidateChangeNotification.json b/src/test/resources/testServiceCandidateChangeNotification.json new file mode 100644 index 0000000000000000000000000000000000000000..83442e8e267ea97db23f53bd0557c0845e6ce818 --- /dev/null +++ b/src/test/resources/testServiceCandidateChangeNotification.json @@ -0,0 +1,3 @@ +{ + "eventId": "testId" +} \ No newline at end of file diff --git a/src/test/resources/testServiceCatalog.txt b/src/test/resources/testServiceCatalog.txt new file mode 100644 index 0000000000000000000000000000000000000000..8f23bdb6d544a2b6cb5f5487ed2d6457a36f1de7 --- /dev/null +++ b/src/test/resources/testServiceCatalog.txt @@ -0,0 +1,5 @@ +{ + "name": "Test Catalog", + "description": "A Test Catalog", + "version": "1.8" +} \ No newline at end of file diff --git a/src/test/resources/testServiceCategory.txt b/src/test/resources/testServiceCategory.txt new file mode 100644 index 0000000000000000000000000000000000000000..59ddc545f2980c0b2f24d8b15695c6dcfc7ab298 --- /dev/null +++ b/src/test/resources/testServiceCategory.txt @@ -0,0 +1,5 @@ +{ + "name": "Test Category 2", + "description": "A Test Category", + "version": "1.8" +} \ No newline at end of file diff --git a/src/test/resources/testServiceSpec.json b/src/test/resources/testServiceSpec.json new file mode 100644 index 0000000000000000000000000000000000000000..bd1411c028c26356ebaa991961daad4000c4c0f0 --- /dev/null +++ b/src/test/resources/testServiceSpec.json @@ -0,0 +1,49 @@ +{ + "name": "Test Spec", + "description": "Test Spec example", + "version": "1.8.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + "name": "Coverage", + "configurable": true, + "description": "This attribute specifies the coverage area of the network slice - the area where the terminals can access a particular network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "dependency" }, + { "name": "Operational", "role": "tag", "relationshipType": "dependency" }, + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "dependency" }, + { "name": "KPI", "role": "tag", "relationshipType": "dependency" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "SMALLINT", + "validFor": null, + "value": { + "value": "4", + "alias": "Local (outdoor)" + } + } + ] + } + ] +} diff --git a/src/test/resources/testServiceSpec2.json b/src/test/resources/testServiceSpec2.json new file mode 100644 index 0000000000000000000000000000000000000000..13e648d6256c026bc134c9418cb6deccbadbb96e --- /dev/null +++ b/src/test/resources/testServiceSpec2.json @@ -0,0 +1,78 @@ +{ + "name": "Test Spec2", + "description": "Test Spec2 example", + "version": "1.8.0", + "isBundle": false, + "attachment": [ + ], + "relatedParty": [ + ], + "resourceSpecification": [ + ], + "serviceLevelSpecification": [ + ], + "serviceSpecCharacteristic": [ + { + "name": "Spec2Attribute1", + "configurable": true, + "description": "This attribute specifies the coverage area of the network slice - the area where the terminals can access a particular network slice", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "regex": null, + "valueType": "ENUM", + "serviceSpecCharRelationship": [ + { "name": "Character Attribute", "role": "tag", "relationshipType": "dependency" }, + { "name": "Operational", "role": "tag", "relationshipType": "dependency" }, + { "name": "Scalability Attribute", "role": "tag", "relationshipType": "dependency" }, + { "name": "KPI", "role": "tag", "relationshipType": "dependency" } + ], + "serviceSpecCharacteristicValue": [ + { + "isDefault": true, + "rangeInterval": null, + "regex": null, + "unitOfMeasure": "N/A", + "valueFrom": null, + "valueTo": null, + "valueType": "SMALLINT", + "validFor": null, + "value": { + "value": "4", + "alias": "Local (outdoor)" + } + } + ] + }, + { + "name": "Spec2Attribute2", + "configurable": true, + "description": "This attribute specifies the xxx", + "extensible": null, + "isUnique": true, + "maxCardinality": 1, + "minCardinality": 1, + "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" + } + } + ] + } + ] +} diff --git a/src/test/resources/testServiceTest.json b/src/test/resources/testServiceTest.json new file mode 100644 index 0000000000000000000000000000000000000000..07f49819ecc0598f4190cc849d38c77ee7c11b77 --- /dev/null +++ b/src/test/resources/testServiceTest.json @@ -0,0 +1,6 @@ +{ + "name": "A test name", + "description": "a test", + "mode": "PROACTIVE", + "state": "none" +} \ No newline at end of file diff --git a/src/test/resources/testServiceTestSpec.json b/src/test/resources/testServiceTestSpec.json new file mode 100644 index 0000000000000000000000000000000000000000..22961ba87096e64fd1bfbd48ced79355844ccfef --- /dev/null +++ b/src/test/resources/testServiceTestSpec.json @@ -0,0 +1,15 @@ +{ + "name": "A test name", + "description": "a test", + "lifecycleStatus": "In study", + "version": "0.beta", + "isBundle": false, + "attachment": [], + "constraint": [], + "entitySpecRelationship": [], + "relatedServiceSpecification": [], + "serviceTestSpecRelationship": [], + "specCharacteristic": [], + "targetEntitySchema": null, + "testMeasureDefinition": [] +} \ No newline at end of file