aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnfm-adapter
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-vnfm-adapter')
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml21
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/ETSI-Catalog-Notification-API.json119
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json1778
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java8
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java (renamed from adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java)32
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/AbstractPkgNotificationConverter.java56
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgChangeNotificationConverter.java79
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgOnboardingNotificationConverter.java69
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java11
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java21
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java67
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/AbstractNotificationServiceProvider.java64
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/BasicAuthNotificationServiceProvider.java68
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationManager.java137
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProvider.java51
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProviderFactory.java67
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthNotificationServiceProvider.java102
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthTokenResponse.java56
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java77
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/TlsNotificationServiceProvider.java56
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java86
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java6
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java24
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/AuthenticationTypeNotSupportedException.java44
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/ConversionFailedException.java (renamed from adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionRequestConversionException.java)9
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiSubscriptionNotificationControllerExceptionHandler.java112
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/NotificationTypeNotSupportedException.java44
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java12
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationControllerTest.java592
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java142
33 files changed, 3863 insertions, 155 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
index e874c4b8b3..bf293e5f4b 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
@@ -49,7 +49,26 @@
</configOptions>
</configuration>
</execution>
-
+ <execution>
+ <id>sol003-packagemanagement-notification-api</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <inputSpec>${basedir}/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json</inputSpec>
+ <language>java</language>
+ <library>okhttp-gson</library>
+ <output>${project.build.directory}/generated-sources/sol003-vnf-packagemanagement/notification</output>
+ <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.api</apiPackage>
+ <modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model</modelPackage>
+ <configOptions>
+ <sourceFolder>src/gen/java/main</sourceFolder>
+ <withXml>true</withXml>
+ <useRxJava2>true</useRxJava2>
+ <serializableModel>true</serializableModel>
+ </configOptions>
+ </configuration>
+ </execution>
<execution>
<id>etsicatalog-notification-api</id>
<goals>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/ETSI-Catalog-Notification-API.json b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/ETSI-Catalog-Notification-API.json
index 6f9b2c3bbe..6db54435d2 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/ETSI-Catalog-Notification-API.json
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/ETSI-Catalog-Notification-API.json
@@ -6,18 +6,26 @@
"version": "v1"
},
"host": "127.0.0.1:8000",
- "schemes": ["http"],
+ "schemes": [
+ "http"
+ ],
"basePath": "/",
- "consumes": ["application/json"],
- "produces": ["application/json"],
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
"securityDefinitions": {
"Basic": {
"type": "basic"
}
},
- "security": [{
- "Basic": []
- }],
+ "security": [
+ {
+ "Basic": []
+ }
+ ],
"paths": {
"/URI-is-provided-by-the-client-when-creating-the-subscription-VnfPackageChangeNotification": {
"get": {
@@ -35,25 +43,31 @@
}
}
},
- "tags": ["VNF Package Management interface"]
+ "tags": [
+ "VNF Package Management interface"
+ ]
},
"post": {
"operationId": "URI-is-provided-by-the-client-when-creating-the-subscription-VnfPackageChangeNotification_create",
"description": "",
- "parameters": [{
- "name": "data",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/PkgChangeNotification"
+ "parameters": [
+ {
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/PkgChangeNotification"
+ }
}
- }],
+ ],
"responses": {
"204": {
"description": ""
}
},
- "tags": ["VNF Package Management interface"]
+ "tags": [
+ "VNF Package Management interface"
+ ]
},
"parameters": []
},
@@ -73,25 +87,31 @@
}
}
},
- "tags": ["VNF Package Management interface"]
+ "tags": [
+ "VNF Package Management interface"
+ ]
},
"post": {
"operationId": "URI-is-provided-by-the-client-when-creating-the-subscription-VnfPackageOnboardingNotification_create",
"description": "",
- "parameters": [{
- "name": "data",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/PkgOnboardingNotification"
+ "parameters": [
+ {
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/PkgOnboardingNotification"
+ }
}
- }],
+ ],
"responses": {
"204": {
"description": ""
}
},
- "tags": ["VNF Package Management interface"]
+ "tags": [
+ "VNF Package Management interface"
+ ]
},
"parameters": []
}
@@ -100,7 +120,9 @@
"NOTIFICATION_LINKSERIALIZER": {
"title": "Vnfpackage",
"description": "Link to the resource representing the VNF package to which the notified change applies.",
- "required": ["href"],
+ "required": [
+ "href"
+ ],
"type": "object",
"properties": {
"href": {
@@ -125,7 +147,16 @@
}
},
"PkgChangeNotification": {
- "required": ["id", "notificationType", "timeStamp", "subscriptionId", "vnfPkgId", "changeType", "vnfdId", "_links"],
+ "required": [
+ "id",
+ "notificationType",
+ "timeStamp",
+ "subscriptionId",
+ "vnfPkgId",
+ "changeType",
+ "vnfdId",
+ "_links"
+ ],
"type": "object",
"properties": {
"id": {
@@ -138,7 +169,9 @@
"title": "Notificationtype",
"description": "Discriminator for the different notification types.",
"type": "string",
- "enum": ["VnfPackageChangeNotification"]
+ "enum": [
+ "VnfPackageChangeNotification"
+ ]
},
"timeStamp": {
"title": "Timestamp",
@@ -156,19 +189,25 @@
"title": "Vnfpkgid",
"description": "Identifier of the VNF package.",
"type": "string",
- "format": "uuid"
+ "minLength": 1
},
"changeType": {
"title": "Changetype",
"description": "The type of change of the VNF package.",
"type": "string",
- "enum": ["OP_STATE_CHANGE", "PKG_DELETE"]
+ "enum": [
+ "OP_STATE_CHANGE",
+ "PKG_DELETE"
+ ]
},
"operationalState": {
"title": "Operationalstate",
"description": "New operational state of the VNF package.",
"type": "string",
- "enum": ["ENABLED", "DISABLED"]
+ "enum": [
+ "ENABLED",
+ "DISABLED"
+ ]
},
"vnfdId": {
"title": "Vnfdid",
@@ -182,7 +221,15 @@
}
},
"PkgOnboardingNotification": {
- "required": ["id", "notificationType", "subscriptionId", "timeStamp", "vnfPkgId", "vnfdId", "_links"],
+ "required": [
+ "id",
+ "notificationType",
+ "subscriptionId",
+ "timeStamp",
+ "vnfPkgId",
+ "vnfdId",
+ "_links"
+ ],
"type": "object",
"properties": {
"id": {
@@ -195,7 +242,9 @@
"title": "Notificationtype",
"description": "Discriminator for the different notification types.",
"type": "string",
- "enum": ["VnfPackageOnboardingNotification"]
+ "enum": [
+ "VnfPackageOnboardingNotification"
+ ]
},
"subscriptionId": {
"title": "Subscriptionid",
@@ -213,13 +262,13 @@
"title": "Vnfpkgid",
"description": "Identifier of the VNF package.",
"type": "string",
- "format": "uuid"
+ "minLength": 1
},
"vnfdId": {
"title": "Vnfdid",
"description": "This identifier, which is managed by the VNF provider, identifies the VNF package and the VNFD in a globally unique way.",
"type": "string",
- "format": "uuid"
+ "minLength": 1
},
"_links": {
"$ref": "#/definitions/PkgmLinks"
@@ -227,4 +276,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json
new file mode 100644
index 0000000000..32e002f0e7
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json
@@ -0,0 +1,1778 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "version": "1.2.0-impl:etsi.org:ETSI_NFV_OpenAPI:1",
+ "title": "SOL003 - VNF Package Management Notification interface",
+ "description": "SOL003 - VNF Package Management Notification interface\n\nIMPORTANT: Please note that this file might be not aligned to the current version of the ETSI Group Specification it refers to. In case of discrepancies the published ETSI Group Specification takes precedence.\n\nIn clause 4.3.2 of ETSI GS NFV-SOL 003 v2.4.1, an attribute-based filtering mechanism is defined. This mechanism is currently not included in the corresponding OpenAPI design for this GS version. Changes to the attribute-based filtering mechanism are being considered in v2.5.1 of this GS for inclusion in the corresponding future ETSI NFV OpenAPI design.\nPlease report bugs to https://forge.etsi.org/bugzilla/buglist.cgi?component=Nfv-Openapis&list_id=61&product=NFV&resolution=\n",
+ "license": {
+ "name": "ETSI Forge copyright notice",
+ "url": "https://forge.etsi.org/etsi-forge-copyright-notice.txt"
+ }
+ },
+ "externalDocs": {
+ "description": "ETSI GS NFV-SOL 003 V2.5.1",
+ "url": "https://www.etsi.org/deliver/etsi_gs/NFV-SOL/001_099/003/02.05.01_60/gs_nfv-sol003v020501p.pdf"
+ },
+ "basePath": "/callback/v1",
+ "schemes": ["https"],
+ "consumes": ["application/json"],
+ "produces": ["application/json"],
+ "paths": {
+ "/URI-is-provided-by-the-client-when-creating-the-subscription-VnfPackageOnboardingNotification": {
+ "post": {
+ "description": "Notify\n\nThe POST method delivers a notification from the server to the client.\n",
+ "parameters": [{
+ "name": "VnfPackageOnboardingNotification",
+ "description": "A notification about on-boarding of a VNF package.",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "description": "This type represents a VNF package management notification, which informs the receiver that the onboarding process of a VNF package is complete and the package is ready for use. The notification shall be triggered by the NFVO when the \"onboardingState\" attribute of a new VNF package has changed to \"ONBOARDED\".\n",
+ "type": "object",
+ "required": ["id", "notificationType", "subscriptionId", "timeStamp", "vnfPkgId", "vnfdId", "_links"],
+ "properties": {
+ "id": {
+ "description": "An identifier with the intention of being globally unique.\n",
+ "type": "string"
+ },
+ "notificationType": {
+ "description": "Discriminator for the different notification types. Shall be set to \"VnfPackageOnboardingNotification\" for this notification type.\n",
+ "type": "string",
+ "enum": ["VnfPackageOnboardingNotification"]
+ },
+ "subscriptionId": {
+ "description": "An identifier with the intention of being globally unique.\n",
+ "type": "string"
+ },
+ "timeStamp": {
+ "description": "Date-time stamp. Representation: String formatted according to IETF RFC 3339.\n",
+ "type": "string",
+ "format": "date-time"
+ },
+ "vnfPkgId": {
+ "description": "An identifier with the intention of being globally unique.\n",
+ "type": "string"
+ },
+ "vnfdId": {
+ "description": "An identifier with the intention of being globally unique.\n",
+ "type": "string"
+ },
+ "_links": {
+ "description": "This type represents the links to resources that a VNF package management notification can contain.\n",
+ "type": "object",
+ "required": ["vnfPackage", "subscription"],
+ "properties": {
+ "vnfPackage": {
+ "description": "This type represents a link to a resource in a notification, using an absolute or relative URI. It shall comply with the provisions defined in table 4.4.1.3a-1.\n",
+ "type": "object",
+ "required": ["href"],
+ "properties": {
+ "href": {
+ "description": "String formatted according to IETF RFC 3986.\n",
+ "type": "string"
+ }
+ }
+ },
+ "subscription": {
+ "description": "This type represents a link to a resource in a notification, using an absolute or relative URI. It shall comply with the provisions defined in table 4.4.1.3a-1.\n",
+ "type": "object",
+ "required": ["href"],
+ "properties": {
+ "href": {
+ "description": "String formatted according to IETF RFC 3986.\n",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }, {
+ "name": "Authorization",
+ "description": "The authorization token for the request. Reference: IETF RFC 7235\n",
+ "in": "header",
+ "required": false,
+ "type": "string"
+ }, {
+ "name": "Content-Type",
+ "description": "The MIME type of the body of the request. Reference: IETF RFC 7231\n",
+ "in": "header",
+ "required": true,
+ "type": "string"
+ }, {
+ "name": "Version",
+ "description": "Version of the API requested to use when responding to this request.\n",
+ "in": "header",
+ "required": true,
+ "type": "string"
+ }],
+ "responses": {
+ "204": {
+ "description": "204 NO CONTENT\nThe notification was delivered successfully.\n",
+ "headers": {
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ }
+ },
+ "400": {
+ "description": "400 BAD REQUEST\n400 code can be returned in the following specified cases, the specific cause has to be proper specified in the \"ProblemDetails\" structure to be returned.\nIf the request is malformed or syntactically incorrect (e.g. if the request URI contains incorrect query parameters or the payload body contains a syntactically incorrect data structure), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and should include in the \"detail\" attribute more information about the source of the problem.\nIf the response to a GET request which queries a container resource would be so big that the performance of the API producer is adversely affected, and the API producer does not support paging for the affected resource, it shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and should include in the \"detail\" attribute more information about the source of the problem.\nIf there is an application error related to the client's input that cannot be easily mapped to any other HTTP response code (\"catch all error\"), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and shall include in the \"detail\" attribute more information about the source of the problem.\nIf the request contains a malformed access token, the API producer should respond with this response. The details of the error shall be returned in the WWW Authenticate HTTP header, as defined in IETF RFC 6750 and IETF RFC 7235. The ProblemDetails structure may be provided.\nThe use of this HTTP error response code described above is applicable to the use of the OAuth 2.0 for the authorization of API requests and notifications, as defined in clauses 4.5.3.3 and 4.5.3.4.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "401 UNAUTHORIZED\nIf the request contains no access token even though one is required, or if the request contains an authorization token that is invalid (e.g. expired or revoked), the API producer should respond with this response. The details of the error shall be returned in the WWW-Authenticate HTTP header, as defined in IETF RFC 6750 and IETF RFC 7235. The ProblemDetails structure may be provided.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "403 FORBIDDEN\nIf the API consumer is not allowed to perform a particular request to a particular resource, the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided. It should include in the \"detail\" attribute information about the source of the problem, and may indicate how to solve it.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "404 NOT FOUND\nIf the API producer did not find a current representation for the resource addressed by the URI passed in the request or is not willing to disclose that one exists, it shall respond with this response code. The \"ProblemDetails\" structure may be provided, including in the \"detail\" attribute information about the source of the problem, e.g. a wrong resource URI variable.\nThis response code is not appropriate in case the resource addressed by the URI is a container resource which is designed to contain child resources, but does not contain any child resource at the time the request is received. For a GET request to an existing empty container resource, a typical response contains a 200 OK response code and a payload body with an empty array.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "406": {
+ "description": "406 NOT ACCEPTABLE\nIf the \"Accept\" header does not contain at least one name of a content type that is acceptable to the API producer, the API producer shall respond with this response code. The \"ProblemDetails\" structure may be omitted.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "500 INTERNAL SERVER ERROR\nIf there is an application error not related to the client's input that cannot be easily mapped to any other HTTP response code (\"catch all error\"), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and shall include in the \"detail\" attribute more information about the source of the problem.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "503": {
+ "description": "503 SERVICE UNAVAILABLE\nIf the API producer encounters an internal overload situation of itself or of a system it relies on, it should respond with this response code, following the provisions in IETF RFC 7231 for the use of the \"Retry-After\" HTTP header and for the alternative to refuse the connection. The \"ProblemDetails\" structure may be omitted.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ }
+ }
+ },
+ "get": {
+ "description": "The GET method allows the server to test the notification endpoint that is provided by the client, e.g. during subscription.\n",
+ "parameters": [{
+ "name": "Authorization",
+ "description": "The authorization token for the request. Reference: IETF RFC 7235\n",
+ "in": "header",
+ "required": false,
+ "type": "string"
+ }, {
+ "name": "Version",
+ "description": "Version of the API requested to use when responding to this request.\n",
+ "in": "header",
+ "required": true,
+ "type": "string"
+ }],
+ "responses": {
+ "204": {
+ "description": "204 NO CONTENT\nThe notification endpoint was tested successfully. The response body shall be empty.\n",
+ "headers": {
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ }
+ },
+ "400": {
+ "description": "400 BAD REQUEST\n400 code can be returned in the following specified cases, the specific cause has to be proper specified in the \"ProblemDetails\" structure to be returned.\nIf the request is malformed or syntactically incorrect (e.g. if the request URI contains incorrect query parameters or the payload body contains a syntactically incorrect data structure), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and should include in the \"detail\" attribute more information about the source of the problem.\nIf the response to a GET request which queries a container resource would be so big that the performance of the API producer is adversely affected, and the API producer does not support paging for the affected resource, it shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and should include in the \"detail\" attribute more information about the source of the problem.\nIf there is an application error related to the client's input that cannot be easily mapped to any other HTTP response code (\"catch all error\"), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and shall include in the \"detail\" attribute more information about the source of the problem.\nIf the request contains a malformed access token, the API producer should respond with this response. The details of the error shall be returned in the WWW Authenticate HTTP header, as defined in IETF RFC 6750 and IETF RFC 7235. The ProblemDetails structure may be provided.\nThe use of this HTTP error response code described above is applicable to the use of the OAuth 2.0 for the authorization of API requests and notifications, as defined in clauses 4.5.3.3 and 4.5.3.4.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "401 UNAUTHORIZED\nIf the request contains no access token even though one is required, or if the request contains an authorization token that is invalid (e.g. expired or revoked), the API producer should respond with this response. The details of the error shall be returned in the WWW-Authenticate HTTP header, as defined in IETF RFC 6750 and IETF RFC 7235. The ProblemDetails structure may be provided.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "403 FORBIDDEN\nIf the API consumer is not allowed to perform a particular request to a particular resource, the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided. It should include in the \"detail\" attribute information about the source of the problem, and may indicate how to solve it.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "404 NOT FOUND\nIf the API producer did not find a current representation for the resource addressed by the URI passed in the request or is not willing to disclose that one exists, it shall respond with this response code. The \"ProblemDetails\" structure may be provided, including in the \"detail\" attribute information about the source of the problem, e.g. a wrong resource URI variable.\nThis response code is not appropriate in case the resource addressed by the URI is a container resource which is designed to contain child resources, but does not contain any child resource at the time the request is received. For a GET request to an existing empty container resource, a typical response contains a 200 OK response code and a payload body with an empty array.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "406": {
+ "description": "406 NOT ACCEPTABLE\nIf the \"Accept\" header does not contain at least one name of a content type that is acceptable to the API producer, the API producer shall respond with this response code. The \"ProblemDetails\" structure may be omitted.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "500 INTERNAL SERVER ERROR\nIf there is an application error not related to the client's input that cannot be easily mapped to any other HTTP response code (\"catch all error\"), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and shall include in the \"detail\" attribute more information about the source of the problem.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "503": {
+ "description": "503 SERVICE UNAVAILABLE\nIf the API producer encounters an internal overload situation of itself or of a system it relies on, it should respond with this response code, following the provisions in IETF RFC 7231 for the use of the \"Retry-After\" HTTP header and for the alternative to refuse the connection. The \"ProblemDetails\" structure may be omitted.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/URI-is-provided-by-the-client-when-creating-the-subscription-VnfPackageChangeNotification": {
+ "post": {
+ "description": "Notify\n\nThe POST method delivers a notification from the server to the client.\n",
+ "parameters": [{
+ "name": "VnfPackageChangeNotification",
+ "description": "A notification about changes of status in a VNF package.\n",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "description": "This type represents a VNF package management notification, which informs the receiver of a change of the status in an on-boarded VNF package. Only changes in the \"operationalState\" attribute of an on-boarded VNF package and the deletion NF package will be reported. Changes in the \"usageState\" and \"onboardingState\" attributes are not reported. The notification shall be triggered by the NFVO when there is a change in the status of an onboarded VNF package, as follows: * The \"operationalState\" attribute of a VNF package has changed, and the \"onboardingState\" attribute of the package has the value \"ONBOARDED\"\n (i.e. the package has been onboarded previously).\n* The on-boarded VNF package has been deleted.\n",
+ "type": "object",
+ "required": ["id", "notificationType", "subscriptionId", "timeStamp", "vnfPkgId", "vnfdId", "changeType", "_links"],
+ "properties": {
+ "id": {
+ "description": "An identifier with the intention of being globally unique.\n",
+ "type": "string"
+ },
+ "notificationType": {
+ "description": "Discriminator for the different notification types. Shall be set to \"VnfPackageChangeNotification\" for this notification type.\n",
+ "type": "string",
+ "enum": ["VnfPackageChangeNotification"]
+ },
+ "subscriptionId": {
+ "description": "An identifier with the intention of being globally unique.\n",
+ "type": "string"
+ },
+ "timeStamp": {
+ "description": "Date-time stamp. Representation: String formatted according to IETF RFC 3339.\n",
+ "type": "string",
+ "format": "date-time"
+ },
+ "vnfPkgId": {
+ "description": "An identifier with the intention of being globally unique.\n",
+ "type": "string"
+ },
+ "vnfdId": {
+ "description": "An identifier with the intention of being globally unique.\n",
+ "type": "string"
+ },
+ "changeType": {
+ "description": "- OP_STATE_CHANGE: The \"operationalState\" attribute has been changed. - PKG_DELETE: The VNF package has been deleted.\n",
+ "type": "string",
+ "enum": ["OP_STATE_CHANGE", "PKG_DELETE"]
+ },
+ "operationalState": {
+ "description": "- ENABLED: The VNF package is enabled, i.e. it can be used for instantiation of new VNF instances.\n- DISABLED: The VNF package is disabled, i.e. it cannot be used for further VNF instantiation requests (unless and until the VNF package\n is re-enabled).\n",
+ "type": "string",
+ "enum": ["ENABLED", "DISABLED"]
+ },
+ "_links": {
+ "description": "This type represents the links to resources that a VNF package management notification can contain.\n",
+ "type": "object",
+ "required": ["vnfPackage", "subscription"],
+ "properties": {
+ "vnfPackage": {
+ "description": "This type represents a link to a resource in a notification, using an absolute or relative URI. It shall comply with the provisions defined in table 4.4.1.3a-1.\n",
+ "type": "object",
+ "required": ["href"],
+ "properties": {
+ "href": {
+ "description": "String formatted according to IETF RFC 3986.\n",
+ "type": "string"
+ }
+ }
+ },
+ "subscription": {
+ "description": "This type represents a link to a resource in a notification, using an absolute or relative URI. It shall comply with the provisions defined in table 4.4.1.3a-1.\n",
+ "type": "object",
+ "required": ["href"],
+ "properties": {
+ "href": {
+ "description": "String formatted according to IETF RFC 3986.\n",
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }, {
+ "name": "Authorization",
+ "description": "The authorization token for the request. Reference: IETF RFC 7235\n",
+ "in": "header",
+ "required": false,
+ "type": "string"
+ }, {
+ "name": "Content-Type",
+ "description": "The MIME type of the body of the request. Reference: IETF RFC 7231\n",
+ "in": "header",
+ "required": true,
+ "type": "string"
+ }, {
+ "name": "Version",
+ "description": "Version of the API requested to use when responding to this request.\n",
+ "in": "header",
+ "required": true,
+ "type": "string"
+ }],
+ "responses": {
+ "204": {
+ "description": "204 NO CONTENT\nThe notification was delivered successfully.\n",
+ "headers": {
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ }
+ },
+ "400": {
+ "description": "400 BAD REQUEST\n400 code can be returned in the following specified cases, the specific cause has to be proper specified in the \"ProblemDetails\" structure to be returned.\nIf the request is malformed or syntactically incorrect (e.g. if the request URI contains incorrect query parameters or the payload body contains a syntactically incorrect data structure), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and should include in the \"detail\" attribute more information about the source of the problem.\nIf the response to a GET request which queries a container resource would be so big that the performance of the API producer is adversely affected, and the API producer does not support paging for the affected resource, it shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and should include in the \"detail\" attribute more information about the source of the problem.\nIf there is an application error related to the client's input that cannot be easily mapped to any other HTTP response code (\"catch all error\"), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and shall include in the \"detail\" attribute more information about the source of the problem.\nIf the request contains a malformed access token, the API producer should respond with this response. The details of the error shall be returned in the WWW Authenticate HTTP header, as defined in IETF RFC 6750 and IETF RFC 7235. The ProblemDetails structure may be provided.\nThe use of this HTTP error response code described above is applicable to the use of the OAuth 2.0 for the authorization of API requests and notifications, as defined in clauses 4.5.3.3 and 4.5.3.4.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "401 UNAUTHORIZED\nIf the request contains no access token even though one is required, or if the request contains an authorization token that is invalid (e.g. expired or revoked), the API producer should respond with this response. The details of the error shall be returned in the WWW-Authenticate HTTP header, as defined in IETF RFC 6750 and IETF RFC 7235. The ProblemDetails structure may be provided.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "403 FORBIDDEN\nIf the API consumer is not allowed to perform a particular request to a particular resource, the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided. It should include in the \"detail\" attribute information about the source of the problem, and may indicate how to solve it.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "404 NOT FOUND\nIf the API producer did not find a current representation for the resource addressed by the URI passed in the request or is not willing to disclose that one exists, it shall respond with this response code. The \"ProblemDetails\" structure may be provided, including in the \"detail\" attribute information about the source of the problem, e.g. a wrong resource URI variable.\nThis response code is not appropriate in case the resource addressed by the URI is a container resource which is designed to contain child resources, but does not contain any child resource at the time the request is received. For a GET request to an existing empty container resource, a typical response contains a 200 OK response code and a payload body with an empty array.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "406": {
+ "description": "406 NOT ACCEPTABLE\nIf the \"Accept\" header does not contain at least one name of a content type that is acceptable to the API producer, the API producer shall respond with this response code. The \"ProblemDetails\" structure may be omitted.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "500 INTERNAL SERVER ERROR\nIf there is an application error not related to the client's input that cannot be easily mapped to any other HTTP response code (\"catch all error\"), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and shall include in the \"detail\" attribute more information about the source of the problem.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "503": {
+ "description": "503 SERVICE UNAVAILABLE\nIf the API producer encounters an internal overload situation of itself or of a system it relies on, it should respond with this response code, following the provisions in IETF RFC 7231 for the use of the \"Retry-After\" HTTP header and for the alternative to refuse the connection. The \"ProblemDetails\" structure may be omitted.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ }
+ }
+ },
+ "get": {
+ "description": "The GET method allows the server to test the notification endpoint that is provided by the client, e.g. during subscription.\n",
+ "parameters": [{
+ "name": "Authorization",
+ "description": "The authorization token for the request. Reference: IETF RFC 7235\n",
+ "in": "header",
+ "required": false,
+ "type": "string"
+ }, {
+ "name": "Version",
+ "description": "Version of the API requested to use when responding to this request.\n",
+ "in": "header",
+ "required": true,
+ "type": "string"
+ }],
+ "responses": {
+ "204": {
+ "description": "204 NO CONTENT\nThe notification endpoint was tested successfully. The response body shall be empty.\n",
+ "headers": {
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ }
+ },
+ "400": {
+ "description": "400 BAD REQUEST\n400 code can be returned in the following specified cases, the specific cause has to be proper specified in the \"ProblemDetails\" structure to be returned.\nIf the request is malformed or syntactically incorrect (e.g. if the request URI contains incorrect query parameters or the payload body contains a syntactically incorrect data structure), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and should include in the \"detail\" attribute more information about the source of the problem.\nIf the response to a GET request which queries a container resource would be so big that the performance of the API producer is adversely affected, and the API producer does not support paging for the affected resource, it shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and should include in the \"detail\" attribute more information about the source of the problem.\nIf there is an application error related to the client's input that cannot be easily mapped to any other HTTP response code (\"catch all error\"), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and shall include in the \"detail\" attribute more information about the source of the problem.\nIf the request contains a malformed access token, the API producer should respond with this response. The details of the error shall be returned in the WWW Authenticate HTTP header, as defined in IETF RFC 6750 and IETF RFC 7235. The ProblemDetails structure may be provided.\nThe use of this HTTP error response code described above is applicable to the use of the OAuth 2.0 for the authorization of API requests and notifications, as defined in clauses 4.5.3.3 and 4.5.3.4.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "401 UNAUTHORIZED\nIf the request contains no access token even though one is required, or if the request contains an authorization token that is invalid (e.g. expired or revoked), the API producer should respond with this response. The details of the error shall be returned in the WWW-Authenticate HTTP header, as defined in IETF RFC 6750 and IETF RFC 7235. The ProblemDetails structure may be provided.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "403 FORBIDDEN\nIf the API consumer is not allowed to perform a particular request to a particular resource, the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided. It should include in the \"detail\" attribute information about the source of the problem, and may indicate how to solve it.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "404 NOT FOUND\nIf the API producer did not find a current representation for the resource addressed by the URI passed in the request or is not willing to disclose that one exists, it shall respond with this response code. The \"ProblemDetails\" structure may be provided, including in the \"detail\" attribute information about the source of the problem, e.g. a wrong resource URI variable.\nThis response code is not appropriate in case the resource addressed by the URI is a container resource which is designed to contain child resources, but does not contain any child resource at the time the request is received. For a GET request to an existing empty container resource, a typical response contains a 200 OK response code and a payload body with an empty array.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "406": {
+ "description": "406 NOT ACCEPTABLE\nIf the \"Accept\" header does not contain at least one name of a content type that is acceptable to the API producer, the API producer shall respond with this response code. The \"ProblemDetails\" structure may be omitted.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "500": {
+ "description": "500 INTERNAL SERVER ERROR\nIf there is an application error not related to the client's input that cannot be easily mapped to any other HTTP response code (\"catch all error\"), the API producer shall respond with this response code. The \"ProblemDetails\" structure shall be provided, and shall include in the \"detail\" attribute more information about the source of the problem.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ },
+ "503": {
+ "description": "503 SERVICE UNAVAILABLE\nIf the API producer encounters an internal overload situation of itself or of a system it relies on, it should respond with this response code, following the provisions in IETF RFC 7231 for the use of the \"Retry-After\" HTTP header and for the alternative to refuse the connection. The \"ProblemDetails\" structure may be omitted.\n",
+ "headers": {
+ "Content-Type": {
+ "description": "The MIME type of the body of the response.",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ },
+ "WWW-Authenticate": {
+ "description": "Challenge if the corresponding HTTP request has not provided authorization, or error details if the corresponding HTTP request has provided an invalid authorization token.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 0
+ },
+ "Version": {
+ "description": "Version of the API used in the response.\n",
+ "type": "string",
+ "maximum": 1,
+ "minimum": 1
+ }
+ },
+ "schema": {
+ "description": "The definition of the general \"ProblemDetails\" data structure from IETF RFC 7807 [19] is reproduced inthis structure. Compared to the general framework defined in IETF RFC 7807 [19], the \"status\" and \"detail\" attributes are mandated to be included by the present document, to ensure that the response contains additional textual information about an error. IETF RFC 7807 [19] foresees extensibility of the \"ProblemDetails\" type. It is possible that particular APIs in the present document, or particular implementations, define extensions to define additional attributes that provide more information about the error. The description column only provides some explanation of the meaning to Facilitate understanding of the design. For a full description, see IETF RFC 7807 [19].\n",
+ "type": "object",
+ "required": ["status", "detail"],
+ "properties": {
+ "type": {
+ "description": "A URI reference according to IETF RFC 3986 [5] that identifies the problem type. It is encouraged that the URI provides human-readable documentation for the problem (e.g. using HTML) when dereferenced. When this member is not present, its value is assumed to be \"about:blank\".\n",
+ "type": "string",
+ "format": "URI"
+ },
+ "title": {
+ "description": "A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization. If type is given and other than \"about:blank\", this attribute shall also be provided. A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).\n",
+ "type": "string"
+ },
+ "status": {
+ "description": "The HTTP status code for this occurrence of the problem. The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem.\n",
+ "type": "integer"
+ },
+ "detail": {
+ "description": "A human-readable explanation specific to this occurrence of the problem.\n",
+ "type": "string"
+ },
+ "instance": {
+ "description": "A URI reference that identifies the specific occurrence of the problem. It may yield further information if dereferenced.\n",
+ "type": "string",
+ "format": "URI"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
index fb32fb9605..d798267918 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java
@@ -32,8 +32,12 @@ public class Constants {
public static final String SERVICE_VERSION = "v1";
public static final String BASE_URL = "/so/" + SERVICE_NAME + "/" + SERVICE_VERSION;
public static final String PACKAGE_MANAGEMENT_BASE_URL = BASE_URL + "/vnfpkgm/v1";
- public static final String ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL = BASE_URL + "/etsicatalogmanager/notification";
- public static final String ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL = BASE_URL + "/etsicatalogmanager";
+ public static final String ETSI_CATALOG_MANAGER_BASE_ENDPOINT = "/etsicatalogmanager";
+ public static final String ETSI_SUBSCRIPTION_NOTIFICATION_ENDPOINT = "/notification";
+ public static final String ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL =
+ BASE_URL + ETSI_CATALOG_MANAGER_BASE_ENDPOINT;
+ public static final String ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL =
+ ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL + ETSI_SUBSCRIPTION_NOTIFICATION_ENDPOINT;
public static final String APPLICATION_ZIP = "application/zip";
public static final String OPERATION_NOTIFICATION_ENDPOINT = "/lcn/VnfLcmOperationOccurrenceNotification";
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
index 61d5adf9d8..87e8bb4d57 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
@@ -23,6 +23,8 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.ArrayList;
import java.util.Collection;
+import org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003.PkgChangeNotificationConverter;
+import org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003.PkgOnboardingNotificationConverter;
import org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003.VnfPkgInfoConverter;
import org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog.PkgmSubscriptionRequestConverter;
import org.onap.so.adapters.vnfmadapter.oauth.OAuth2AccessTokenAdapter;
@@ -46,6 +48,8 @@ public class MessageConverterConfiguration {
final DefaultConversionService service = new DefaultConversionService();
service.addConverter(new VnfPkgInfoConverter());
service.addConverter(new PkgmSubscriptionRequestConverter());
+ service.addConverter(new PkgChangeNotificationConverter());
+ service.addConverter(new PkgOnboardingNotificationConverter());
return service;
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java
index a5404607b4..f1815054e3 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,34 +22,40 @@
package org.onap.so.adapters.vnfmadapter;
-import org.onap.so.security.SoBasicWebSecurityConfigurerAdapter;
+import org.onap.so.security.HttpSecurityConfigurer;
import org.onap.so.security.SoUserCredentialConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
/**
* @author Waqas Ikram (waqas.ikram@est.tech)
* @author Gareth Roper (gareth.roper@est.tech)
- *
*/
-@EnableWebSecurity
-@Configuration
-public class VnfmBasicWebSecurityConfigurerAdapter extends SoBasicWebSecurityConfigurerAdapter {
+@Primary
+@Component
+public class VnfmBasicHttpSecurityConfigurer implements HttpSecurityConfigurer {
+
+ @Autowired
+ private SoUserCredentialConfiguration soUserCredentialConfiguration;
@Value("${server.ssl.client-auth:none}")
private String clientAuth;
- SoUserCredentialConfiguration soUserCredentialConfiguration;
@Override
- protected void configure(final HttpSecurity http) throws Exception {
+ public void configure(final HttpSecurity http) throws Exception {
if (("need").equalsIgnoreCase(clientAuth)) {
http.csrf().disable().authorizeRequests().anyRequest().permitAll();
} else {
- super.configure(http);
- http.authorizeRequests().antMatchers(HttpMethod.GET, "/etsi/subscription/notification").permitAll();
+ http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
+ .antMatchers(HttpMethod.GET, Constants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL).permitAll()
+ .antMatchers("/**")
+ .hasAnyRole(StringUtils.collectionToDelimitedString(soUserCredentialConfiguration.getRoles(), ","))
+ .and().httpBasic();
}
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/AbstractPkgNotificationConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/AbstractPkgNotificationConverter.java
new file mode 100644
index 0000000000..e1c43098f8
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/AbstractPkgNotificationConverter.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003;
+
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgmLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinksVnfPackage;
+
+/**
+ * A base class that can be extended by classes for converting Etsi Catalog Manager Pkg Notification classes. Provides
+ * common methods that will be useful to those classes.
+ *
+ * @author andrew.a.lamb@est.tech
+ */
+abstract public class AbstractPkgNotificationConverter {
+
+ protected URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinks convert(
+ final PkgmLinks pkgmLinks) {
+ final URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinksVnfPackage linksVnfPackage =
+ new URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinksVnfPackage();
+ if (pkgmLinks.getVnfPackage() != null) {
+ linksVnfPackage.setHref(pkgmLinks.getVnfPackage().getHref());
+ }
+
+ final URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinksVnfPackage linksSubscription =
+ new URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinksVnfPackage();
+ if (pkgmLinks.getSubscription() != null) {
+ linksSubscription.setHref(pkgmLinks.getSubscription().getHref());
+ }
+
+ final URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinks links =
+ new URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinks();
+ links.setVnfPackage(linksVnfPackage);
+ links.setSubscription(linksSubscription);
+ return links;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgChangeNotificationConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgChangeNotificationConverter.java
new file mode 100644
index 0000000000..8c4168632b
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgChangeNotificationConverter.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgChangeNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageChangeNotification;
+import org.slf4j.Logger;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Service;
+
+/**
+ * Converter to convert from an Etsi Catalog Manager {@link PkgChangeNotification} Object to its equivalent SOL003
+ * {@link VnfPackageChangeNotification} Object
+ *
+ * @author andrew.a.lamb@est.tech
+ */
+@Service
+public class PkgChangeNotificationConverter extends AbstractPkgNotificationConverter
+ implements Converter<PkgChangeNotification, VnfPackageChangeNotification> {
+ private static final Logger logger = getLogger(PkgChangeNotificationConverter.class);
+
+ /**
+ * Convert a {@link PkgChangeNotification} Object to an {@link VnfPackageChangeNotification} Object
+ *
+ * @param pkgChangeNotification The PkgChangeNotification Object to Convert
+ * @return The Converted VnfPackageChangeNotification Object
+ */
+ @Override
+ public VnfPackageChangeNotification convert(final PkgChangeNotification pkgChangeNotification) {
+ logger.info("Converting PkgChangeNotification\n{}", pkgChangeNotification.toString());
+ final VnfPackageChangeNotification vnfPackageChangeNotification = new VnfPackageChangeNotification();
+ vnfPackageChangeNotification.setId(pkgChangeNotification.getId());
+
+ if (pkgChangeNotification.getNotificationType() != null) {
+ vnfPackageChangeNotification.setNotificationType(VnfPackageChangeNotification.NotificationTypeEnum
+ .fromValue(pkgChangeNotification.getNotificationType().getValue()));
+ }
+
+ vnfPackageChangeNotification.setSubscriptionId(pkgChangeNotification.getSubscriptionId());
+ vnfPackageChangeNotification.setTimeStamp(pkgChangeNotification.getTimeStamp());
+ vnfPackageChangeNotification.setVnfPkgId(pkgChangeNotification.getVnfPkgId());
+
+ vnfPackageChangeNotification.setVnfdId(pkgChangeNotification.getVnfdId());
+
+ if (pkgChangeNotification.getChangeType() != null) {
+ vnfPackageChangeNotification.setChangeType(VnfPackageChangeNotification.ChangeTypeEnum
+ .fromValue(pkgChangeNotification.getChangeType().getValue()));
+ }
+
+ if (pkgChangeNotification.getOperationalState() != null) {
+ vnfPackageChangeNotification.setOperationalState(VnfPackageChangeNotification.OperationalStateEnum
+ .fromValue(pkgChangeNotification.getOperationalState().getValue()));
+ }
+
+ vnfPackageChangeNotification.setLinks(convert((pkgChangeNotification.getLinks())));
+
+ return vnfPackageChangeNotification;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgOnboardingNotificationConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgOnboardingNotificationConverter.java
new file mode 100644
index 0000000000..836acb6d36
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgOnboardingNotificationConverter.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgOnboardingNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification;
+import org.slf4j.Logger;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Service;
+
+/**
+ * Converter to convert from an Etsi Catalog Manager {@link PkgOnboardingNotification} Object to its equivalent SOL003
+ * {@link VnfPackageOnboardingNotification} Object
+ *
+ * @author andrew.a.lamb@est.tech
+ */
+@Service
+public class PkgOnboardingNotificationConverter extends AbstractPkgNotificationConverter
+ implements Converter<PkgOnboardingNotification, VnfPackageOnboardingNotification> {
+ private static final Logger logger = getLogger(PkgOnboardingNotificationConverter.class);
+
+ /**
+ * Convert a {@link PkgOnboardingNotification} Object to an {@link VnfPackageOnboardingNotification} Object
+ *
+ * @param pkgOnboardingNotification The PkgOnboardingNotification Object to Convert
+ * @return The Converted VnfPackageOnboardingNotification Object
+ */
+ @Override
+ public VnfPackageOnboardingNotification convert(final PkgOnboardingNotification pkgOnboardingNotification) {
+ logger.info("Converting PkgChangeNotification\n{}", pkgOnboardingNotification.toString());
+ final VnfPackageOnboardingNotification vnfPackageOnboardingNotification =
+ new VnfPackageOnboardingNotification();
+ vnfPackageOnboardingNotification.setId(pkgOnboardingNotification.getId());
+
+ if (pkgOnboardingNotification.getNotificationType() != null) {
+ vnfPackageOnboardingNotification.setNotificationType(VnfPackageOnboardingNotification.NotificationTypeEnum
+ .fromValue(pkgOnboardingNotification.getNotificationType().getValue()));
+ }
+
+ vnfPackageOnboardingNotification.setSubscriptionId(pkgOnboardingNotification.getSubscriptionId());
+ vnfPackageOnboardingNotification.setTimeStamp(pkgOnboardingNotification.getTimeStamp());
+ vnfPackageOnboardingNotification.setVnfPkgId(pkgOnboardingNotification.getVnfPkgId());
+ vnfPackageOnboardingNotification.setVnfdId(pkgOnboardingNotification.getVnfdId());
+
+ vnfPackageOnboardingNotification.setLinks(convert((pkgOnboardingNotification.getLinks())));
+
+ return vnfPackageOnboardingNotification;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java
index c6d51c99aa..d0fd4c9e7c 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java
@@ -20,14 +20,10 @@
package org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog;
-import static org.slf4j.LoggerFactory.getLogger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Optional;
-import java.util.UUID;
-import javax.swing.text.html.Option;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders;
@@ -38,7 +34,6 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVersions;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProducts;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders;
-import org.slf4j.Logger;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Service;
@@ -48,14 +43,11 @@ import org.springframework.stereotype.Service;
*
* @author Ronan Kenny (ronan.kenny@est.tech)
* @author Gareth Roper (gareth.roper@est.tech)
- *
*/
@Service
public class PkgmSubscriptionRequestConverter implements
Converter<PkgmSubscriptionRequest, org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest> {
- private static final Logger logger = getLogger(PkgmSubscriptionRequestConverter.class);
-
@Override
public org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest convert(
PkgmSubscriptionRequest pkgmSubscriptionRequest) {
@@ -133,7 +125,8 @@ public class PkgmSubscriptionRequestConverter implements
final List<VnfProductsProviders> etsiCatalogManagerVnfProductsProviders = new ArrayList<>();
filterProductsFromProvider.forEach(vnfProduct -> {
etsiCatalogManagerVnfProductsProviders
- .add(new VnfProductsProviders().vnfProducts(getVnfProducts(vnfProduct.getVnfProducts())));
+ .add(new VnfProductsProviders().vnfProvider(vnfProduct.getVnfProvider())
+ .vnfProducts(getVnfProducts(vnfProduct.getVnfProducts())));
});
return etsiCatalogManagerVnfProductsProviders;
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
index 62b365745c..0dcc49eeac 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
@@ -21,9 +21,9 @@
package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
import java.util.Optional;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
-import org.springframework.http.ResponseEntity;
/**
* Provides methods for invoking REST calls to the ETSI Catalog Manager.
@@ -74,11 +74,26 @@ public interface EtsiCatalogServiceProvider {
Optional<byte[]> getVnfPackageArtifact(final String vnfPkgId, final String artifactPath);
/**
- * Post the SubscriptionRequest Object.
+ * POST the SubscriptionRequest Object.
*
- * @return The ResponseEntity containing the ETSI Catalog Manager's PkgmSubscription object.
+ * @return The ETSI Catalog Manager's PkgmSubscription object.
*/
Optional<PkgmSubscription> postSubscription(
final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest);
+ /**
+ * Get the Subscription from ETSI Catalog.
+ *
+ * @param subscriptionId Subscription ID
+ * @return The Subscription {@link NsdmSubscription} from ETSI Catalog
+ */
+ Optional<NsdmSubscription> getSubscription(final String subscriptionId);
+
+ /**
+ * DELETE the SubscriptionRequest Object.
+ *
+ * @return A Boolean representing if the delete was successful or not.
+ */
+ boolean deleteSubscription(final String subscriptionId);
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
index 1a48494e1a..30d084629c 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
@@ -21,11 +21,16 @@
package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
import java.util.Optional;
-import javax.swing.text.html.Option;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.*;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.EtsiCatalogManagerBadRequestException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.EtsiCatalogManagerRequestFailureException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgBadRequestException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgConflictException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgNotFoundException;
import org.onap.so.rest.exceptions.HttpResouceNotFoundException;
import org.onap.so.rest.exceptions.InvalidRestRequestException;
import org.onap.so.rest.exceptions.RestProcessingException;
@@ -76,7 +81,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
etsiCatalogUrlProvider.getVnfPackageArtifactUrl(vnfPkgId, artifactPath), byte[].class);
logger.info("getVnfPackageArtifact Request to ETSI Catalog Manager Status Code: {}",
response.getStatusCodeValue());
- if (response.getStatusCode() == HttpStatus.OK) {
+ if (response.getStatusCode().is2xxSuccessful()) {
return Optional.ofNullable(response.getBody());
}
} catch (final HttpResouceNotFoundException httpResouceNotFoundException) {
@@ -101,7 +106,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
httpServiceProvider.getHttpResponse(etsiCatalogUrlProvider.getVnfPackagesUrl(), VnfPkgInfo[].class);
logger.info("getVnfPackages Request to ETSI Catalog Manager Status Code: {}",
response.getStatusCodeValue());
- if (response.getStatusCode() == HttpStatus.OK) {
+ if (response.getStatusCode().is2xxSuccessful()) {
if (response.hasBody()) {
final VnfPkgInfo[] vnfPackages = response.getBody();
assert (vnfPackages != null);
@@ -142,7 +147,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
.getHttpResponse(etsiCatalogUrlProvider.getVnfPackageUrl(vnfPkgId), VnfPkgInfo.class);
logger.info("getVnfPackage Request for vnfPkgId {} to ETSI Catalog Manager Status Code: {}", vnfPkgId,
response.getStatusCodeValue());
- if (response.getStatusCode() == HttpStatus.OK) {
+ if (response.getStatusCode().is2xxSuccessful()) {
if (response.hasBody()) {
final VnfPkgInfo vnfPkgInfo = response.getBody();
if (conversionService.canConvert(vnfPkgInfo.getClass(), InlineResponse2001.class)) {
@@ -180,7 +185,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
final ResponseEntity<PkgmSubscription> responseEntity =
httpServiceProvider.postHttpRequest(etsiCatalogManagerSubscriptionRequest,
etsiCatalogUrlProvider.getSubscriptionUrl(), PkgmSubscription.class);
- if (responseEntity.getStatusCode() == HttpStatus.OK) {
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
if (responseEntity.hasBody()) {
return Optional.of(responseEntity.getBody());
}
@@ -190,7 +195,8 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
return Optional.empty();
} catch (final InvalidRestRequestException invalidRestRequestException) {
logger.error("Caught InvalidRestRequestException", invalidRestRequestException);
- throw new EtsiCatalogManagerBadRequestException("Bad Request Received on postSubscription call.");
+ throw new EtsiCatalogManagerBadRequestException(
+ "Bad Request Received on postSubscription call to ETSI Catalog Manager.");
} catch (final RestProcessingException restProcessingException) {
logger.error("Caught RestProcessingException with Status Code: {}", restProcessingException.getStatusCode(),
restProcessingException);
@@ -200,6 +206,53 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
}
}
+ @Override
+ public boolean deleteSubscription(final String subscriptionId) {
+ try {
+ final ResponseEntity<Void> responseEntity = httpServiceProvider
+ .deleteHttpRequest(etsiCatalogUrlProvider.getSubscriptionUrl() + "/" + subscriptionId, Void.class);
+
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
+ logger.info("Subscription with ID: {} has been successfully deleted from the ETSI Catalog Manager",
+ subscriptionId);
+ return true;
+ }
+ logger.error("Unexpected Status Code Received on deleteSubscription: {}", responseEntity.getStatusCode());
+ return false;
+ } catch (final HttpResouceNotFoundException resouceNotFoundException) {
+ final String message = "Unable to find subscription in ETSI Catalog Manager using id: " + subscriptionId;
+ logger.error(message);
+ throw new SubscriptionNotFoundException(message);
+ } catch (final InvalidRestRequestException invalidRestRequestException) {
+ logger.error("Caught InvalidRestRequestException on deleteSubscription call to ETSI Catalog Manager.",
+ invalidRestRequestException);
+ throw new EtsiCatalogManagerBadRequestException(
+ "Bad Request Received on deleteSubscription call to ETSI Catalog Manager.");
+ }
+ }
+
+ @Override
+ public Optional<NsdmSubscription> getSubscription(final String subscriptionId) {
+ try {
+ final ResponseEntity<NsdmSubscription> responseEntity = httpServiceProvider.getHttpResponse(
+ etsiCatalogUrlProvider.getSubscriptionUrl() + "/" + subscriptionId, NsdmSubscription.class);
+
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
+ logger.debug("Found subscription with ID: {} in ETSI Catalog Manager", subscriptionId);
+ return Optional.ofNullable(responseEntity.getBody());
+ }
+ logger.error("Unexpected Status Code Received on getting subscription from ETSI Catalog Manager: {}",
+ responseEntity.getStatusCode());
+ } catch (final HttpResouceNotFoundException resouceNotFoundException) {
+ logger.error("Unable to find subscription in ETSI Catalog Manager using id: {}", subscriptionId);
+ return Optional.empty();
+ } catch (final RestProcessingException | InvalidRestRequestException exception) {
+ logger.error("Unable to query ETSI Catalog Manager for subscription using id: {}", subscriptionId,
+ exception);
+ }
+ throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.");
+ }
+
private Optional<byte[]> requestVnfElement(final String vnfPkgId, final String vnfRequestUrl,
final String vnfRequestName) {
try {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/AbstractNotificationServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/AbstractNotificationServiceProvider.java
new file mode 100644
index 0000000000..86ca59cffe
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/AbstractNotificationServiceProvider.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement;
+
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import java.nio.charset.StandardCharsets;
+import org.apache.commons.codec.binary.Base64;
+import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
+import org.onap.so.configuration.rest.HttpHeadersProvider;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.onap.so.rest.service.HttpRestServiceProviderImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * A base class that can be extended by classes for providing notification services. Provides common methods that will
+ * be useful to those classes.
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ */
+public abstract class AbstractNotificationServiceProvider {
+
+ @Autowired
+ @Qualifier(CONFIGURABLE_REST_TEMPLATE)
+ private RestTemplate restTemplate;
+
+ protected HttpRestServiceProvider getHttpRestServiceProvider(final HttpHeadersProvider httpHeadersProvider) {
+ final HttpRestServiceProvider httpRestServiceProvider =
+ new HttpRestServiceProviderImpl(restTemplate, httpHeadersProvider);
+ return httpRestServiceProvider;
+ }
+
+ protected BasicHttpHeadersProvider getBasicHttpHeadersProviderWithBasicAuth(final String username,
+ final String password) {
+ final byte[] encodedAuth = getBasicAuth(username, password);
+ final String authHeader = "Basic " + new String(encodedAuth);
+ return new BasicHttpHeadersProvider(authHeader);
+ }
+
+ protected byte[] getBasicAuth(final String username, final String password) {
+ final String auth = username + ":" + password;
+ return Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/BasicAuthNotificationServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/BasicAuthNotificationServiceProvider.java
new file mode 100644
index 0000000000..6f9d94e9de
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/BasicAuthNotificationServiceProvider.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum;
+import org.onap.so.configuration.rest.HttpHeadersProvider;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.slf4j.Logger;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+/**
+ * Implementation of a NotificationServiceProvider which supports Basic Authentication
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ */
+@Service
+public class BasicAuthNotificationServiceProvider extends AbstractNotificationServiceProvider
+ implements NotificationServiceProvider {
+
+ private static final Logger logger = getLogger(BasicAuthNotificationServiceProvider.class);
+
+ @Override
+ public boolean send(final Object notification, final SubscriptionsAuthentication subscriptionsAuthentication,
+ final String callbackUri) {
+ logger.info("Sending notification to uri: {}", callbackUri);
+ final HttpHeadersProvider httpHeadersProvider =
+ getBasicHttpHeadersProviderWithBasicAuth(subscriptionsAuthentication.getParamsBasic().getUserName(),
+ subscriptionsAuthentication.getParamsBasic().getPassword());
+ final HttpRestServiceProvider httpRestServiceProvider = getHttpRestServiceProvider(httpHeadersProvider);
+
+ final ResponseEntity<Void> responseEntity =
+ httpRestServiceProvider.postHttpRequest(notification, callbackUri, Void.class);
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
+ logger.info("Notification sent successfully.");
+ return true;
+ }
+
+ logger.error("Failed to send notification.");
+ return false;
+ }
+
+ @Override
+ public AuthTypeEnum getAuthType() {
+ return AuthTypeEnum.BASIC;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationManager.java
new file mode 100644
index 0000000000..c1051d1c9d
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationManager.java
@@ -0,0 +1,137 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import java.util.List;
+import java.util.Optional;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgChangeNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgOnboardingNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageChangeNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.AuthenticationTypeNotSupportedException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.NotificationTypeNotSupportedException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.stereotype.Service;
+
+/**
+ * Manages package management subscription notifications to the VNFMs
+ *
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+@Service
+public class NotificationManager {
+
+ private static final Logger logger = getLogger(NotificationManager.class);
+ private final ConversionService conversionService;
+ private final SubscriptionManager subscriptionManager;
+ private final NotificationServiceProviderFactory notificationServiceProviderFactory;
+
+ @Autowired
+ public NotificationManager(final SubscriptionManager subscriptionManager, final ConversionService conversionService,
+ final NotificationServiceProviderFactory notificationServiceProviderFactory) {
+ this.subscriptionManager = subscriptionManager;
+ this.conversionService = conversionService;
+ this.notificationServiceProviderFactory = notificationServiceProviderFactory;
+ }
+
+ /**
+ * Process a subscription notification. Checks for a subscription request stored in the adapter and if there is, it
+ * sends the notification to the subscribed vnfm.
+ *
+ * @param notification the notification to send to the vnfm
+ * @param subscriptionId the id of the subscription request
+ * @return true if the notification is successfully sent
+ */
+ public boolean processSubscriptionNotification(final Object notification, final String subscriptionId) {
+ final Optional<PkgmSubscriptionRequest> optionalSubscription =
+ subscriptionManager.getSubscriptionRequest(subscriptionId);
+ if (optionalSubscription.isPresent()) {
+ final PkgmSubscriptionRequest subscriptionRequest = optionalSubscription.get();
+ return notifyVnfm(subscriptionRequest, notification);
+ }
+ final String errorMessage = "No subscription found with subscriptionId " + subscriptionId
+ + ". Unable to forward notification to subscriber.";
+ logger.error(errorMessage);
+ throw new SubscriptionNotFoundException(errorMessage);
+ }
+
+ private boolean notifyVnfm(final PkgmSubscriptionRequest subscriptionRequest, final Object notification) {
+ if (!(notification instanceof PkgOnboardingNotification) && !(notification instanceof PkgChangeNotification)) {
+ final String errorMessage =
+ "An error occurred. Notification type not supported for: " + notification.getClass();
+ logger.error(errorMessage);
+ throw new NotificationTypeNotSupportedException(errorMessage);
+ }
+
+ final SubscriptionsAuthentication subscriptionsAuthentication = subscriptionRequest.getAuthentication();
+ final AuthTypeEnum authType = getAuthType(subscriptionsAuthentication.getAuthType());
+ final NotificationServiceProvider sender = notificationServiceProviderFactory.getNotificationSender(authType);
+
+ final Object vnfmNotificationObject = convertEtsiCatalogNotification(notification);
+
+ if (sender.send(vnfmNotificationObject, subscriptionsAuthentication, subscriptionRequest.getCallbackUri())) {
+ logger.info("Notification delivered successfully {}", notification);
+ return true;
+ }
+
+ logger.error("Failed to deliver notification.");
+ return false;
+ }
+
+ private SubscriptionsAuthentication.AuthTypeEnum getAuthType(final List<AuthTypeEnum> authTypes) {
+ if (authTypes.contains(SubscriptionsAuthentication.AuthTypeEnum.TLS_CERT)) {
+ return SubscriptionsAuthentication.AuthTypeEnum.TLS_CERT;
+ }
+ if (authTypes.contains(SubscriptionsAuthentication.AuthTypeEnum.OAUTH2_CLIENT_CREDENTIALS)) {
+ return SubscriptionsAuthentication.AuthTypeEnum.OAUTH2_CLIENT_CREDENTIALS;
+ }
+ if (authTypes.contains(SubscriptionsAuthentication.AuthTypeEnum.BASIC)) {
+ return SubscriptionsAuthentication.AuthTypeEnum.BASIC;
+ }
+ final String errorMessage =
+ "An error occurred. No supported authentication type provided in subscription request.";
+ logger.error(errorMessage);
+ throw new AuthenticationTypeNotSupportedException(errorMessage);
+ }
+
+ private Object convertEtsiCatalogNotification(final Object etsiCatalogNotification) {
+ logger.info("Converting notification:\n {}", etsiCatalogNotification);
+ if (conversionService.canConvert(etsiCatalogNotification.getClass(), VnfPackageOnboardingNotification.class)) {
+ return conversionService.convert(etsiCatalogNotification, VnfPackageOnboardingNotification.class);
+ } else if (conversionService.canConvert(etsiCatalogNotification.getClass(),
+ VnfPackageChangeNotification.class)) {
+ return conversionService.convert(etsiCatalogNotification, VnfPackageChangeNotification.class);
+ }
+ final String errorMessage = "An error occurred. Unable to convert provided notification object.";
+ logger.error(errorMessage + "\n" + etsiCatalogNotification);
+ throw new ConversionFailedException(errorMessage);
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProvider.java
new file mode 100644
index 0000000000..2be80eec75
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProvider.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement;
+
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum;
+
+/**
+ * Interface which lays out requirements for a Notification Service Provider
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ */
+public interface NotificationServiceProvider {
+
+ /**
+ * Method to send a notification to a uri, given the subscription authentication
+ *
+ * @param notification The notification to send
+ * @param subscriptionsAuthentication Object containing the authentication details
+ * @param callbackUri The uri to send the notification to
+ * @return true if notification is delivered successfully, otherwise false
+ */
+ boolean send(final Object notification, final SubscriptionsAuthentication subscriptionsAuthentication,
+ final String callbackUri);
+
+ /**
+ * Method to get the supported authorization type of the service provider
+ *
+ * @return the supported AuthTypeEnum
+ */
+ AuthTypeEnum getAuthType();
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProviderFactory.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProviderFactory.java
new file mode 100644
index 0000000000..ab67afed82
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProviderFactory.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.AuthenticationTypeNotSupportedException;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * Factory to provide a notification services
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ */
+@Component
+public class NotificationServiceProviderFactory {
+
+ private static final Logger logger = getLogger(NotificationServiceProviderFactory.class);
+ private static final Map<AuthTypeEnum, NotificationServiceProvider> CACHE = new HashMap<>();
+
+ @Autowired
+ public NotificationServiceProviderFactory(final List<NotificationServiceProvider> services) {
+ for (final NotificationServiceProvider notificationServiceProvider : services) {
+ logger.debug("Adding {} of type {} to cache", notificationServiceProvider.getClass().getCanonicalName(),
+ notificationServiceProvider.getAuthType());
+ CACHE.put(notificationServiceProvider.getAuthType(), notificationServiceProvider);
+ }
+ }
+
+ /**
+ * Get a notification service for a given authorization type
+ *
+ * @param type the type of authentication required
+ * @return the notification service
+ */
+ public NotificationServiceProvider getNotificationSender(final AuthTypeEnum type) {
+ final NotificationServiceProvider service = CACHE.get(type);
+ if (service == null) {
+ throw new AuthenticationTypeNotSupportedException("Unknown type: " + type);
+ }
+ return service;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthNotificationServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthNotificationServiceProvider.java
new file mode 100644
index 0000000000..496fb083cf
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthNotificationServiceProvider.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException;
+import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
+import org.onap.so.configuration.rest.HttpHeadersProvider;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.slf4j.Logger;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+@Service
+public class OAuthNotificationServiceProvider extends AbstractNotificationServiceProvider
+ implements NotificationServiceProvider {
+
+ private static final Logger logger = getLogger(OAuthNotificationServiceProvider.class);
+
+ @Override
+ public boolean send(final Object notification, final SubscriptionsAuthentication subscriptionsAuthentication,
+ final String callbackUri) {
+ logger.info("Sending notification to uri: {}", callbackUri);
+ final String token = getAccessToken(subscriptionsAuthentication);
+
+ if (token == null) {
+ return false;
+ }
+
+ final HttpHeadersProvider httpHeadersProvider = getHttpHeadersProvider(token);
+ final HttpRestServiceProvider httpRestServiceProvider = getHttpRestServiceProvider(httpHeadersProvider);
+ final ResponseEntity<Void> responseEntity =
+ httpRestServiceProvider.postHttpRequest(notification, callbackUri, Void.class);
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
+ logger.info("Notification sent successfully.");
+ return true;
+ }
+
+ logger.error("Failed to send notification.");
+ return false;
+ }
+
+ @Override
+ public AuthTypeEnum getAuthType() {
+ return AuthTypeEnum.OAUTH2_CLIENT_CREDENTIALS;
+ }
+
+ private BasicHttpHeadersProvider getHttpHeadersProvider(final String token) {
+ final String authHeader = "Bearer " + token;
+ return new BasicHttpHeadersProvider(authHeader);
+ }
+
+ private String getAccessToken(final SubscriptionsAuthentication subscriptionsAuthentication) {
+ logger.info("Requesting Access Token.");
+
+ final String tokenEndpoint = subscriptionsAuthentication.getParamsOauth2ClientCredentials().getTokenEndpoint();
+
+ final HttpHeadersProvider httpHeadersProvider = getBasicHttpHeadersProviderWithBasicAuth(
+ subscriptionsAuthentication.getParamsOauth2ClientCredentials().getClientId(),
+ subscriptionsAuthentication.getParamsOauth2ClientCredentials().getClientPassword());
+
+ final HttpRestServiceProvider httpRestServiceProvider = getHttpRestServiceProvider(httpHeadersProvider);
+ final ResponseEntity<OAuthTokenResponse> responseEntity =
+ httpRestServiceProvider.postHttpRequest(null, tokenEndpoint, OAuthTokenResponse.class);
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
+ if (responseEntity.getBody() != null) {
+ logger.info("Returning Access Token.");
+ return responseEntity.getBody().getAccessToken();
+ }
+ }
+
+ final String errorMessage = "An error occurred. Unable to retrieve OAuth Token from VNFM for notification.";
+ logger.error(errorMessage);
+ throw new InternalServerErrorException(errorMessage);
+ }
+
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthTokenResponse.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthTokenResponse.java
new file mode 100644
index 0000000000..146641cc7c
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthTokenResponse.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement;
+
+import java.io.Serializable;
+import javax.xml.bind.annotation.XmlElement;
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ */
+public class OAuthTokenResponse implements Serializable {
+
+ private static final long serialVersionUID = -6455742984985959926L;
+
+ @XmlElement(name = "access_token")
+ @SerializedName("access_token")
+ private String accessToken;
+
+ /**
+ * Get the Accees Token
+ *
+ * @return the Access Token
+ */
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ /**
+ * Set the Access Token
+ *
+ * @param accessToken
+ */
+ public void setAccessToken(final String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java
index 30a16f70a8..a4c52fd13d 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java
@@ -31,8 +31,8 @@ import java.util.Objects;
import java.util.Optional;
import org.onap.so.adapters.vnfmadapter.Constants;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProvider;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogUrlProvider;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
@@ -40,13 +40,12 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf;
import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache.PackageManagementCacheServiceProvider;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionRequestConversionException;
-import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException;
import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.convert.ConversionException;
import org.springframework.core.convert.ConversionService;
import org.springframework.stereotype.Service;
@@ -55,34 +54,26 @@ import org.springframework.stereotype.Service;
*
* @author Ronan Kenny (ronan.kenny@est.tech)
* @author Gareth Roper (gareth.roper@est.tech)
- *
*/
@Service
public class SubscriptionManager {
private static final Logger logger = getLogger(SubscriptionManager.class);
private final PackageManagementCacheServiceProvider packageManagementCacheServiceProvider;
- private final EtsiCatalogUrlProvider etsiCatalogUrlProvider;
- private final HttpRestServiceProvider httpServiceProvider;
private final ConversionService conversionService;
private final EtsiCatalogServiceProvider etsiCatalogServiceProvider;
private final String vnfmAdapterEndpoint;
private final String msoKeyString;
private final String vnfmAdapterAuth;
-
@Autowired
public SubscriptionManager(final PackageManagementCacheServiceProvider packageManagementCacheServiceProvider,
- final ConversionService conversionService, final HttpRestServiceProvider httpServiceProvider,
- final EtsiCatalogUrlProvider etsiCatalogUrlProvider,
- final EtsiCatalogServiceProvider etsiCatalogServiceProvider,
+ final ConversionService conversionService, final EtsiCatalogServiceProvider etsiCatalogServiceProvider,
@Value("${vnfmadapter.endpoint}") final String vnfmAdapterEndpoint,
@Value("${mso.key}") final String msoKeyString,
- @Value("${vnfmadapter.auth:D6CFE56451508B75536C5E8A1E7AE06D0346006A693BF29293A6E1C762EFD59C671911DB6E9294E4FE15E4C1C5524B}") final String vnfmAdapterAuth) {
+ @Value("${vnfmadapter.auth:BF29BA36F0CFE1C05507781F6B97EFBCA7EFAC9F595954D465FC43F646883EF585C20A58CBB02528A6FAAC}") final String vnfmAdapterAuth) {
this.packageManagementCacheServiceProvider = packageManagementCacheServiceProvider;
- this.etsiCatalogUrlProvider = etsiCatalogUrlProvider;
this.conversionService = conversionService;
- this.httpServiceProvider = httpServiceProvider;
this.etsiCatalogServiceProvider = etsiCatalogServiceProvider;
this.vnfmAdapterEndpoint = vnfmAdapterEndpoint;
this.vnfmAdapterAuth = vnfmAdapterAuth;
@@ -99,10 +90,10 @@ public class SubscriptionManager {
etsiCatalogServiceProvider.postSubscription(etsiCatalogManagerSubscriptionRequest);
if (optionalEtsiCatalogManagerSubscription.isPresent()) {
- PkgmSubscription etsiCatalogManagerSubscription = optionalEtsiCatalogManagerSubscription.get();
+ final PkgmSubscription etsiCatalogManagerSubscription = optionalEtsiCatalogManagerSubscription.get();
logger.debug("postPkgmSubscriptionRequest Response SubscriptionId: {}",
- Objects.requireNonNull(etsiCatalogManagerSubscription.getId().toString()));
- final String subscriptionId = etsiCatalogManagerSubscription.getId().toString();
+ Objects.requireNonNull(etsiCatalogManagerSubscription.getId()));
+ final String subscriptionId = etsiCatalogManagerSubscription.getId();
packageManagementCacheServiceProvider.addSubscription(subscriptionId, pkgmSubscriptionRequest);
@@ -119,13 +110,24 @@ public class SubscriptionManager {
"Received empty response from POST to ETSI Catalog Manager Subscription Endpoint.");
}
-
-
public Optional<String> getSubscriptionId(final PkgmSubscriptionRequest pkgmSubscriptionRequest) {
return packageManagementCacheServiceProvider.getSubscriptionId(pkgmSubscriptionRequest);
}
public Optional<InlineResponse2002> getSubscription(final String subscriptionId) {
+
+ logger.debug("Checking if subscrition with id: {} exists in ETSI Catalog Manager", subscriptionId);
+ final Optional<NsdmSubscription> etsiCatalogSubscriptionOption =
+ etsiCatalogServiceProvider.getSubscription(subscriptionId);
+
+ if (!etsiCatalogSubscriptionOption.isPresent()) {
+ logger.debug("Unable to find subscription in ETSI Catalog Manager using id: {}", subscriptionId);
+ if (packageManagementCacheServiceProvider.getSubscription(subscriptionId).isPresent()) {
+ logger.debug("will remove subcription with id: {} from local cache", subscriptionId);
+ packageManagementCacheServiceProvider.deleteSubscription(subscriptionId);
+ }
+ }
+
final Optional<PkgmSubscriptionRequest> optional =
packageManagementCacheServiceProvider.getSubscription(subscriptionId);
if (optional.isPresent()) {
@@ -139,32 +141,57 @@ public class SubscriptionManager {
final Map<String, PkgmSubscriptionRequest> subscriptions =
packageManagementCacheServiceProvider.getSubscriptions();
final List<InlineResponse2002> response = new ArrayList<>();
- subscriptions.forEach((key, value) -> response.add(getInlineResponse2002(key, value)));
+ subscriptions.forEach((key, value) -> {
+ final Optional<InlineResponse2002> optional = getSubscription(key);
+ if (optional.isPresent()) {
+ response.add(optional.get());
+ }
+ });
return response;
}
+ public boolean deleteSubscription(final String subscriptionId) {
+ if (packageManagementCacheServiceProvider.getSubscription(subscriptionId).isPresent()) {
+ try {
+ if (etsiCatalogServiceProvider.deleteSubscription(subscriptionId)) {
+ return packageManagementCacheServiceProvider.deleteSubscription(subscriptionId);
+ }
+ } catch (final SubscriptionNotFoundException subscriptionNotFoundException) {
+ logger.error(
+ "Unable to find subscription in ETSI Catalog Manager using id: {} will delete it from local cache",
+ subscriptionId);
+ return packageManagementCacheServiceProvider.deleteSubscription(subscriptionId);
+ }
+ }
+ return false;
+ }
+
public URI getSubscriptionUri(final String subscriptionId) {
return URI.create(
vnfmAdapterEndpoint + Constants.PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions/" + subscriptionId);
}
+ public Optional<PkgmSubscriptionRequest> getSubscriptionRequest(final String subscriptionId) {
+ return packageManagementCacheServiceProvider.getSubscription(subscriptionId);
+ }
+
private InlineResponse2002 getInlineResponse2002(final String id, final PkgmSubscriptionRequest subscription) {
return new InlineResponse2002().id(id).filter(subscription.getFilter())
.callbackUri(subscription.getCallbackUri());
}
private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest buildEtsiCatalogManagerPkgmSubscriptionRequest(
- PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException {
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException {
final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest;
try {
etsiCatalogManagerSubscriptionRequest = conversionService.convert(pkgmSubscriptionRequest,
org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest.class);
- } catch (ConversionException conversionException) {
+ } catch (final org.springframework.core.convert.ConversionException conversionException) {
logger.error(conversionException.getMessage());
- throw new SubscriptionRequestConversionException(
+ throw new ConversionFailedException(
"Could not convert Sol003 PkgmSubscriptionRequest to ETSI-Catalog Manager PkgmSubscriptionRequest");
- } catch (Exception exception) {
+ } catch (final Exception exception) {
logger.error(exception.getMessage());
throw new InternalServerErrorException(
"Could not convert Sol003 PkgmSubscriptionRequest to ETSI-Catalog Manager PkgmSubscriptionRequest");
@@ -183,7 +210,7 @@ public class SubscriptionManager {
.addAuthTypeItem(BASIC).paramsBasic(new BasicAuth().userName(username).password(password)));
return etsiCatalogManagerSubscriptionRequest;
}
- throw new SubscriptionRequestConversionException(
+ throw new ConversionFailedException(
"Failed to convert Sol003 PkgmSubscriptionRequest to ETSI-Catalog Manager PkgmSubscriptionRequest");
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/TlsNotificationServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/TlsNotificationServiceProvider.java
new file mode 100644
index 0000000000..c9babbd345
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/TlsNotificationServiceProvider.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.AuthenticationTypeNotSupportedException;
+import org.slf4j.Logger;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ */
+@Service
+public class TlsNotificationServiceProvider extends AbstractNotificationServiceProvider
+ implements NotificationServiceProvider {
+
+ private static final Logger logger = getLogger(TlsNotificationServiceProvider.class);
+
+ @Override
+ public boolean send(final Object notification, final SubscriptionsAuthentication subscriptionsAuthentication,
+ final String callbackUri) {
+ final String errorMessage = "An error occurred. Authentication type "
+ + subscriptionsAuthentication.getAuthType().toString() + " not currently supported.";
+ logger.error(errorMessage);
+ throw new AuthenticationTypeNotSupportedException(errorMessage);
+ }
+
+
+ @Override
+ public AuthTypeEnum getAuthType() {
+ return AuthTypeEnum.TLS_CERT;
+ }
+
+
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java
index 6042513a50..437d20e593 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java
@@ -60,7 +60,7 @@ public interface PackageManagementCacheServiceProvider {
* Delete subscription from cache
*
* @param subscriptionId
- * @return true if subscription exists and able to be removed, otherwise returns false
+ * @return Boolean
*/
boolean deleteSubscription(final String subscriptionId);
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java
index c5bd5bc14e..a97f04bcc8 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java
@@ -22,30 +22,110 @@ package org.onap.so.adapters.vnfmadapter.rest;
import static org.onap.so.adapters.vnfmadapter.Constants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL;
import static org.slf4j.LoggerFactory.getLogger;
+import java.util.AbstractMap;
+import java.util.Map.Entry;
import javax.ws.rs.core.MediaType;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgChangeNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgOnboardingNotification;
+import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.NotificationManager;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.NotificationTypeNotSupportedException;
import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
/**
* This controller handles the ETSI Subscription Notification Endpoints.
*
* @author Ronan Kenny (ronan.kenny@est.tech)
* @author Gareth Roper (gareth.roper@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
*/
@Controller
-@RequestMapping(value = ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL,
- produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML},
- consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+@RequestMapping(value = ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL)
public class EtsiSubscriptionNotificationController {
private static final Logger logger = getLogger(EtsiSubscriptionNotificationController.class);
+ private final NotificationManager notificationManager;
+ private final Gson gson;
+
+ @Autowired
+ public EtsiSubscriptionNotificationController(final NotificationManager notificationManager) {
+ this.notificationManager = notificationManager;
+ this.gson = new GsonBuilder().create();
+ }
@GetMapping(value = "/notification")
public ResponseEntity<Void> testSubscriptionNotificationEndPoint() {
logger.debug("Testing Notification Endpoint");
return ResponseEntity.noContent().build();
}
+
+ /**
+ * POST notification on to subscriber.
+ *
+ * @param notification The notification to send.
+ * @return Response Code: 204 No Content if Successful, ProblemDetails Object if not.
+ */
+ @PostMapping(value = "/notification", consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON)
+ public ResponseEntity<?> postSubscriptionNotification(@RequestBody final String notification) {
+ logger.info("Posting subscription notification \n{}", notification);
+
+ final Entry<String, Object> notificationObject = getNotificationObject(notification);
+ if (notificationManager.processSubscriptionNotification(notificationObject.getValue(),
+ notificationObject.getKey())) {
+ logger.info("Notification Delivered Successfully");
+ return ResponseEntity.noContent().build();
+ }
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed.";
+ logger.error(errorMessage);
+ throw new InternalServerErrorException(errorMessage);
+ }
+
+ private Entry<String, Object> getNotificationObject(final String notification) {
+ final String notificationType = getNotificationType(notification);
+ if (PkgOnboardingNotification.NotificationTypeEnum.VNFPACKAGEONBOARDINGNOTIFICATION.getValue()
+ .equals(notificationType)) {
+ final PkgOnboardingNotification pkgOnboardingNotification =
+ gson.fromJson(notification, PkgOnboardingNotification.class);
+ logger.info("Onboarding notification received:\n{}", pkgOnboardingNotification);
+ return new AbstractMap.SimpleEntry<>(pkgOnboardingNotification.getSubscriptionId(),
+ pkgOnboardingNotification);
+ }
+ if (PkgChangeNotification.NotificationTypeEnum.VNFPACKAGECHANGENOTIFICATION.getValue()
+ .equals(notificationType)) {
+ final PkgChangeNotification pkgChangeNotification =
+ gson.fromJson(notification, PkgChangeNotification.class);
+ logger.info("Change notification received:\n{}", pkgChangeNotification);
+ return new AbstractMap.SimpleEntry<>(pkgChangeNotification.getSubscriptionId(), pkgChangeNotification);
+
+ }
+
+ final String errorMessage = "An error occurred. Notification type not supported for: " + notificationType;
+ logger.error(errorMessage);
+ throw new NotificationTypeNotSupportedException(errorMessage);
+
+ }
+
+ private String getNotificationType(final String notification) {
+ try {
+ final JsonParser parser = new JsonParser();
+ final JsonObject element = (JsonObject) parser.parse(notification);
+ return element.get("notificationType").getAsString();
+ } catch (final Exception e) {
+ logger.error("An error occurred processing notificiation: {}", e.getMessage());
+ }
+ throw new NotificationTypeNotSupportedException(
+ "Unable to parse notification type in object \n" + notification);
+ }
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
index 3ead98fce2..21b20b0134 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
@@ -50,8 +50,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
@RequestMapping(value = BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
public class Sol003GrantController {
- private static final String SEPARATOR = "_";
- private static final String VIM_TYPE = "OPENSTACK";
private static final Logger logger = LoggerFactory.getLogger(Sol003GrantController.class);
public final AaiServiceProvider aaiServiceProvider;
public final AaiHelper aaiHelper;
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
index cce7241757..f1d20c65ef 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
@@ -109,19 +109,19 @@ public class Sol003PackageManagementController {
*/
@GetMapping(value = "/vnf_packages/{vnfPkgId}/vnfd",
produces = {MediaType.TEXT_PLAIN, APPLICATION_ZIP, MediaType.APPLICATION_JSON})
- public ResponseEntity<byte[]> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) {
+ public ResponseEntity<?> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) {
logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageVnfd Endpoint Invoked with VNF Package ID: ", vnfPkgId);
final Optional<byte[]> response = etsiCatalogServiceProvider.getVnfPackageVnfd(vnfPkgId);
if (response.isPresent()) {
logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageVnfd Response: ", HttpStatus.OK);
- return new ResponseEntity(response.get(), HttpStatus.OK);
+ return new ResponseEntity<>(response.get(), HttpStatus.OK);
}
final String errorMessage = "An error occurred, a null response was received by the\n"
+ " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnfd\" \n"
+ "endpoint.";
logger.error(errorMessage);
- return new ResponseEntity(new ProblemDetails().detail(errorMessage), HttpStatus.INTERNAL_SERVER_ERROR);
+ return new ResponseEntity<>(new ProblemDetails().detail(errorMessage), HttpStatus.INTERNAL_SERVER_ERROR);
}
/**
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java
index cbad564210..6db3797f9b 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java
@@ -23,14 +23,13 @@ package org.onap.so.adapters.vnfmadapter.rest;
import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
import static org.slf4j.LoggerFactory.getLogger;
import java.net.URI;
-import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.util.List;
import java.util.Optional;
import javax.ws.rs.core.MediaType;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails;
import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.SubscriptionManager;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,6 +37,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -79,7 +79,7 @@ public class Sol003PackageManagementSubscriptionController {
@PostMapping(value = "/subscriptions")
public ResponseEntity<?> postSubscriptionRequest(@RequestBody final PkgmSubscriptionRequest pkgmSubscriptionRequest)
throws GeneralSecurityException {
- logger.info(LOG_REQUEST_RECEIVED, " postSubscriptionRequest Endpoint Called");
+ logger.info(LOG_REQUEST_RECEIVED, " postSubscriptionRequest Endpoint Called", pkgmSubscriptionRequest);
// Check if subscription exists already.
final Optional<String> exists = subscriptionManager.getSubscriptionId(pkgmSubscriptionRequest);
@@ -140,6 +140,24 @@ public class Sol003PackageManagementSubscriptionController {
}
/**
+ * DELETE a specific subscription, by subscriptionId. Section Number: 10.4.8.3.5
+ *
+ * @param subscriptionId The ID of the subscription that you wish to delete.
+ * @return Empty response if successful. Object: Void Response Code: 204 No Content
+ */
+ @DeleteMapping(value = "/subscriptions/{subscriptionId}")
+ public ResponseEntity<?> deleteSubscription(@PathVariable("subscriptionId") final String subscriptionId) {
+ if (subscriptionManager.deleteSubscription(subscriptionId)) {
+ logger.debug("Successfully deleted subscription with id {}", subscriptionId);
+ return ResponseEntity.noContent().build();
+ }
+ final String errorMessage =
+ "The requested subscription: " + subscriptionId + " was not found on call deleteSubscription";
+ logger.error(errorMessage);
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ProblemDetails().detail(errorMessage));
+ }
+
+ /**
* Method to set the Location in the header with the URI parameter
*
* @param subscriptionUri
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/AuthenticationTypeNotSupportedException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/AuthenticationTypeNotSupportedException.java
new file mode 100644
index 0000000000..303420f1e8
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/AuthenticationTypeNotSupportedException.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Exception for an unsupported authentication type
+ *
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ */
+@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
+public class AuthenticationTypeNotSupportedException extends RuntimeException {
+
+ private static final long serialVersionUID = 2939423208362066902L;
+
+ public AuthenticationTypeNotSupportedException(final String message) {
+ super(message);
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionRequestConversionException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/ConversionFailedException.java
index daa544f928..e19a53d1dc 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionRequestConversionException.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/ConversionFailedException.java
@@ -23,16 +23,17 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
/**
- * Exception for an ETSI Catalog Manager Request Failure
+ * Exception for Conversion Failures
*
- * @author gareth.roper@est.tech
+ * @author Gareth Roper (gareth.roper@est.tech)
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
*/
@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
-public class SubscriptionRequestConversionException extends RuntimeException {
+public class ConversionFailedException extends RuntimeException {
private static final long serialVersionUID = 45898561453196895L;
- public SubscriptionRequestConversionException(final String message) {
+ public ConversionFailedException(final String message) {
super(message);
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiSubscriptionNotificationControllerExceptionHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiSubscriptionNotificationControllerExceptionHandler.java
new file mode 100644
index 0000000000..e8e1ce35b9
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiSubscriptionNotificationControllerExceptionHandler.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+
+import static org.slf4j.LoggerFactory.getLogger;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails;
+import org.onap.so.adapters.vnfmadapter.rest.EtsiSubscriptionNotificationController;
+import org.onap.so.rest.exceptions.HttpResouceNotFoundException;
+import org.onap.so.rest.exceptions.InvalidRestRequestException;
+import org.onap.so.rest.exceptions.RestProcessingException;
+import org.slf4j.Logger;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
+/**
+ * Exception Handler for the Etsi Subscription Notification Controller {@link EtsiSubscriptionNotificationController
+ * EtsiSubscriptionNotificationController}
+ *
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ */
+@ControllerAdvice(assignableTypes = EtsiSubscriptionNotificationController.class)
+public class EtsiSubscriptionNotificationControllerExceptionHandler {
+
+ private static final Logger logger = getLogger(EtsiSubscriptionNotificationControllerExceptionHandler.class);
+
+ @ExceptionHandler(InvalidRestRequestException.class)
+ public ResponseEntity<ProblemDetails> handleInvalidRestRequestException(
+ final InvalidRestRequestException invalidRestRequestException) {
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + HttpStatus.BAD_REQUEST + ".\n" + invalidRestRequestException.getMessage();
+ logger.error(errorMessage);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
+ }
+
+ @ExceptionHandler(HttpResouceNotFoundException.class)
+ public ResponseEntity<ProblemDetails> handleHttpResourceNotFoundException(
+ final HttpResouceNotFoundException httpResourceNotFoundException) {
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + HttpStatus.NOT_FOUND + ".\n" + httpResourceNotFoundException.getMessage();
+ logger.error(errorMessage);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
+ }
+
+ @ExceptionHandler(RestProcessingException.class)
+ public ResponseEntity<ProblemDetails> handleRestProcessingException(
+ final RestProcessingException restProcessingException) {
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + restProcessingException.getStatusCode() + ".\n" + restProcessingException.getMessage();
+ logger.error(errorMessage);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
+ }
+
+ @ExceptionHandler(InternalServerErrorException.class)
+ public ResponseEntity<ProblemDetails> handleInternalServerErrorException(
+ final InternalServerErrorException internalServerErrorException) {
+ logger.error(internalServerErrorException.getMessage());
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+ .body(new ProblemDetails().detail(internalServerErrorException.getMessage()));
+ }
+
+ @ExceptionHandler(AuthenticationTypeNotSupportedException.class)
+ public ResponseEntity<ProblemDetails> handleAuthenticationTypeNotSupportedException(
+ final AuthenticationTypeNotSupportedException authenticationTypeNotSupportedException) {
+ logger.error(authenticationTypeNotSupportedException.getMessage());
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+ .body(new ProblemDetails().detail(authenticationTypeNotSupportedException.getMessage()));
+ }
+
+ @ExceptionHandler(ConversionFailedException.class)
+ public ResponseEntity<ProblemDetails> handleConversionFailedException(
+ final ConversionFailedException conversionFailedException) {
+ logger.error(conversionFailedException.getMessage());
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+ .body(new ProblemDetails().detail(conversionFailedException.getMessage()));
+ }
+
+ @ExceptionHandler(NotificationTypeNotSupportedException.class)
+ public ResponseEntity<ProblemDetails> handleNotificationTypeNotSupportedException(
+ final NotificationTypeNotSupportedException notificationTypeNotSupportedException) {
+ logger.error(notificationTypeNotSupportedException.getMessage());
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+ .body(new ProblemDetails().detail(notificationTypeNotSupportedException.getMessage()));
+ }
+
+ @ExceptionHandler(SubscriptionNotFoundException.class)
+ public ResponseEntity<ProblemDetails> handleSubscriptionNotFoundException(
+ final SubscriptionNotFoundException subscriptionNotFoundException) {
+ logger.error(subscriptionNotFoundException.getMessage());
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
+ .body(new ProblemDetails().detail(subscriptionNotFoundException.getMessage()));
+ }
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/NotificationTypeNotSupportedException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/NotificationTypeNotSupportedException.java
new file mode 100644
index 0000000000..dcc98864aa
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/NotificationTypeNotSupportedException.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Exception for an unsupported notification type
+ *
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ */
+@ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
+public class NotificationTypeNotSupportedException extends RuntimeException {
+
+ private static final long serialVersionUID = 2939423208362066902L;
+
+ public NotificationTypeNotSupportedException(final String message) {
+ super(message);
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java
index da8b0cbff2..8091f35da6 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java
@@ -22,10 +22,6 @@ package org.onap.so.adapters.vnfmadapter.rest.exceptions;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails;
import org.onap.so.adapters.vnfmadapter.rest.Sol003PackageManagementController;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.EtsiCatalogManagerRequestFailureException;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgBadRequestException;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgConflictException;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgNotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
@@ -64,11 +60,11 @@ public class Sol003PackageManagementControllerExceptionHandler {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(problemDetails);
}
- @ExceptionHandler(SubscriptionRequestConversionException.class)
- public ResponseEntity<ProblemDetails> handleSubscriptionRequestConversionException(
- final SubscriptionRequestConversionException subscriptionRequestConversionException) {
+ @ExceptionHandler(ConversionFailedException.class)
+ public ResponseEntity<ProblemDetails> handleConversionFailedException(
+ final ConversionFailedException conversionFailedException) {
final ProblemDetails problemDetails = new ProblemDetails();
- problemDetails.setDetail(subscriptionRequestConversionException.getMessage());
+ problemDetails.setDetail(conversionFailedException.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(problemDetails);
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationControllerTest.java
new file mode 100644
index 0000000000..8012f7e6cf
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationControllerTest.java
@@ -0,0 +1,592 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.vnfmadapter.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.onap.so.adapters.vnfmadapter.Constants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.vnfmadapter.Constants;
+import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.NOTIFICATIONLINKSERIALIZER;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgChangeNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgOnboardingNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgmLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthenticationParamsBasic;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthenticationParamsOauth2ClientCredentials;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageChangeNotification;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification;
+import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.http.*;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.client.MockRestServiceServer;
+import org.springframework.web.client.RestTemplate;
+import org.threeten.bp.LocalDateTime;
+import org.threeten.bp.OffsetDateTime;
+import org.threeten.bp.ZoneOffset;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+/**
+ * @author Andrew Lamb (andrew.a.lamb@est.tech)
+ *
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class EtsiSubscriptionNotificationControllerTest {
+
+ @LocalServerPort
+ private int port;
+
+ private static final URI CALLBACK_URI = URI.create("http://test_callback_uri/notification");
+ private static final String TOKEN_ENDPOINT = "http://test_token_endpoint_uri/";
+ private static final String TOKEN = "dXNlcm5hbWU6cGFzc3dvcmQ=......";
+ private static final String JSON_TOKEN = "{\"access_token\":\"" + TOKEN + "\"}";
+ private static final String LOCALHOST_URL = "http://localhost:";
+ private static final String NOTIFICATION_BASE_URL =
+ ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL + "/notification";
+ private static final String USERNAME = "username";
+ private static final String PASSWORD = "password";
+ private static final String EXPECTED_BASIC_AUTHORIZATION = "Basic dXNlcm5hbWU6cGFzc3dvcmQ=";
+ private static final String EXPECTED_OAUTH_AUTHORIZATION = "Bearer " + TOKEN;
+ private static final String NOTIFICATION_ID = "NOTIFICATION_ID";
+ private static final String SUBSCRIPTION_ID = "SUBSCRIPTION_ID";
+ private static final OffsetDateTime TIMESTAMP =
+ OffsetDateTime.of(LocalDateTime.of(2020, 1, 1, 1, 1, 1, 1), ZoneOffset.ofHours(1));
+ private static final String VNFPKG_ID = UUID.randomUUID().toString();
+ private static final String VNFD_ID = UUID.randomUUID().toString();
+
+ private BasicHttpHeadersProvider basicHttpHeadersProvider;
+ private final Gson gson = new GsonBuilder().create();;
+
+ @Autowired
+ @Qualifier(CONFIGURABLE_REST_TEMPLATE)
+ private RestTemplate restTemplate;
+ private MockRestServiceServer mockRestServer;
+
+ @Autowired
+ private TestRestTemplate testRestTemplate;
+
+ @Autowired
+ private CacheManager cacheServiceProvider;
+ private Cache cache;
+
+ @Before
+ public void setUp() {
+ mockRestServer = MockRestServiceServer.bindTo(restTemplate).build();
+ basicHttpHeadersProvider = new BasicHttpHeadersProvider();
+ cache = cacheServiceProvider.getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE);
+ cache.clear();
+ }
+
+ @After
+ public void tearDown() {
+ cache.clear();
+ }
+
+ @Test
+ public void testSubscriptionNotificationEndPoint_ReturnsNoContent() {
+ final ResponseEntity<?> response = sendHttpGet(NOTIFICATION_BASE_URL);
+ assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
+ }
+
+ @Test
+ public void testOnboardingNotificationSentOnToVnfmCallbackUri_SubscriptionRequestInCache_Success() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andExpect(jsonPath("$.id").value(NOTIFICATION_ID))
+ .andExpect(jsonPath("$.notificationType")
+ .value(VnfPackageOnboardingNotification.NotificationTypeEnum.VNFPACKAGEONBOARDINGNOTIFICATION
+ .toString()))
+ .andExpect(jsonPath("$.subscriptionId").value(SUBSCRIPTION_ID))
+ .andExpect(jsonPath("$.timeStamp").value(TIMESTAMP.toString()))
+ .andExpect(jsonPath("$.vnfPkgId").value(VNFPKG_ID.toString()))
+ .andExpect(jsonPath("$.vnfdId").value(VNFD_ID.toString()))
+ .andExpect(jsonPath("$._links").value(buildPkgmLinks()))
+ .andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION)).andRespond(withSuccess());
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
+ }
+
+ @Test
+ public void testOnboardingNotificationNotSentOnToVnfmCallbackUri_SubscriptionRequestNotInCache_Fail() {
+ final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
+ final String notificationString = gson.toJson(notification);
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "No subscription found with subscriptionId " + SUBSCRIPTION_ID
+ + ". Unable to forward notification to subscriber.";
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testOnboardingNotificationSentOnToVnfmCallbackUri_BadRequestResponseFromCallbackUri_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andRespond(withStatus(HttpStatus.BAD_REQUEST));
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + HttpStatus.BAD_REQUEST + ".\n" + "No result found for given url: " + CALLBACK_URI;
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testOnboardingNotificationSentOnToVnfmCallbackUri_301MovedPermanentlyResponseFromCallbackUri_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andRespond(withStatus(HttpStatus.MOVED_PERMANENTLY));
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed.";
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testOnboardingNotificationSentOnToVnfmCallbackUri_NotFoundResponseFromCallbackUri_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andRespond(withStatus(HttpStatus.NOT_FOUND));
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + HttpStatus.NOT_FOUND + ".\n" + "No result found for given url: " + CALLBACK_URI;
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testOnboardingNotificationSentOnToVnfmCallbackUri_InternalServerErrorResponseFromCallbackUri_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + HttpStatus.INTERNAL_SERVER_ERROR.value() + ".\n" + "Unable to invoke HTTP POST using URL: "
+ + CALLBACK_URI;
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testChangeNotificationSentOnToVnfmCallbackUri_SubscriptionRequestInCache_Success() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgChangeNotification notification = buildPkgChangeNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andExpect(jsonPath("$.id").value(NOTIFICATION_ID))
+ .andExpect(jsonPath("$.notificationType").value(
+ VnfPackageChangeNotification.NotificationTypeEnum.VNFPACKAGECHANGENOTIFICATION.toString()))
+ .andExpect(jsonPath("$.subscriptionId").value(SUBSCRIPTION_ID))
+ .andExpect(jsonPath("$.timeStamp").value(TIMESTAMP.toString()))
+ .andExpect(jsonPath("$.vnfPkgId").value(VNFPKG_ID.toString()))
+ .andExpect(jsonPath("$.vnfdId").value(VNFD_ID.toString()))
+ .andExpect(
+ jsonPath("$.changeType").value(PkgChangeNotification.ChangeTypeEnum.OP_STATE_CHANGE.toString()))
+ .andExpect(jsonPath("$.operationalState")
+ .value(PkgChangeNotification.OperationalStateEnum.ENABLED.toString()))
+ .andExpect(jsonPath("$._links").value(buildPkgmLinks()))
+ .andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION)).andRespond(withSuccess());
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
+ }
+
+ @Test
+ public void testChangeNotificationNotSentOnToVnfmCallbackUri_SubscriptionRequestNotInCache_Fail() {
+ final PkgChangeNotification notification = buildPkgChangeNotification();
+ final String notificationString = gson.toJson(notification);
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "No subscription found with subscriptionId " + SUBSCRIPTION_ID
+ + ". Unable to forward notification to subscriber.";
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testChangeNotificationSentOnToVnfmCallbackUri_BadRequestResponseFromCallbackUri_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgChangeNotification notification = buildPkgChangeNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andRespond(withStatus(HttpStatus.BAD_REQUEST));
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + HttpStatus.BAD_REQUEST + ".\n" + "No result found for given url: " + CALLBACK_URI;
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testChangeNotificationSentOnToVnfmCallbackUri_NotFoundResponseFromCallbackUri_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgChangeNotification notification = buildPkgChangeNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andRespond(withStatus(HttpStatus.NOT_FOUND));
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + HttpStatus.NOT_FOUND + ".\n" + "No result found for given url: " + CALLBACK_URI;
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testChangeNotificationSentOnToVnfmCallbackUri_InternalServerErrorResponseFromCallbackUri_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgChangeNotification notification = buildPkgChangeNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + HttpStatus.INTERNAL_SERVER_ERROR.value() + ".\n" + "Unable to invoke HTTP POST using URL: "
+ + CALLBACK_URI;
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testNotificationSentOnToVnfm_BasicAuthUserPasswordAuthorized_Success() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andExpect(jsonPath("$.id").value(NOTIFICATION_ID))
+ .andExpect(jsonPath("$.notificationType")
+ .value(VnfPackageOnboardingNotification.NotificationTypeEnum.VNFPACKAGEONBOARDINGNOTIFICATION
+ .toString()))
+ .andExpect(jsonPath("$.subscriptionId").value(SUBSCRIPTION_ID))
+ .andExpect(jsonPath("$.timeStamp").value(TIMESTAMP.toString()))
+ .andExpect(jsonPath("$.vnfPkgId").value(VNFPKG_ID.toString()))
+ .andExpect(jsonPath("$.vnfdId").value(VNFD_ID.toString()))
+ .andExpect(jsonPath("$._links").value(buildPkgmLinks()))
+ .andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION)).andRespond(withSuccess());
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
+ }
+
+ @Test
+ public void testNotificationSentOnToVnfm_BasicAuthUserPasswordNotAuthorized_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.BASIC);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgChangeNotification notification = buildPkgChangeNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION))
+ .andRespond(withStatus(HttpStatus.UNAUTHORIZED));
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Sending of notification to VNFM failed with response: "
+ + HttpStatus.UNAUTHORIZED.value() + ".\n" + "Unable to invoke HTTP POST using URL: " + CALLBACK_URI;
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testNotificationSentOnToVnfm_OAuthAuthorized_Success() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.OAUTH2_CLIENT_CREDENTIALS);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgChangeNotification notification = buildPkgChangeNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST))
+ .andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION))
+ .andRespond(withSuccess(JSON_TOKEN, MediaType.APPLICATION_JSON));
+
+ mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ .andExpect(header("Authorization", EXPECTED_OAUTH_AUTHORIZATION))
+ .andExpect(jsonPath("$.id").value(NOTIFICATION_ID))
+ .andExpect(jsonPath("$.notificationType").value(
+ VnfPackageChangeNotification.NotificationTypeEnum.VNFPACKAGECHANGENOTIFICATION.toString()))
+ .andExpect(jsonPath("$.subscriptionId").value(SUBSCRIPTION_ID))
+ .andExpect(jsonPath("$.timeStamp").value(TIMESTAMP.toString()))
+ .andExpect(jsonPath("$.vnfPkgId").value(VNFPKG_ID.toString()))
+ .andExpect(jsonPath("$.vnfdId").value(VNFD_ID.toString()))
+ .andExpect(
+ jsonPath("$.changeType").value(PkgChangeNotification.ChangeTypeEnum.OP_STATE_CHANGE.toString()))
+ .andExpect(jsonPath("$.operationalState")
+ .value(PkgChangeNotification.OperationalStateEnum.ENABLED.toString()))
+ .andExpect(jsonPath("$._links").value(buildPkgmLinks())).andRespond(withSuccess());
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
+ }
+
+ @Test
+ public void testNotificationSentOnToVnfm_OAuthTokenNotReceived_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.OAUTH2_CLIENT_CREDENTIALS);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgChangeNotification notification = buildPkgChangeNotification();
+ final String notificationString = gson.toJson(notification);
+
+ mockRestServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST))
+ .andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION)).andRespond(withSuccess());
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Unable to retrieve OAuth Token from VNFM for notification.";
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ @Test
+ public void testNotificationSentOnToVnfm_TLSCertNotYetSupported_Fail() {
+ final PkgmSubscriptionRequest subscriptionRequest =
+ buildPkgmSubscriptionRequest(SubscriptionsAuthentication.AuthTypeEnum.TLS_CERT);
+ cache.put(SUBSCRIPTION_ID, subscriptionRequest);
+ final PkgChangeNotification notification = buildPkgChangeNotification();
+ final String notificationString = gson.toJson(notification);
+
+ final ResponseEntity<?> response = sendHttpPost(notificationString);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
+ assertTrue(response.getBody() instanceof ProblemDetails);
+
+ final ProblemDetails problemDetails = (ProblemDetails) response.getBody();
+ final String errorMessage = "An error occurred. Authentication type "
+ + subscriptionRequest.getAuthentication().getAuthType().toString() + " not currently supported.";
+
+ assertEquals(errorMessage, problemDetails.getDetail());
+ }
+
+ private PkgOnboardingNotification buildPkgOnboardingNotification() {
+ final PkgOnboardingNotification notification = new PkgOnboardingNotification();
+ notification.setId(NOTIFICATION_ID);
+ notification
+ .setNotificationType(PkgOnboardingNotification.NotificationTypeEnum.VNFPACKAGEONBOARDINGNOTIFICATION);
+ notification.setSubscriptionId(SUBSCRIPTION_ID);
+ notification.setTimeStamp(TIMESTAMP);
+ notification.setVnfPkgId(VNFPKG_ID);
+ notification.setVnfdId(VNFD_ID);
+ notification.setLinks(buildPkgmLinks());
+ return notification;
+ }
+
+ private PkgChangeNotification buildPkgChangeNotification() {
+ final PkgChangeNotification notification = new PkgChangeNotification();
+ notification.setId(NOTIFICATION_ID);
+ notification.setNotificationType(PkgChangeNotification.NotificationTypeEnum.VNFPACKAGECHANGENOTIFICATION);
+ notification.setSubscriptionId(SUBSCRIPTION_ID);
+ notification.setTimeStamp(TIMESTAMP);
+ notification.setVnfPkgId(VNFPKG_ID);
+ notification.setVnfdId(VNFD_ID);
+ notification.setChangeType(PkgChangeNotification.ChangeTypeEnum.OP_STATE_CHANGE);
+ notification.setOperationalState(PkgChangeNotification.OperationalStateEnum.ENABLED);
+ notification.setLinks(buildPkgmLinks());
+ return notification;
+ }
+
+ private PkgmLinks buildPkgmLinks() {
+ final PkgmLinks pkgmLinks = new PkgmLinks();
+
+ final NOTIFICATIONLINKSERIALIZER subscriptionLinkSerializer = new NOTIFICATIONLINKSERIALIZER();
+ subscriptionLinkSerializer.setHref("subscription_href");
+ pkgmLinks.setSubscription(subscriptionLinkSerializer);
+
+ final NOTIFICATIONLINKSERIALIZER vnfPackageLinkSerializer = new NOTIFICATIONLINKSERIALIZER();
+ vnfPackageLinkSerializer.setHref("vnf_package_href");
+ pkgmLinks.setVnfPackage(vnfPackageLinkSerializer);
+
+ return pkgmLinks;
+ }
+
+ private PkgmSubscriptionRequest buildPkgmSubscriptionRequest(
+ final SubscriptionsAuthentication.AuthTypeEnum authTypeEnum) {
+ final PkgmSubscriptionRequest subscriptionRequest = new PkgmSubscriptionRequest();
+ subscriptionRequest.setCallbackUri(CALLBACK_URI.toString());
+ subscriptionRequest.setAuthentication(buildSubscriptionsAuthentication(authTypeEnum));
+ return subscriptionRequest;
+ }
+
+ // TODO update for auth types other than basicAuth
+ private SubscriptionsAuthentication buildSubscriptionsAuthentication(
+ final SubscriptionsAuthentication.AuthTypeEnum authTypeEnum) {
+ final SubscriptionsAuthentication subscriptionsAuthentication = new SubscriptionsAuthentication();
+ final List<SubscriptionsAuthentication.AuthTypeEnum> authTypes = new ArrayList<>();
+ authTypes.add(authTypeEnum);
+ subscriptionsAuthentication.setAuthType(authTypes);
+ if (authTypeEnum == SubscriptionsAuthentication.AuthTypeEnum.TLS_CERT) {
+ // TODO: remove basic params and code for TLS
+ final SubscriptionsAuthenticationParamsBasic basicParams =
+ new SubscriptionsAuthenticationParamsBasic().userName(USERNAME).password(PASSWORD);
+ subscriptionsAuthentication.setParamsBasic(basicParams);
+ } else if (authTypeEnum == SubscriptionsAuthentication.AuthTypeEnum.OAUTH2_CLIENT_CREDENTIALS) {
+ final SubscriptionsAuthenticationParamsOauth2ClientCredentials oathParams =
+ new SubscriptionsAuthenticationParamsOauth2ClientCredentials().clientId(USERNAME)
+ .clientPassword(PASSWORD).tokenEndpoint(TOKEN_ENDPOINT);
+ subscriptionsAuthentication.setParamsOauth2ClientCredentials(oathParams);
+ } else {
+ final SubscriptionsAuthenticationParamsBasic basicParams =
+ new SubscriptionsAuthenticationParamsBasic().userName(USERNAME).password(PASSWORD);
+ subscriptionsAuthentication.setParamsBasic(basicParams);
+ }
+
+ return subscriptionsAuthentication;
+ }
+
+ private <T> ResponseEntity<ProblemDetails> sendHttpPost(final T notification) {
+ final String testURL = LOCALHOST_URL + port + NOTIFICATION_BASE_URL;
+ final HttpEntity<?> request = new HttpEntity<>(notification, basicHttpHeadersProvider.getHttpHeaders());
+ return testRestTemplate.withBasicAuth("test", "test").exchange(testURL, HttpMethod.POST, request,
+ ProblemDetails.class);
+ }
+
+ private ResponseEntity<Void> sendHttpGet(final String url) {
+ final String testURL = LOCALHOST_URL + port + url;
+ final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders());
+ return testRestTemplate.withBasicAuth("test", "test").exchange(testURL, HttpMethod.GET, request, Void.class);
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java
index f90978e0d5..ba1bf71936 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java
@@ -20,27 +20,32 @@
package org.onap.so.adapters.vnfmadapter.rest;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
-import java.security.GeneralSecurityException;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
import java.net.URI;
import java.net.URISyntaxException;
+import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
-import com.google.gson.Gson;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.vnfmadapter.Constants;
import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.LinkSelf;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002;
@@ -51,13 +56,13 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf;
-import org.onap.so.utils.CryptoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -65,41 +70,33 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
-import org.springframework.http.HttpMethod;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
-import static org.hamcrest.Matchers.is;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
+import com.google.gson.Gson;
/**
* @author Ronan Kenny (ronan.kenny@est.tech)
* @author Gareth Roper (gareth.roper@est.tech)
- *
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
-@SuppressWarnings("unchecked")
public class Sol003PackageManagementSubscriptionControllerTest {
- private static String subscriptionId;
private final Gson gson = new Gson();
-
+ private final URI msbEndpoint = URI.create("http://msb-iag.onap:80/api/vnfpkgm/v1/subscriptions");
@Autowired
@Qualifier(CONFIGURABLE_REST_TEMPLATE)
- private RestTemplate testRestTemplate;
-
- private MockRestServiceServer mockRestServer;
-
+ private RestTemplate restTemplate;
+ private MockRestServiceServer mockRestServiceServer;
@Autowired
private CacheManager cacheServiceProvider;
- private final URI msbEndpoint = URI.create("http://msb-iag.onap:80/api/vnfpkgm/v1/subscriptions");
-
@Autowired
private Sol003PackageManagementSubscriptionController sol003PackageManagementSubscriptionController;
+ private static final String ID = UUID.randomUUID().toString();
+
@Before
public void setUp() {
- mockRestServer = MockRestServiceServer.bindTo(testRestTemplate).build();
+ mockRestServiceServer = MockRestServiceServer.bindTo(restTemplate).build();
final Cache cache = cacheServiceProvider.getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE);
cache.clear();
}
@@ -113,8 +110,8 @@ public class Sol003PackageManagementSubscriptionControllerTest {
final HttpHeaders headers = buildHttpHeaders(Objects.requireNonNull(response.getBody()).getCallbackUri());
- SubscriptionsLinks subscriptionsLinks = new SubscriptionsLinks();
- VnfPackagesLinksSelf vnfPackagesLinksSelf = new VnfPackagesLinksSelf();
+ final SubscriptionsLinks subscriptionsLinks = new SubscriptionsLinks();
+ final VnfPackagesLinksSelf vnfPackagesLinksSelf = new VnfPackagesLinksSelf();
vnfPackagesLinksSelf.setHref("https://so-vnfm-adapter.onap:30406" + PACKAGE_MANAGEMENT_BASE_URL
+ "/subscriptions/" + response.getBody().getId());
subscriptionsLinks.setSelf(vnfPackagesLinksSelf);
@@ -134,7 +131,6 @@ public class Sol003PackageManagementSubscriptionControllerTest {
final ResponseEntity<InlineResponse2002> response =
(ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
.postSubscriptionRequest(pkgmSubscriptionRequest);
- subscriptionId = Objects.requireNonNull(response.getBody()).getId();
// Create duplicate entry
final PkgmSubscriptionRequest pkgmSubscriptionRequest2 = buildPkgmSubscriptionRequest();
@@ -148,12 +144,18 @@ public class Sol003PackageManagementSubscriptionControllerTest {
@Test
public void testSuccessGetSubscriptionWithSubscriptionId() throws GeneralSecurityException, URISyntaxException {
+
final PkgmSubscriptionRequest pkgmSubscriptionRequest = postSubscriptionForTest();
+ mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + ID)).andExpect(method(HttpMethod.GET))
+ .andRespond(withSuccess(gson.toJson(new NsdmSubscription().id(ID)), MediaType.APPLICATION_JSON));
+
final ResponseEntity<InlineResponse2002> response =
(ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
.postSubscriptionRequest(pkgmSubscriptionRequest);
- subscriptionId = Objects.requireNonNull(response.getBody()).getId();
+ final String subscriptionId = response.getBody().getId();
+
+
final ResponseEntity<InlineResponse2002> response2002 =
(ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
@@ -161,9 +163,8 @@ public class Sol003PackageManagementSubscriptionControllerTest {
final HttpHeaders headers = buildHttpHeaders(response.getBody().getCallbackUri());
-
assertEquals(response.getBody().getFilter(), pkgmSubscriptionRequest.getFilter());
- assert (response.getHeaders().equals(headers));
+ assertEquals(response.getHeaders(), headers);
assertEquals(HttpStatus.OK, response2002.getStatusCode());
assertEquals(pkgmSubscriptionRequest.getFilter(), response.getBody().getFilter());
// Ensure CallBackUri is set to new URI
@@ -172,9 +173,12 @@ public class Sol003PackageManagementSubscriptionControllerTest {
@Test
public void testFailGetSubscriptionWithInvalidSubscriptionId() {
+ final String invalidId = "invalidSubscriptionId";
+ mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + invalidId)).andExpect(method(HttpMethod.GET))
+ .andRespond(withStatus(HttpStatus.NOT_FOUND));
final ResponseEntity<InlineResponse2002> response =
(ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
- .getSubscription("invalidSubscriptionId");
+ .getSubscription(invalidId);
assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
}
@@ -183,14 +187,16 @@ public class Sol003PackageManagementSubscriptionControllerTest {
final PkgmSubscription pkgmSubscription = buildPkgmSubscription();
final PkgmSubscriptionRequest pkgmSubscriptionRequest = buildPkgmSubscriptionRequest();
- mockRestServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST))
.andRespond(withSuccess(gson.toJson(pkgmSubscription), MediaType.APPLICATION_JSON));
+ mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + ID)).andExpect(method(HttpMethod.GET))
+ .andRespond(withSuccess(gson.toJson(new NsdmSubscription().id(ID)), MediaType.APPLICATION_JSON));
sol003PackageManagementSubscriptionController.postSubscriptionRequest(pkgmSubscriptionRequest);
- ResponseEntity<List<InlineResponse2002>> response =
+ final ResponseEntity<List<InlineResponse2002>> response =
sol003PackageManagementSubscriptionController.getSubscriptions();
- List<InlineResponse2002> subscriptionsList = response.getBody();
+ final List<InlineResponse2002> subscriptionsList = response.getBody();
assertEquals(Objects.requireNonNull(response.getBody()).get(0).getFilter(),
pkgmSubscriptionRequest.getFilter());
@@ -199,6 +205,70 @@ public class Sol003PackageManagementSubscriptionControllerTest {
assertEquals(HttpStatus.OK, response.getStatusCode());
}
+ @Test
+ public void testSuccessDeleteSubscriptionWithSubscriptionId() throws GeneralSecurityException {
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest = buildPkgmSubscriptionRequest();
+ final PkgmSubscription pkgmSubscription = buildPkgmSubscription();
+ final String subscriptionId = pkgmSubscription.getId();
+
+ mockRestServiceServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST))
+ .andRespond(withSuccess(gson.toJson(pkgmSubscription), MediaType.APPLICATION_JSON));
+
+ mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + subscriptionId)).andExpect(method(HttpMethod.DELETE))
+ .andRespond(withStatus(HttpStatus.NO_CONTENT));
+ mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + subscriptionId)).andExpect(method(HttpMethod.GET))
+ .andRespond(withSuccess(gson.toJson(new NsdmSubscription().id(subscriptionId)),
+ MediaType.APPLICATION_JSON));
+
+ final ResponseEntity<InlineResponse2002> responsePost =
+ (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
+ .postSubscriptionRequest(pkgmSubscriptionRequest);
+
+ final ResponseEntity responseDelete =
+ sol003PackageManagementSubscriptionController.deleteSubscription(subscriptionId);
+
+ // Attempt to retrieve the subscription after delete
+ final ResponseEntity<InlineResponse2002> responseGetSubscription =
+ (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
+ .getSubscription(subscriptionId);
+
+ assertEquals(HttpStatus.NOT_FOUND, responseGetSubscription.getStatusCode());
+ assertEquals(HttpStatus.NO_CONTENT, responseDelete.getStatusCode());
+ }
+
+ @Test
+ public void testDeleteSubscription_SubscripitonNotFoundInEtsiCatalogManager_SubscriptionDeletedFromLocalCache()
+ throws GeneralSecurityException {
+ final PkgmSubscriptionRequest pkgmSubscriptionRequest = buildPkgmSubscriptionRequest();
+ final PkgmSubscription pkgmSubscription = buildPkgmSubscription();
+
+ mockRestServiceServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST))
+ .andRespond(withSuccess(gson.toJson(pkgmSubscription), MediaType.APPLICATION_JSON));
+
+ mockRestServiceServer.expect(requestTo(msbEndpoint + "/" + ID)).andExpect(method(HttpMethod.DELETE))
+ .andRespond(withStatus(HttpStatus.NOT_FOUND));
+
+ final ResponseEntity<InlineResponse2002> responsePost =
+ (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController
+ .postSubscriptionRequest(pkgmSubscriptionRequest);
+
+ final Cache cache = cacheServiceProvider.getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE);
+ assertNotNull(cache.get(ID));
+
+ final ResponseEntity responseDelete = sol003PackageManagementSubscriptionController.deleteSubscription(ID);
+
+ assertEquals(HttpStatus.NO_CONTENT, responseDelete.getStatusCode());
+ assertNull(cache.get(ID));
+
+ }
+
+ @Test
+ public void testFailDeleteSubscriptionWithInvalidSubscriptionId() throws URISyntaxException, InterruptedException {
+ final ResponseEntity<Void> responseDelete = (ResponseEntity<Void>) sol003PackageManagementSubscriptionController
+ .deleteSubscription("invalidSubscriptionId");
+ assertEquals(HttpStatus.NOT_FOUND, responseDelete.getStatusCode());
+ }
+
private PkgmSubscriptionRequest buildPkgmSubscriptionRequest() {
final PkgmSubscriptionRequest pkgmSubscriptionRequest = new PkgmSubscriptionRequest();
final SubscriptionsFilter sub = buildSubscriptionsFilter();
@@ -227,11 +297,11 @@ public class Sol003PackageManagementSubscriptionControllerTest {
}
private PkgmSubscription buildPkgmSubscription() {
- PkgmSubscription pkgmSubscription = new PkgmSubscription();
- PkgmNotificationsFilter pkgmNotificationsFilter = new PkgmNotificationsFilter();
- LinkSelf linkSelf = new LinkSelf();
- String id = UUID.randomUUID().toString();
- pkgmSubscription.setId(id);
+ final PkgmSubscription pkgmSubscription = new PkgmSubscription();
+ final PkgmNotificationsFilter pkgmNotificationsFilter = new PkgmNotificationsFilter();
+ final LinkSelf linkSelf = new LinkSelf();
+
+ pkgmSubscription.setId(ID);
pkgmSubscription.setCallbackUri(msbEndpoint + "/" + pkgmSubscription.getId().toString());
pkgmSubscription.setFilter(pkgmNotificationsFilter);
pkgmSubscription.setLinks(linkSelf);
@@ -242,14 +312,14 @@ public class Sol003PackageManagementSubscriptionControllerTest {
final PkgmSubscriptionRequest pkgmSubscriptionRequest = buildPkgmSubscriptionRequest();
final PkgmSubscription pkgmSubscription = buildPkgmSubscription();
- mockRestServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(msbEndpoint)).andExpect(method(HttpMethod.POST))
.andRespond(withSuccess(gson.toJson(pkgmSubscription), MediaType.APPLICATION_JSON));
return pkgmSubscriptionRequest;
}
- private HttpHeaders buildHttpHeaders(String uri) throws URISyntaxException {
+ private HttpHeaders buildHttpHeaders(final String uri) throws URISyntaxException {
final HttpHeaders headers = new HttpHeaders();
- URI myUri = new URI(uri);
+ final URI myUri = new URI(uri);
headers.setLocation(myUri);
return headers;
}