aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-30 15:56:09 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-31 11:09:25 -0400
commit5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch)
tree59a968f27b4b603aacc9d5e7b51fb598aeec5321 /mso-api-handlers/mso-api-handler-infra/src/main/java
parentb6dc38501f3b746426b42d9de4cc883d894149e8 (diff)
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java61
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java58
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java51
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java)10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Actions.java25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java70
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Constants.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java)10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java)501
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandler.java)136
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java76
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java247
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Messages.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java)4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ModelType.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ModelType.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoException.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoException.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java756
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandler.java)132
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java342
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RecipeLookupResult.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestActionMap.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java1661
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java)34
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Status.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Status.java)8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java337
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TestApi.java37
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java57
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java80
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java78
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java)12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java)226
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EService.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EService.java)14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java)92
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java)12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceScaleRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceScaleRequest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java)10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java)97
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java)4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java)10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleNsByStepsData.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsByStepsData.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleNsData.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsData.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleResource.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleResource.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleService.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleService.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java)90
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/package-info.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/package-info.java)4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetails.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetails.java)110
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfo.java)146
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskList.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskList.java)14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReference.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReference.java)112
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValue.java)214
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariables.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariables.java)10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponse.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponse.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/ValidResponses.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValidResponses.java)103
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Value.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Value.java)110
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Variables.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Variables.java)148
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java)26
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java238
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java)162
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java297
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java)30
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequest.java)128
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequest.java)291
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java103
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java162
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java)50
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/InfraUtils.java)40
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java)25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailed.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AsdcClientCallFailed.java)14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java)70
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java120
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java42
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java118
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java236
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java183
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java300
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java83
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java)169
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java89
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Action.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Action.java)20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java)38
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java)76
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Distribution.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Distribution.java)58
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/DistributionStatus.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/DistributionStatus.java)16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/InstanceReferences.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/InstanceReferences.java)120
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Manifest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Manifest.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java)18
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RecoveryAction.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RecoveryAction.java)20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstance.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RelatedInstance.java)136
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java)90
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Request.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Request.java)180
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestDetails.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestDetails.java)208
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestInfo.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestInfo.java)236
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestList.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestList.java)189
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestParameters.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestParameters.java)168
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestReferences.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestReferences.java)192
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestStatus.java)138
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ResourceType.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/ResourceType.java)16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ServiceModelList.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/ServiceModelList.java)118
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Status.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Status.java)16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java)190
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java)230
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java)34
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/package-info.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/package-info.java)58
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ApplyUpdatedConfigValidation.java49
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java75
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java58
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java81
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java111
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java60
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java60
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java232
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestInfoValidation.java67
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java100
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestScopeValidation.java49
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/SubscriberInfoValidation.java51
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java102
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java180
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationRule.java28
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ActionType.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ActionType.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ModelType.java)64
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ObjectFactory.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java)12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestInfo.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestInfo.java)16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestStatusType.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestStatusType.java)6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelName.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelName.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelNames.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java)7
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfInputs.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfInputs.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfOutputs.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfOutputs.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequest.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequest.java)10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequests.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java)8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfType.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfType.java)2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfTypes.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java)9
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/package-info.java (renamed from mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java)4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java66
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java227
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoPropertiesUtils.java57
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java1186
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java376
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java1249
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java327
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestration.java334
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java335
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/OperationalEnvironmentProcessFactory.java54
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java106
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java172
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java145
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java78
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelper.java216
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java286
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java342
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java82
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java92
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/OperationalEnvironmentProcess.java78
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/resources/ManualTasks.xsd48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/resources/application.properties27
157 files changed, 10346 insertions, 8912 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java
new file mode 100644
index 0000000000..67bbc3db8e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandler.common;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class ResponseBuilder {
+
+ @Value("${mso.infra.default.versions.apiMinorVersion}")
+ private String apiMinorVersion;
+ @Value("${mso.infra.default.versions.apiPatchVersion}")
+ private String apiPatchVersion;
+
+ public Response buildResponse(int status, String requestId, Object jsonResponse, String apiVersion) {
+
+ if (apiVersion.matches("v[1-9]")) {
+ apiVersion = apiVersion.substring(1);
+ }
+
+ String latestVersion = apiVersion + "." + apiMinorVersion + "." + apiPatchVersion;
+
+ javax.ws.rs.core.Response.ResponseBuilder builder = Response.status(status)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .header(CommonConstants.X_MINOR_VERSION, apiMinorVersion)
+ .header(CommonConstants.X_PATCH_VERSION, apiPatchVersion)
+ .header(CommonConstants.X_LATEST_VERSION, latestVersion);
+
+ if(StringUtils.isNotBlank(requestId)) {
+ builder.header(CommonConstants.X_TRANSACTION_ID, requestId);
+ }
+
+ return builder.entity(jsonResponse).build();
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java
new file mode 100644
index 0000000000..91ab580b07
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandler.filters;
+
+import java.io.IOException;
+import java.net.URI;
+
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.UriInfo;
+
+import org.onap.so.apihandlerinfra.Constants;
+
+
+@PreMatching
+public class RequestUriFilter implements ContainerRequestFilter {
+
+ private String requestURI;
+ @Override
+ public void filter(ContainerRequestContext context) throws IOException {
+ UriInfo uriInfo = context.getUriInfo();
+ URI baseURI = uriInfo.getBaseUri();
+ requestURI = uriInfo.getPath();
+
+ if(requestURI.contains("onap/so/infra/serviceInstances")){
+ requestURI = requestURI.replaceFirst("serviceInstances", "serviceInstantiation");
+ if(!requestURI.contains(Constants.SERVICE_INSTANCE_PATH)){
+ //Adds /serviceInstances after the version provided in the URI
+ requestURI = new StringBuilder(requestURI).insert(requestURI.indexOf(Constants.SERVICE_INSTANTIATION_PATH) + 24, Constants.SERVICE_INSTANCE_PATH).toString();
+ }
+ requestURI = baseURI + requestURI;
+ URI uri = URI.create(requestURI);
+ context.setRequestUri(uri);
+ }
+ }
+ public String getRequestUri(){
+ return requestURI;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java
new file mode 100644
index 0000000000..d801a94c9b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandler.recipe;
+
+import java.io.IOException;
+
+import org.onap.so.logger.MsoLogger;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.web.client.ResponseErrorHandler;
+
+
+
+public class CamundaClientErrorHandler implements ResponseErrorHandler{
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CamundaClientErrorHandler.class);
+
+ @Override
+ public void handleError(ClientHttpResponse response) throws IOException {
+
+ msoLogger.debug(response.getBody().toString());
+ //msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR,
+ // MsoLogger.ResponseCode.CommunicationError, e.getMessage(), "BPMN", fullURL, null);
+ }
+
+ @Override
+ public boolean hasError(ClientHttpResponse response) throws IOException {
+ HttpStatus.Series series = response.getStatusCode().series();
+ return (HttpStatus.Series.CLIENT_ERROR.equals(series)
+ || HttpStatus.Series.SERVER_ERROR.equals(series));
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
index 5c84e699d8..3eee14e3bf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
/*
* Enum for Status values returned by API Handler to Tail-F
*/
-public enum Action {
+public enum Action implements Actions{
createInstance,
updateInstance,
deleteInstance,
@@ -37,6 +37,10 @@ public enum Action {
removeRelationships,
inPlaceSoftwareUpdate,
applyUpdatedConfig,
+ completeTask,
+ assignInstance,
+ unassignInstance,
compareModel,
- scaleInstance
+ scaleInstance,
+ deactivateAndCloudDelete
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Actions.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Actions.java
new file mode 100644
index 0000000000..5dbe44f58b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Actions.java
@@ -0,0 +1,25 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+public interface Actions {
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java
new file mode 100644
index 0000000000..afe55a23a7
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import java.util.concurrent.Executor;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+@SpringBootApplication(scanBasePackages = { "org.onap"})
+@EnableAsync
+public class ApiHandlerApplication {
+
+ @Value("${mso.async.core-pool-size}")
+ private int corePoolSize;
+
+ @Value("${mso.async.max-pool-size}")
+ private int maxPoolSize;
+
+ @Value("${mso.async.queue-capacity}")
+ private int queueCapacity;
+
+ private static final String LOGS_DIR = "logs_dir";
+
+ private static void setLogsDir() {
+ if (System.getProperty(LOGS_DIR) == null) {
+ System.getProperties().setProperty(LOGS_DIR, "./logs/apih/");
+ }
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(ApiHandlerApplication.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+ System.getProperties().setProperty("server.name", "Springboot");
+ setLogsDir();
+ }
+
+ @Bean
+ public Executor asyncExecutor() {
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ executor.setCorePoolSize(corePoolSize);
+ executor.setMaxPoolSize(maxPoolSize);
+ executor.setQueueCapacity(queueCapacity);
+ executor.setThreadNamePrefix("mso-apihandler-infra-");
+ executor.initialize();
+ return executor;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Constants.java
index 477a7e46b4..fe105a7637 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Constants.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
public class Constants {
@@ -45,4 +45,8 @@ public class Constants {
public static final String A_LA_CARTE = "aLaCarte";
public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+
+ public final static String VNF_REQUEST_SCOPE = "vnf";
+ public final static String SERVICE_INSTANCE_PATH = "/serviceInstances";
+ public final static String SERVICE_INSTANTIATION_PATH = "/serviceInstantiation";
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
index ca821ecbc3..ee50d920fe 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
import java.io.IOException;
import java.util.ArrayList;
@@ -40,52 +40,80 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandler.common.RequestClient;
-import org.openecomp.mso.apihandler.common.RequestClientFactory;
-import org.openecomp.mso.apihandler.common.RequestClientParamater;
-import org.openecomp.mso.apihandler.common.ResponseHandler;
-import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.CompareModelsRequest;
-import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceDeleteRequest;
-import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest;
-import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceScaleRequest;
-import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoAlarmLogger;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.OperationStatus;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.serviceinstancebeans.ModelInfo;
-import org.openecomp.mso.serviceinstancebeans.ModelType;
-import org.openecomp.mso.serviceinstancebeans.RequestDetails;
-import org.openecomp.mso.serviceinstancebeans.RequestInfo;
-import org.openecomp.mso.serviceinstancebeans.RequestParameters;
-import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest;
-import org.openecomp.mso.serviceinstancebeans.SubscriberInfo;
-import org.openecomp.mso.utils.UUIDChecker;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.RequestClient;
+import org.onap.so.apihandler.common.RequestClientFactory;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandler.common.ResponseHandler;
+import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.CompareModelsRequest;
+import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceDeleteRequest;
+import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest;
+import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceScaleRequest;
+import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
+import org.onap.so.db.catalog.data.repository.ServiceRecipeRepository;
+import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.db.request.beans.OperationStatus;
+import org.onap.so.db.request.data.repository.OperationStatusRepository;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoAlarmLogger;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.SubscriberInfo;
+import org.onap.so.utils.UUIDChecker;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
+@Component
@Path("/e2eServiceInstances")
@Api(value = "/e2eServiceInstances", description = "API Requests for E2E Service Instances")
public class E2EServiceInstances {
private HashMap<String, String> instanceIdMap = new HashMap<>();
private static MsoLogger msoLogger = MsoLogger
- .getMsoLogger(MsoLogger.Catalog.APIH);
+ .getMsoLogger(MsoLogger.Catalog.APIH, E2EServiceInstances.class);
private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
public static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
- private ServiceInstancesRequest sir = null;
public static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: ";
+ public static final String EXCEPTION_CREATING_DB_RECORD = "Exception while creating record in DB";
+ public static final String EXCEPTION_COMMUNICATE_BPMN_ENGINE = "Exception while communicate with BPMN engine";
+
+ @Autowired
+ private MsoRequest msoRequest;
+
+ @Autowired
+ private RequestClientFactory requestClientFactory;
+
+ @Autowired
+ private OperationStatusRepository osRepo;
+
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Autowired
+ private ServiceRecipeRepository sRecipeRepo;
+
+ @Autowired
+ private ResponseBuilder builder;
/**
* POST Requests for E2E Service create Instance on a version provided
+ * @throws ApiException
*/
@POST
@@ -94,7 +122,7 @@ public class E2EServiceInstances {
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Create an E2E Service Instance on a version provided", response = Response.class)
public Response createE2EServiceInstance(String request,
- @PathParam("version") String version) {
+ @PathParam("version") String version) throws ApiException {
return processE2EserviceInstances(request, Action.createInstance, null,
version);
@@ -102,6 +130,7 @@ public class E2EServiceInstances {
/**
* PUT Requests for E2E Service update Instance on a version provided
+ * @throws ApiException
*/
@PUT
@@ -111,7 +140,7 @@ public class E2EServiceInstances {
@ApiOperation(value = "Update an E2E Service Instance on a version provided and serviceId", response = Response.class)
public Response updateE2EServiceInstance(String request,
@PathParam("version") String version,
- @PathParam("serviceId") String serviceId) {
+ @PathParam("serviceId") String serviceId) throws ApiException {
instanceIdMap.put("serviceId", serviceId);
@@ -122,6 +151,7 @@ public class E2EServiceInstances {
/**
* DELETE Requests for E2E Service delete Instance on a specified version
* and serviceId
+ * @throws ApiException
*/
@DELETE
@@ -131,7 +161,7 @@ public class E2EServiceInstances {
@ApiOperation(value = "Delete E2E Service Instance on a specified version and serviceId", response = Response.class)
public Response deleteE2EServiceInstance(String request,
@PathParam("version") String version,
- @PathParam("serviceId") String serviceId) {
+ @PathParam("serviceId") String serviceId) throws ApiException {
instanceIdMap.put("serviceId", serviceId);
@@ -147,11 +177,12 @@ public class E2EServiceInstances {
@PathParam("serviceId") String serviceId,
@PathParam("version") String version,
@PathParam("operationId") String operationId) {
- return getE2EServiceInstances(serviceId, operationId);
+ return getE2EServiceInstance(serviceId, operationId, version);
}
/**
* Scale Requests for E2E Service scale Instance on a specified version
+ * @throws ApiException
*/
@POST
@@ -161,7 +192,7 @@ public class E2EServiceInstances {
@ApiOperation(value="Scale E2E Service Instance on a specified version",response=Response.class)
public Response scaleE2EServiceInstance(String request,
@PathParam("version") String version,
- @PathParam("serviceId") String serviceId) {
+ @PathParam("serviceId") String serviceId) throws ApiException {
msoLogger.debug("------------------scale begin------------------");
instanceIdMap.put("serviceId", serviceId);
@@ -169,6 +200,7 @@ public class E2EServiceInstances {
}
/**
* GET Requests for Comparing model of service instance with target version
+ * @throws ApiException
*/
@POST
@@ -178,7 +210,7 @@ public class E2EServiceInstances {
@ApiOperation(value = "Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId ", response = Response.class)
public Response compareModelwithTargetVersion(String request,
@PathParam("serviceId") String serviceId,
- @PathParam("version") String version) {
+ @PathParam("version") String version) throws ApiException {
instanceIdMap.put("serviceId", serviceId);
@@ -186,7 +218,7 @@ public class E2EServiceInstances {
}
private Response compareModelwithTargetVersion(String requestJSON, Action action,
- HashMap<String, String> instanceIdMap, String version) {
+ HashMap<String, String> instanceIdMap, String version) throws ApiException {
String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
@@ -194,8 +226,6 @@ public class E2EServiceInstances {
CompareModelsRequest e2eCompareModelReq = null;
- MsoRequest msoRequest = new MsoRequest(requestId);
-
ObjectMapper mapper = new ObjectMapper();
try {
e2eCompareModelReq = mapper.readValue(requestJSON, CompareModelsRequest.class);
@@ -205,7 +235,7 @@ public class E2EServiceInstances {
msoLogger.debug("Mapping of request to JSON object failed : ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
+ ErrorNumbers.SVC_BAD_PARAMETER, null, version);
msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
@@ -215,15 +245,16 @@ public class E2EServiceInstances {
return response;
}
- return runCompareModelBPMWorkflow(e2eCompareModelReq, msoRequest, requestJSON, requestId, startTime, action);
+ return runCompareModelBPMWorkflow(e2eCompareModelReq, requestJSON, requestId, startTime, action, version);
}
- private Response runCompareModelBPMWorkflow(CompareModelsRequest e2eCompareModelReq, MsoRequest msoRequest,
- String requestJSON, String requestId, long startTime, Action action) {
+ private Response runCompareModelBPMWorkflow(CompareModelsRequest e2eCompareModelReq,
+ String requestJSON, String requestId, long startTime, Action action, String version) throws ApiException {
// Define RecipeLookupResult info here instead of query DB for efficiency
String workflowUrl = "/mso/async/services/CompareModelofE2EServiceInstance";
+ int recipeTimeout = 180;
RequestClient requestClient = null;
HttpResponse response = null;
@@ -231,18 +262,25 @@ public class E2EServiceInstances {
long subStartTime = System.currentTimeMillis();
try {
- requestClient = RequestClientFactory.getRequestClient(workflowUrl, MsoPropertiesUtils.loadMsoProperties());
+ requestClient = requestClientFactory.getRequestClient(workflowUrl);
JSONObject jjo = new JSONObject(requestJSON);
+ String bpmnRequest = jjo.toString();
// Capture audit event
msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
- RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId).
- setBaseVfModule(false).setRecipeTimeout(180).setRequestAction(action.name()).
- setServiceInstanceId(instanceIdMap.get("serviceId")).setServiceType(e2eCompareModelReq.getServiceType()).
- setRequestDetails(jjo.toString()).build();
-
- response = requestClient.post(requestClientParamater);
+ String serviceId = instanceIdMap.get("serviceId");
+ String serviceType = e2eCompareModelReq.getServiceType();
+ RequestClientParameter postParam = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(false)
+ .setRecipeTimeout(recipeTimeout)
+ .setRequestAction(action.name())
+ .setServiceInstanceId(serviceId)
+ .setServiceType(serviceType)
+ .setRequestDetails(bpmnRequest)
+ .setALaCarte(false).build();
+ response = requestClient.post(postParam);
msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
"Successfully received response from BPMN engine", "BPMN", workflowUrl, null);
@@ -252,7 +290,7 @@ public class E2EServiceInstances {
workflowUrl, null);
Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
@@ -264,8 +302,8 @@ public class E2EServiceInstances {
}
if (response == null) {
- Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
+ "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
@@ -277,23 +315,22 @@ public class E2EServiceInstances {
ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
int bpelStatus = respHandler.getStatus();
- return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action,
- instanceIdMap);
+ return beplStatusUpdate(requestId, startTime, requestClient, respHandler, bpelStatus, action,
+ instanceIdMap, version);
}
- private Response getE2EServiceInstances(String serviceId, String operationId) {
- RequestsDatabase requestsDB = RequestsDatabase.getInstance();
+ private Response getE2EServiceInstance(String serviceId, String operationId, String version) {
GetE2EServiceInstanceResponse e2eServiceResponse = new GetE2EServiceInstanceResponse();
- MsoRequest msoRequest = new MsoRequest(serviceId);
-
+ String apiVersion = version.substring(1);
+
long startTime = System.currentTimeMillis();
OperationStatus operationStatus = null;
try {
- operationStatus = requestsDB.getOperationStatus(serviceId,
+ operationStatus = osRepo.findOneByServiceIdAndOperationId(serviceId,
operationId);
} catch (Exception e) {
@@ -304,13 +341,11 @@ public class E2EServiceInstances {
"",
MsoLogger.ErrorCode.AvailabilityError,
"Exception while communciate with Request DB - Infra Request Lookup",
- e);
- msoRequest
- .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ e);
Response response = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
e.getMessage(),
- ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null);
+ ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null, version);
alarmLogger.sendAlarm("MsoDatabaseAccessError",
MsoAlarmLogger.CRITICAL, Messages.errors
.get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
@@ -327,7 +362,7 @@ public class E2EServiceInstances {
Response resp = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_NO_CONTENT, MsoException.ServiceException,
"E2E serviceId " + serviceId + " is not found in DB",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null, version);
msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.BusinessProcesssError,
@@ -343,19 +378,17 @@ public class E2EServiceInstances {
e2eServiceResponse.setOperationStatus(operationStatus);
- return Response.status(200).entity(e2eServiceResponse).build();
+ return builder.buildResponse(HttpStatus.SC_OK, null, e2eServiceResponse, apiVersion);
}
private Response deleteE2EserviceInstances(String requestJSON,
- Action action, HashMap<String, String> instanceIdMap, String version) {
+ Action action, HashMap<String, String> instanceIdMap, String version) throws ApiException {
// TODO should be a new one or the same service instance Id
String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
E2EServiceInstanceDeleteRequest e2eDelReq = null;
- MsoRequest msoRequest = new MsoRequest(requestId);
-
ObjectMapper mapper = new ObjectMapper();
try {
e2eDelReq = mapper.readValue(requestJSON,
@@ -369,7 +402,7 @@ public class E2EServiceInstances {
MsoException.ServiceException,
"Mapping of request to JSON object failed. "
+ e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER,
- null);
+ null, version);
msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,
MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
@@ -381,47 +414,42 @@ public class E2EServiceInstances {
return response;
}
- CatalogDatabase db = null;
RecipeLookupResult recipeLookupResult = null;
try {
- db = CatalogDatabase.getInstance();
//TODO Get the service template model version uuid from AAI.
- recipeLookupResult = getServiceInstanceOrchestrationURI(db, null, action);
+ recipeLookupResult = getServiceInstanceOrchestrationURI(null, action);
} catch (Exception e) {
msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC,
MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.AvailabilityError,
"Exception while communciate with Catalog DB", e);
- msoRequest
- .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+
Response response = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
"No communication to catalog DB " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
alarmLogger.sendAlarm("MsoDatabaseAccessError",
MsoAlarmLogger.CRITICAL, Messages.errors
- .get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
- msoRequest.createRequestRecord(Status.FAILED, action);
+ .get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+ msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Exception while communciate with Catalog DB", action, ModelType.service.name(), requestJSON);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with DB");
msoLogger.debug(END_OF_THE_TRANSACTION
+ (String) response.getEntity());
return response;
- } finally {
- closeCatalogDB(db);
}
if (recipeLookupResult == null) {
msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND,
MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.DataError, "No recipe found in DB");
- msoRequest
- .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ MsoLogger.ErrorCode.DataError, "No recipe found in DB");
Response response = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
"Recipe does not exist in catalog DB",
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
- msoRequest.createRequestRecord(Status.FAILED, action);
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
+
+ msoRequest.createErrorRequestRecord(Status.FAILED, requestId,"Recipe does not exist in catalog DB", action, ModelType.service.name(), requestJSON);
+
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
@@ -435,23 +463,31 @@ public class E2EServiceInstances {
long subStartTime = System.currentTimeMillis();
try {
- requestClient = RequestClientFactory.getRequestClient(
- recipeLookupResult.getOrchestrationURI(),
- MsoPropertiesUtils.loadMsoProperties());
+ requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI());
JSONObject jjo = new JSONObject(requestJSON);
jjo.put("operationId", UUIDChecker.generateUUID(msoLogger));
+
+ String bpmnRequest = jjo.toString();
+
// Capture audit event
msoLogger
.debug("MSO API Handler Posting call to BPEL engine for url: "
+ requestClient.getUrl());
-
- RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId).
- setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).
- setRequestAction(action.name()).setServiceInstanceId(instanceIdMap.get("serviceId")).
- setServiceType(e2eDelReq.getServiceType()).setRequestDetails(jjo.toString()).
- setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
- response = requestClient.post(requestClientParamater);
+ String serviceId = instanceIdMap.get("serviceId");
+ String serviceInstanceType = e2eDelReq.getServiceType();
+ RequestClientParameter clientParam = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(false)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.name())
+ .setServiceInstanceId(serviceId)
+ .setServiceType(serviceInstanceType)
+ .setRequestDetails(bpmnRequest)
+ .setApiVersion(version)
+ .setALaCarte(false)
+ .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
+ response = requestClient.post(clientParam);
msoLogger.recordMetricEvent(subStartTime,
MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
@@ -466,7 +502,7 @@ public class E2EServiceInstances {
Response resp = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
"Failed calling bpmn " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
alarmLogger.sendAlarm("MsoConfigurationError",
MsoAlarmLogger.CRITICAL,
Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
@@ -486,7 +522,7 @@ public class E2EServiceInstances {
Response resp = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
"bpelResponse is null",
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.BusinessProcesssError,
@@ -502,12 +538,12 @@ public class E2EServiceInstances {
requestClient.getType());
int bpelStatus = respHandler.getStatus();
- return beplStatusUpdate(requestId, startTime, msoRequest,
- requestClient, respHandler, bpelStatus, action, instanceIdMap);
+ return beplStatusUpdate(requestId, startTime, requestClient, respHandler,
+ bpelStatus, action, instanceIdMap, version);
}
private Response updateE2EserviceInstances(String requestJSON, Action action,
- HashMap<String, String> instanceIdMap, String version) {
+ HashMap<String, String> instanceIdMap, String version) throws ApiException {
String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
@@ -515,7 +551,6 @@ public class E2EServiceInstances {
E2EServiceInstanceRequest e2eSir = null;
String serviceId = instanceIdMap.get("serviceId");
- MsoRequest msoRequest = new MsoRequest(requestId);
ObjectMapper mapper = new ObjectMapper();
try {
e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
@@ -525,7 +560,7 @@ public class E2EServiceInstances {
msoLogger.debug("Mapping of request to JSON object failed : ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
+ ErrorNumbers.SVC_BAD_PARAMETER, null, version);
msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
@@ -534,16 +569,16 @@ public class E2EServiceInstances {
return response;
}
- mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+ ServiceInstancesRequest sir = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
sir.getRequestDetails().getRequestParameters().setaLaCarte(true);
try {
- msoRequest.parse(sir, instanceIdMap, action, version, requestJSON);
+ parseRequest(sir, instanceIdMap, action, version, requestJSON, false, requestId);
} catch (Exception e) {
msoLogger.debug("Validation failed: ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
MsoException.ServiceException, "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId() != null) {
+ ErrorNumbers.SVC_BAD_PARAMETER, null, version);
+ if (requestId != null) {
msoLogger.debug("Logging failed message to the database");
}
msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
@@ -554,18 +589,15 @@ public class E2EServiceInstances {
return response;
}
- CatalogDatabase db = null;
RecipeLookupResult recipeLookupResult = null;
try {
- db = CatalogDatabase.getInstance();
- recipeLookupResult = getServiceInstanceOrchestrationURI(db, e2eSir.getService().getServiceUuid(), action);
+ recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action);
} catch (Exception e) {
msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
- msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
@@ -574,17 +606,14 @@ public class E2EServiceInstances {
msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
return response;
- } finally {
- closeCatalogDB(db);
}
if (recipeLookupResult == null) {
msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.DataError, "No recipe found in DB");
- msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ MsoLogger.ErrorCode.DataError, "No recipe found in DB");
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
MsoException.ServiceException, "Recipe does not exist in catalog DB",
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
@@ -599,19 +628,25 @@ public class E2EServiceInstances {
HttpResponse response = null;
long subStartTime = System.currentTimeMillis();
+ String sirRequestJson = convertToString(sir);
+
try {
- requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(),
- MsoPropertiesUtils.loadMsoProperties());
+ requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI());
// Capture audit event
msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
- RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId).
- setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()).
- setServiceInstanceId(serviceId).setServiceType(serviceInstanceType).
- setRequestDetails(mapReqJsonToSvcInstReq(e2eSir, requestJSON)).
- setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
-
- response = requestClient.post(requestClientParamater);
+ RequestClientParameter postParam = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(false)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.name())
+ .setServiceInstanceId(serviceId)
+ .setServiceType(serviceInstanceType)
+ .setRequestDetails(sirRequestJson)
+ .setApiVersion(version)
+ .setALaCarte(false)
+ .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
+ response = requestClient.post(postParam);
msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
"Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(),
@@ -623,7 +658,7 @@ public class E2EServiceInstances {
recipeLookupResult.getOrchestrationURI(), null);
Response getBPMNResp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
@@ -637,41 +672,41 @@ public class E2EServiceInstances {
if (response == null) {
Response getBPMNResp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
"Null response from BPMN");
msoLogger.debug(END_OF_THE_TRANSACTION + (String) getBPMNResp.getEntity());
-
return getBPMNResp;
}
ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
int bpelStatus = respHandler.getStatus();
- return beplStatusUpdate(serviceId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action, instanceIdMap);
+ return beplStatusUpdate(serviceId, startTime, requestClient, respHandler,
+ bpelStatus, action, instanceIdMap, version);
}
-
+
private Response processE2EserviceInstances(String requestJSON, Action action,
- HashMap<String, String> instanceIdMap, String version) {
+ HashMap<String, String> instanceIdMap, String version) throws ApiException {
String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
E2EServiceInstanceRequest e2eSir = null;
- MsoRequest msoRequest = new MsoRequest(requestId);
+ MsoRequest msoRequest = new MsoRequest();
ObjectMapper mapper = new ObjectMapper();
try {
e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
} catch (Exception e) {
-
+
msoLogger.debug("Mapping of request to JSON object failed : ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
+ ErrorNumbers.SVC_BAD_PARAMETER, null, version);
msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
@@ -680,16 +715,16 @@ public class E2EServiceInstances {
return response;
}
- mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+ ServiceInstancesRequest sir = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
sir.getRequestDetails().getRequestParameters().setaLaCarte(true);
try {
- msoRequest.parse(sir, instanceIdMap, action, version, requestJSON);
+ parseRequest(sir, instanceIdMap, action, version, requestJSON, false, requestId);
} catch (Exception e) {
msoLogger.debug("Validation failed: ", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
MsoException.ServiceException, "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId() != null) {
+ ErrorNumbers.SVC_BAD_PARAMETER, null, version);
+ if (requestId != null) {
msoLogger.debug("Logging failed message to the database");
}
msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
@@ -698,20 +733,17 @@ public class E2EServiceInstances {
"Validation of the input request failed");
msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
return response;
- }
-
- CatalogDatabase db = null;
+ }
+
RecipeLookupResult recipeLookupResult = null;
try {
- db = CatalogDatabase.getInstance();
- recipeLookupResult = getServiceInstanceOrchestrationURI(db, e2eSir.getService().getServiceUuid(), action);
+ recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action);
} catch (Exception e) {
msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
- msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
@@ -719,17 +751,14 @@ public class E2EServiceInstances {
"Exception while communciate with DB");
msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
return response;
- } finally {
- closeCatalogDB(db);
}
if (recipeLookupResult == null) {
msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.DataError, "No recipe found in DB");
- msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ MsoLogger.ErrorCode.DataError, "No recipe found in DB");
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
MsoException.ServiceException, "Recipe does not exist in catalog DB",
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
@@ -737,23 +766,32 @@ public class E2EServiceInstances {
return response;
}
+ String serviceInstanceType = e2eSir.getService().getServiceType();
+
+ String serviceId = "";
RequestClient requestClient = null;
HttpResponse response = null;
long subStartTime = System.currentTimeMillis();
+ String sirRequestJson = convertToString(sir);
+
try {
- requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(),
- MsoPropertiesUtils.loadMsoProperties());
+ requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI());
// Capture audit event
msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
- RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId).
- setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()).
- setServiceInstanceId("").setServiceType(e2eSir.getService().getServiceType()).
- setRequestDetails(mapReqJsonToSvcInstReq(e2eSir, requestJSON)).
- setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
-
- response = requestClient.post(requestClientParamater);
+ RequestClientParameter parameter = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(false)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.name())
+ .setServiceInstanceId(serviceId)
+ .setServiceType(serviceInstanceType)
+ .setRequestDetails(sirRequestJson)
+ .setApiVersion(version)
+ .setALaCarte(false)
+ .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
+ response = requestClient.post(parameter);
msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
"Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(),
@@ -764,7 +802,7 @@ public class E2EServiceInstances {
recipeLookupResult.getOrchestrationURI(), null);
Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
@@ -777,7 +815,7 @@ public class E2EServiceInstances {
if (response == null) {
Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
@@ -789,19 +827,18 @@ public class E2EServiceInstances {
ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
int bpelStatus = respHandler.getStatus();
- return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action, instanceIdMap);
+ return beplStatusUpdate(requestId, startTime, requestClient, respHandler,
+ bpelStatus, action, instanceIdMap, version);
}
private Response scaleE2EserviceInstances(String requestJSON,
- Action action, HashMap<String, String> instanceIdMap, String version) {
+ Action action, HashMap<String, String> instanceIdMap, String version) throws ApiException {
String requestId = UUIDChecker.generateUUID(msoLogger);
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
E2EServiceInstanceScaleRequest e2eScaleReq = null;
- MsoRequest msoRequest = new MsoRequest(requestId);
-
ObjectMapper mapper = new ObjectMapper();
try {
e2eScaleReq = mapper.readValue(requestJSON,
@@ -815,7 +852,7 @@ public class E2EServiceInstances {
MsoException.ServiceException,
"Mapping of request to JSON object failed. "
+ e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER,
- null);
+ null, version);
msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,
MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
@@ -827,47 +864,41 @@ public class E2EServiceInstances {
return response;
}
- CatalogDatabase db = null;
RecipeLookupResult recipeLookupResult = null;
try {
- db = CatalogDatabase.getInstance();
//TODO Get the service template model version uuid from AAI.
- recipeLookupResult = getServiceInstanceOrchestrationURI(db, null, action);
+ recipeLookupResult = getServiceInstanceOrchestrationURI(null, action);
} catch (Exception e) {
msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC,
MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.AvailabilityError,
"Exception while communciate with Catalog DB", e);
- msoRequest
- .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+
Response response = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
"No communication to catalog DB " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
alarmLogger.sendAlarm("MsoDatabaseAccessError",
MsoAlarmLogger.CRITICAL, Messages.errors
- .get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
- msoRequest.createRequestRecord(Status.FAILED, action);
+ .get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+ msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with DB");
msoLogger.debug(END_OF_THE_TRANSACTION
+ (String) response.getEntity());
return response;
- } finally {
- closeCatalogDB(db);
}
if (recipeLookupResult == null) {
msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND,
MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.DataError, "No recipe found in DB");
- msoRequest
- .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+
Response response = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
"Recipe does not exist in catalog DB",
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
- msoRequest.createRequestRecord(Status.FAILED, action);
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
+ msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No recipe found in DB", action, ModelType.service.name(), requestJSON);
msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
@@ -881,25 +912,31 @@ public class E2EServiceInstances {
long subStartTime = System.currentTimeMillis();
try {
- requestClient = RequestClientFactory.getRequestClient(
- recipeLookupResult.getOrchestrationURI(),
- MsoPropertiesUtils.loadMsoProperties());
+ requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI());
JSONObject jjo = new JSONObject(requestJSON);
jjo.put("operationId", UUIDChecker.generateUUID(msoLogger));
+ String bpmnRequest = jjo.toString();
+
// Capture audit event
msoLogger
.debug("MSO API Handler Posting call to BPEL engine for url: "
+ requestClient.getUrl());
- RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId).
- setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()).
- setServiceInstanceId(instanceIdMap.get("serviceId")).
- setServiceType(e2eScaleReq.getService().getServiceType()).
- setRequestDetails(jjo.toString()).
- setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
-
- response = requestClient.post(requestClientParamater);
+ String serviceId = instanceIdMap.get("serviceId");
+ String serviceInstanceType = e2eScaleReq.getService().getServiceType();
+ RequestClientParameter postParam = new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(false)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.name())
+ .setServiceInstanceId(serviceId)
+ .setServiceType(serviceInstanceType)
+ .setRequestDetails(bpmnRequest)
+ .setApiVersion(version)
+ .setALaCarte(false)
+ .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
+ response = requestClient.post(postParam);
msoLogger.recordMetricEvent(subStartTime,
MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
@@ -914,7 +951,7 @@ public class E2EServiceInstances {
Response resp = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
"Failed calling bpmn " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
alarmLogger.sendAlarm("MsoConfigurationError",
MsoAlarmLogger.CRITICAL,
Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
@@ -934,7 +971,7 @@ public class E2EServiceInstances {
Response resp = msoRequest.buildServiceErrorResponse(
HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
"bpelResponse is null",
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.BusinessProcesssError,
@@ -950,41 +987,37 @@ public class E2EServiceInstances {
requestClient.getType());
int bpelStatus = respHandler.getStatus();
- return beplStatusUpdate(requestId, startTime, msoRequest,
- requestClient, respHandler, bpelStatus, action, instanceIdMap);
+ return beplStatusUpdate(requestId, startTime, requestClient, respHandler,
+ bpelStatus, action, instanceIdMap, version);
}
- private void closeCatalogDB(CatalogDatabase db) {
- if (db != null) {
- db.close();
- }
- }
-
private Response beplStatusUpdate(String serviceId, long startTime,
- MsoRequest msoRequest, RequestClient requestClient,
+ RequestClient requestClient,
ResponseHandler respHandler, int bpelStatus, Action action,
- HashMap<String, String> instanceIdMap) {
+ HashMap<String, String> instanceIdMap, String version) {
+
+ String apiVersion = version.substring(1);
+
// BPMN accepted the request, the request is in progress
if (bpelStatus == HttpStatus.SC_ACCEPTED) {
- String camundaJSONResponseBody = respHandler.getContent();
+ String camundaJSONResponseBody = respHandler.getResponseBody();
msoLogger.debug("Received from Camunda: " + camundaJSONResponseBody);
msoLogger.recordAuditEvent(startTime,
MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
"BPMN accepted the request, the request is in progress");
msoLogger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody);
- return Response.status(HttpStatus.SC_ACCEPTED)
- .entity(camundaJSONResponseBody).build();
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, null, camundaJSONResponseBody, apiVersion);
} else {
List<String> variables = new ArrayList<>();
variables.add(bpelStatus + "");
- String camundaJSONResponseBody = respHandler.getContent();
+ String camundaJSONResponseBody = respHandler.getResponseBody();
if (camundaJSONResponseBody != null
&& !camundaJSONResponseBody.isEmpty()) {
Response resp = msoRequest.buildServiceErrorResponse(
bpelStatus, MsoException.ServiceException,
"Request Failed due to BPEL error with HTTP Status= %1 "
+ '\n' + camundaJSONResponseBody,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables, version);
msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
requestClient.getUrl(), "", "",
MsoLogger.ErrorCode.BusinessProcesssError,
@@ -1004,7 +1037,7 @@ public class E2EServiceInstances {
MsoException.ServiceException,
"Request Failed due to BPEL error with HTTP Status= %1",
ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- variables);
+ variables, version);
msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
requestClient.getUrl(), "", "",
MsoLogger.ErrorCode.BusinessProcesssError,
@@ -1028,10 +1061,9 @@ public class E2EServiceInstances {
* @param action the action for the service
* @return the service recipe result
*/
- private RecipeLookupResult getServiceInstanceOrchestrationURI(
- CatalogDatabase db, String serviceModelUUID, Action action) {
+ private RecipeLookupResult getServiceInstanceOrchestrationURI(String serviceModelUUID, Action action) {
- RecipeLookupResult recipeLookupResult = getServiceURI(db, serviceModelUUID, action);
+ RecipeLookupResult recipeLookupResult = getServiceURI(serviceModelUUID, action);
if (recipeLookupResult != null) {
msoLogger.debug("Orchestration URI is: "
@@ -1052,19 +1084,17 @@ public class E2EServiceInstances {
* @param action the action of the service.
* @return the service recipe result.
*/
- private RecipeLookupResult getServiceURI(CatalogDatabase db, String serviceModelUUID, Action action) {
+ private RecipeLookupResult getServiceURI(String serviceModelUUID, Action action) {
String defaultServiceModelName = "UUI_DEFAULT";
- Service defaultServiceRecord = db
- .getServiceByModelName(defaultServiceModelName);
- ServiceRecipe defaultRecipe = db.getServiceRecipeByModelUUID(
- defaultServiceRecord.getModelUUID(), action.name());
+ Service defaultServiceRecord = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
+ ServiceRecipe defaultRecipe = sRecipeRepo.findFirstByServiceModelUUIDAndAction(defaultServiceRecord.getModelUUID(), action.name());
//set recipe as default generic recipe
ServiceRecipe recipe = defaultRecipe;
//check the service special recipe
if(null != serviceModelUUID && ! serviceModelUUID.isEmpty()){
- ServiceRecipe serviceSpecialRecipe = db.getServiceRecipeByModelUUID(
+ ServiceRecipe serviceSpecialRecipe = sRecipeRepo.findFirstByServiceModelUUIDAndAction(
serviceModelUUID, action.name());
if(null != serviceSpecialRecipe){
//set service special recipe.
@@ -1076,7 +1106,7 @@ public class E2EServiceInstances {
return null;
}
return new RecipeLookupResult(recipe.getOrchestrationUri(),
- recipe.getRecipeTimeout(), recipe.getServiceParamXSD());
+ recipe.getRecipeTimeout(), recipe.getParamXsd());
}
@@ -1087,10 +1117,10 @@ public class E2EServiceInstances {
* @param e2eSir
* @return
*/
- private String mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir,
+ private ServiceInstancesRequest mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir,
String requestJSON) {
- sir = new ServiceInstancesRequest();
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
String returnString = null;
RequestDetails requestDetails = new RequestDetails();
@@ -1173,6 +1203,28 @@ public class E2EServiceInstances {
sir.setRequestDetails(requestDetails);
+ return sir;
+ }
+
+
+ private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Action action, String version,
+ String requestJSON, Boolean aLaCarte, String requestId) throws ValidateException {
+ int reqVersion = Integer.parseInt(version.substring(1));
+ try {
+ msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte);
+ } catch (Exception e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+
+ msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, ModelType.service.name(), requestJSON);
+
+ throw validateException;
+ }
+ }
+
+ private String convertToString(ServiceInstancesRequest sir) {
+ String returnString = null;
// converting to string
ObjectMapper mapper = new ObjectMapper();
try {
@@ -1185,5 +1237,4 @@ public class E2EServiceInstances {
return returnString;
}
-
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java
index 811b6109b4..7a8035ac63 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java
@@ -1,66 +1,70 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra;
-
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
-
-import org.openecomp.mso.HealthCheckUtils;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/globalhealthcheck")
-@Api(value="/globalhealthcheck",description="APIH Infra Global Health Check")
-public class GlobalHealthcheckHandler {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
-
- @HEAD
- @GET
- @Produces("text/html")
- @ApiOperation(value="Performing global health check",response=Response.class)
- public Response globalHealthcheck (@DefaultValue("true") @QueryParam("enableBpmn") boolean enableBpmn) {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName ("GlobalHealthcheck");
- // Generate a Request Id
- String requestId = UUIDChecker.generateUUID(msoLogger);
- HealthCheckUtils healthCheck = new HealthCheckUtils ();
- if (!healthCheck.siteStatusCheck (msoLogger)) {
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
-
- if (healthCheck.verifyGlobalHealthCheck(enableBpmn, requestId)) {
- msoLogger.debug("globalHealthcheck - Successful");
- return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
- } else {
- msoLogger.debug("globalHealthcheck - At leaset one of the sub-modules is not available");
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.utils.UUIDChecker;
+import org.springframework.stereotype.Component;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+
+
+@Component
+@Path("/globalhealthcheck")
+@Api(value="/globalhealthcheck",description="APIH Infra Global Health Check")
+public class GlobalHealthcheckHandler {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH,GlobalHealthcheckHandler.class);
+ private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
+
+ public static final Response HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK)
+ .entity (CHECK_HTML)
+ .build ();
+
+ @GET
+ @Produces("text/html")
+ @ApiOperation(value="Performing global health check",response=Response.class)
+ @Transactional
+ public Response globalHealthcheck (@DefaultValue("true") @QueryParam("enableBpmn") boolean enableBpmn,
+ @Context ContainerRequestContext requestContext) {
+ long startTime = System.currentTimeMillis ();
+ MsoLogger.setServiceName ("GlobalHealthcheck");
+ // Generated RequestId
+ String requestId = requestContext.getProperty("requestId").toString();
+ MsoLogger.setLogContext(requestId, null);
+ msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, "", "");
+ return HEALTH_CHECK_RESPONSE;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
new file mode 100644
index 0000000000..1700e121f0
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import javax.annotation.PostConstruct;
+import javax.ws.rs.ApplicationPath;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletProperties;
+import org.onap.so.apihandler.filters.RequestUriFilter;
+import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration;
+import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging;
+import org.onap.so.web.exceptions.RuntimeExceptionMapper;
+import org.springframework.context.annotation.Configuration;
+
+import io.swagger.jaxrs.config.BeanConfig;
+import io.swagger.jaxrs.listing.ApiListingResource;
+import io.swagger.jaxrs.listing.SwaggerSerializers;
+
+@Configuration
+@ApplicationPath("/")
+public class JerseyConfiguration extends ResourceConfig {
+
+
+
+ @PostConstruct
+ public void setUp() {
+ register(GlobalHealthcheckHandler.class);
+ register(NodeHealthcheckHandler.class);
+ register(ServiceInstances.class);
+ register(TasksHandler.class);
+ register(CloudOrchestration.class);
+ register(CloudResourcesOrchestration.class);
+ register(OrchestrationRequests.class);
+ register(JaxRsFilterLogging.class);
+ register(ManualTasks.class);
+ register(TasksHandler.class);
+ register(ApiListingResource.class);
+ register(SwaggerSerializers.class);
+ register(ApiExceptionMapper.class);
+ register(RuntimeExceptionMapper.class);
+ register(RequestUriFilter.class);
+ register(E2EServiceInstances.class);
+ // this registration seems to be needed to get predictable
+ // execution behavior for the above JSON Exception Mappers
+ register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class);
+ property(ServletProperties.FILTER_FORWARD_ON_404, true);
+ BeanConfig beanConfig = new BeanConfig();
+ beanConfig.setVersion("1.0.2");
+ beanConfig.setSchemes(new String[] { "https" });
+ beanConfig.setResourcePackage("org.onap.so.apihandlerinfra");
+ beanConfig.setPrettyPrint(true);
+ beanConfig.setScan(true);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java
new file mode 100644
index 0000000000..4d8c4ffbd8
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java
@@ -0,0 +1,247 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import java.io.IOException;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.RequestClient;
+import org.onap.so.apihandler.common.RequestClientFactory;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandler.common.ResponseHandler;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tasksbeans.TaskRequestReference;
+import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest;
+import org.onap.so.apihandlerinfra.tasksbeans.Value;
+import org.onap.so.apihandlerinfra.tasksbeans.Variables;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoAlarmLogger;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+
+@Path("/tasks")
+@Component
+public class ManualTasks {
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, ManualTasks.class);
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+
+ @org.springframework.beans.factory.annotation.Value("${mso.camunda.rest.task.uri}")
+ private String taskUri;
+
+ @Autowired
+ private RequestClientFactory reqClientFactory;
+
+ @Autowired
+ private MsoRequest msoRequest;
+
+ @Autowired
+ private ResponseBuilder builder;
+
+ @POST
+ @Path("/{version:[vV]1}/{taskId}/complete")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Complete specified task",response=Response.class)
+ @Transactional
+ public Response completeTask(String request, @PathParam("version") String version, @PathParam("taskId") String taskId,
+ @Context ContainerRequestContext requestContext) throws ApiException {
+
+ String requestId = requestContext.getProperty("requestId").toString();
+ MsoLogger.setLogContext(requestId, null);
+ msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, "", "");
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("requestId is: " + requestId);
+ TasksRequest taskRequest = null;
+ String apiVersion = version.substring(1);
+
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ taskRequest= mapper.readValue(request, TasksRequest.class);
+
+ if (taskRequest.getRequestDetails() == null) {
+ throw new ValidationException("requestDetails");
+ }
+ if (taskRequest.getRequestDetails().getRequestInfo() == null) {
+ throw new ValidationException("requestInfo");
+ }
+ if (empty(taskRequest.getRequestDetails().getRequestInfo().getSource())) {
+ throw new ValidationException("source");
+ }
+ if (empty(taskRequest.getRequestDetails().getRequestInfo().getRequestorId())) {
+ throw new ValidationException("requestorId");
+ }
+
+ }catch(IOException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed: " + e.getMessage(),
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ catch(ValidationException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON Object failed. " + e.getMessage(),
+ HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
+ throw validateException;
+
+ }
+ //Create Request Record
+ InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(taskRequest,Action.completeTask,requestId,Status.PENDING,request);
+
+ // Transform the request to Camunda-style Complete request
+ Variables variablesForComplete = new Variables();
+ Value sourceValue = new Value();
+ sourceValue.setValue(taskRequest.getRequestDetails().getRequestInfo().getSource());
+ Value responseValue = new Value();
+ responseValue.setValue(taskRequest.getRequestDetails().getRequestInfo().getResponseValue().name());
+ Value requestorIdValue = new Value();
+ requestorIdValue.setValue(taskRequest.getRequestDetails().getRequestInfo().getRequestorId());
+ variablesForComplete.setSource(sourceValue);
+ variablesForComplete.setResponseValue(responseValue);
+ variablesForComplete.setRequestorId(requestorIdValue);
+
+ String camundaJsonReq = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+ camundaJsonReq = mapper.writeValueAsString(variablesForComplete);
+ } catch(JsonProcessingException e){
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.UnknownError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of JSON object to Camunda request failed",
+ HttpStatus.SC_INTERNAL_SERVER_ERROR,ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+ throw validateException;
+ }
+
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+ long subStartTime = System.currentTimeMillis();
+ String requestUrl = taskUri + "/" + taskId + "/complete";
+ try {
+ requestClient = reqClientFactory.getRequestClient (requestUrl);
+ // Capture audit event
+
+ response = requestClient.post(camundaJsonReq);
+
+ } catch (Exception e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ AlarmLoggerInfo alarmLoggerInfo = new AlarmLoggerInfo.Builder("MsoConfigurationError", MsoAlarmLogger.CRITICAL, Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)).build();
+
+
+
+ BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY),
+ HttpStatus.SC_BAD_GATEWAY,ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).alarmInfo(alarmLoggerInfo).build();
+
+ throw bpmnFailureException;
+ }
+
+ if (response == null) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY),
+ HttpStatus.SC_BAD_GATEWAY,ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build();
+
+ throw bpmnFailureException;
+
+ }
+
+ ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
+ int bpelStatus = respHandler.getStatus ();
+
+ // BPEL accepted the request, the request is in progress
+ if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) {
+ msoLogger.debug ("Received good response from Camunda");
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN completed the request");
+ TaskRequestReference trr = new TaskRequestReference();
+ trr.setTaskId(taskId);
+ String completeResp = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+ completeResp = mapper.writeValueAsString(trr);
+ }
+ catch (JsonProcessingException e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Request Failed due to bad response format" ,
+ bpelStatus,ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ msoLogger.debug("Response to the caller: " + completeResp);
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) completeResp);
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, completeResp, apiVersion);
+ } else {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).build();
+
+
+ BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(bpelStatus),
+ bpelStatus,ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+
+ throw bpmnFailureException;
+
+ }
+
+ }
+
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Messages.java
index f46d327531..555c536efb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Messages.java
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
import java.util.HashMap;
import java.util.Map;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.ErrorNumbers;
public class Messages {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ModelType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ModelType.java
index 1db847e9d9..7b3ea3a181 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ModelType.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ModelType.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
/*
* Enum for Status values returned by API Handler to Tail-F
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoException.java
index 5204816bb8..defc904b05 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoException.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
public enum MsoException {
ServiceException,
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
new file mode 100644
index 0000000000..42ad5fc3d5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -0,0 +1,756 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.StringTokenizer;
+
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.xml.XMLConstants;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest;
+import org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation;
+import org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation;
+import org.onap.so.apihandlerinfra.validation.InPlaceSoftwareUpdateValidation;
+import org.onap.so.apihandlerinfra.validation.InstanceIdMapValidation;
+import org.onap.so.apihandlerinfra.validation.ModelInfoValidation;
+import org.onap.so.apihandlerinfra.validation.PlatformLOBValidation;
+import org.onap.so.apihandlerinfra.validation.ProjectOwningEntityValidation;
+import org.onap.so.apihandlerinfra.validation.RelatedInstancesValidation;
+import org.onap.so.apihandlerinfra.validation.RequestInfoValidation;
+import org.onap.so.apihandlerinfra.validation.RequestParametersValidation;
+import org.onap.so.apihandlerinfra.validation.RequestScopeValidation;
+import org.onap.so.apihandlerinfra.validation.SubscriberInfoValidation;
+import org.onap.so.apihandlerinfra.validation.UserParamsValidation;
+import org.onap.so.apihandlerinfra.validation.ValidationInformation;
+import org.onap.so.apihandlerinfra.validation.ValidationRule;
+import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType;
+import org.onap.so.apihandlerinfra.vnfbeans.VnfInputs;
+import org.onap.so.apihandlerinfra.vnfbeans.VnfRequest;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.InstanceDirection;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.PolicyException;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+@Component
+public class MsoRequest {
+
+ @Autowired
+ private InfraActiveRequestsRepository iarRepo;
+
+ @Autowired
+ private ResponseBuilder builder;
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH,MsoRequest.class);
+
+ public Response buildServiceErrorResponse (int httpResponseCode, MsoException exceptionType,
+ String errorText, String messageId, List<String> variables, String version) {
+
+ if(errorText.length() > 1999){
+ errorText = errorText.substring(0, 1999);
+ }
+
+ RequestError re = new RequestError();
+
+ if("PolicyException".equals(exceptionType.name())){
+
+ PolicyException pe = new PolicyException();
+ pe.setMessageId(messageId);
+ pe.setText(errorText);
+ if(variables != null){
+ for(String variable: variables){
+ pe.getVariables().add(variable);
+ }
+ }
+ re.setPolicyException(pe);
+
+ } else {
+
+ ServiceException se = new ServiceException();
+ se.setMessageId(messageId);
+ se.setText(errorText);
+ if(variables != null){
+ for(String variable: variables){
+ se.getVariables().add(variable);
+ }
+ }
+ re.setServiceException(se);
+ }
+
+ String requestErrorStr = null;
+
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_DEFAULT);
+ requestErrorStr = mapper.writeValueAsString(re);
+ }catch(Exception e){
+ msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in buildServiceErrorResponse writing exceptionType to string ", e);
+ }
+
+ return builder.buildResponse(httpResponseCode, null, requestErrorStr, version);
+ }
+
+
+
+ // Parse request JSON
+ public void parse (ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, Actions action, String version,
+ String originalRequestJSON, int reqVersion, Boolean aLaCarteFlag) throws ValidationException, IOException {
+
+ msoLogger.debug ("Validating the Service Instance request");
+ List<ValidationRule> rules = new ArrayList<>();
+ msoLogger.debug ("Incoming version is: " + version + " coverting to int: " + reqVersion);
+ RequestParameters requestParameters = sir.getRequestDetails().getRequestParameters();
+ ValidationInformation info = new ValidationInformation(sir, instanceIdMap, action,
+ reqVersion, aLaCarteFlag, requestParameters);
+
+ rules.add(new InstanceIdMapValidation());
+
+ if(reqVersion >= 6 && action == Action.inPlaceSoftwareUpdate){
+ rules.add(new InPlaceSoftwareUpdateValidation());
+ }else if(reqVersion >= 6 && action == Action.applyUpdatedConfig){
+ rules.add(new ApplyUpdatedConfigValidation());
+ }else{
+ rules.add(new RequestScopeValidation());
+ rules.add(new RequestParametersValidation());
+ rules.add(new RequestInfoValidation());
+ rules.add(new ModelInfoValidation());
+ rules.add(new CloudConfigurationValidation());
+ rules.add(new SubscriberInfoValidation());
+ rules.add(new PlatformLOBValidation());
+ rules.add(new ProjectOwningEntityValidation());
+ rules.add(new RelatedInstancesValidation());
+ }
+ if(reqVersion >= 7 && requestParameters != null && requestParameters.getUserParams() != null){
+ for(Map<String, Object> params : requestParameters.getUserParams()){
+ if(params.containsKey("service")){
+ ObjectMapper obj = new ObjectMapper();
+ String input = obj.writeValueAsString(params.get("service"));
+ Service validate = obj.readValue(input, Service.class);
+ info.setUserParams(validate);
+ rules.add(new UserParamsValidation());
+ break;
+ }
+ }
+ }
+ for(ValidationRule rule : rules){
+ rule.validate(info);
+ }
+ }
+ void parseOrchestration (ServiceInstancesRequest sir) throws ValidationException {
+ RequestInfo requestInfo = sir.getRequestDetails().getRequestInfo();
+
+ if (requestInfo == null) {
+ throw new ValidationException ("requestInfo");
+ }
+
+ if (empty (requestInfo.getSource ())) {
+ throw new ValidationException ("source");
+ }
+ if (empty (requestInfo.getRequestorId ())) {
+ throw new ValidationException ("requestorId");
+ }
+ }
+ public Map<String, List<String>> getOrchestrationFilters (MultivaluedMap<String, String> queryParams) throws ValidationException {
+
+ String queryParam = null;
+ Map<String, List<String>> orchestrationFilterParams = new HashMap<>();
+
+
+ for (Entry<String,List<String>> entry : queryParams.entrySet()) {
+ queryParam = entry.getKey();
+
+ try{
+ if("filter".equalsIgnoreCase(queryParam)){
+ for(String value : entry.getValue()) {
+ StringTokenizer st = new StringTokenizer(value, ":");
+
+ int counter=0;
+ String mapKey=null;
+ List<String> orchestrationList = new ArrayList<>();
+ while (st.hasMoreElements()) {
+ if(counter == 0){
+ mapKey = st.nextElement() + "";
+ } else{
+ orchestrationList.add(st.nextElement() + "");
+ }
+ counter++;
+ }
+ orchestrationFilterParams.put(mapKey, orchestrationList);
+ }
+ }
+
+ }catch(Exception e){
+ //msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, e);
+ throw new ValidationException ("QueryParam ServiceInfo", e);
+
+ }
+
+ }
+
+
+ return orchestrationFilterParams;
+ }
+
+ public InfraActiveRequests createRequestObject (ServiceInstancesRequest servInsReq, Actions action, String requestId,
+ Status status, String originalRequestJSON, String requestScope) {
+ InfraActiveRequests aq = new InfraActiveRequests ();
+ try {
+ if (null == servInsReq) {
+ servInsReq = new ServiceInstancesRequest ();
+ }
+
+ String networkType = "";
+ String vnfType = "";
+ aq.setRequestId (requestId);
+ aq.setRequestAction(action.toString());
+ aq.setAction(action.toString());
+
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
+
+ aq.setStartTime (startTimeStamp);
+ RequestInfo requestInfo =servInsReq.getRequestDetails().getRequestInfo();
+ if (requestInfo != null) {
+
+ if(requestInfo.getSource() != null){
+ aq.setSource(requestInfo.getSource());
+ }
+ if(requestInfo.getCallbackUrl() != null){
+ aq.setCallBackUrl(requestInfo.getCallbackUrl());
+ }
+ if(requestInfo.getCorrelator() != null){
+ aq.setCorrelator(requestInfo.getCorrelator());
+ }
+
+ if(requestInfo.getRequestorId() != null) {
+ aq.setRequestorId(requestInfo.getRequestorId());
+ }
+ }
+
+ if (servInsReq.getRequestDetails().getModelInfo() != null || (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)) {
+ aq.setRequestScope(requestScope);
+ }
+
+ if (servInsReq.getRequestDetails().getCloudConfiguration() != null) {
+ CloudConfiguration cloudConfiguration = servInsReq.getRequestDetails().getCloudConfiguration();
+ if(cloudConfiguration.getLcpCloudRegionId() != null) {
+ aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId());
+ }
+
+ if(cloudConfiguration.getTenantId() != null) {
+ aq.setTenantId(cloudConfiguration.getTenantId());
+ }
+
+ }
+
+ if(servInsReq.getServiceInstanceId() != null){
+ aq.setServiceInstanceId(servInsReq.getServiceInstanceId());
+ }
+
+ if(servInsReq.getVnfInstanceId() != null){
+ aq.setVnfId(servInsReq.getVnfInstanceId());
+ }
+
+ if(ModelType.service.name().equalsIgnoreCase(requestScope)){
+ if(servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null){
+ aq.setServiceInstanceName(requestInfo.getInstanceName());
+ }
+ }
+
+ if(ModelType.network.name().equalsIgnoreCase(requestScope)){
+ aq.setNetworkName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
+ aq.setNetworkType(networkType);
+ aq.setNetworkId(servInsReq.getNetworkInstanceId());
+ }
+
+ if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)){
+ aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
+ aq.setVolumeGroupName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
+ aq.setVnfType(vnfType);
+
+ }
+
+ if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)){
+ aq.setVfModuleName(requestInfo.getInstanceName());
+ aq.setVfModuleModelName(servInsReq.getRequestDetails().getModelInfo().getModelName());
+ aq.setVfModuleId(servInsReq.getVfModuleInstanceId());
+ aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
+ aq.setVnfType(vnfType);
+
+ }
+
+ if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ aq.setConfigurationId(servInsReq.getConfigurationId());
+ aq.setConfigurationName(requestInfo.getInstanceName());
+ }
+
+ if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){
+ aq.setVnfName(requestInfo.getInstanceName());
+ if (null != servInsReq.getRequestDetails()) {
+ RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList();
+
+ if (instanceList != null) {
+
+ for(RelatedInstanceList relatedInstanceList : instanceList){
+
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){
+ aq.setVnfType(vnfType);
+ }
+ }
+ }
+ }
+ }
+
+ aq.setRequestBody (originalRequestJSON);
+
+ aq.setRequestStatus (status.toString ());
+ aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER);
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e);
+
+ if (!status.equals (Status.FAILED)) {
+ throw e;
+ }
+ }
+ return aq;
+ }
+
+ public InfraActiveRequests createRequestObject (TasksRequest taskRequest, Action action, String requestId,
+ Status status, String originalRequestJSON) {
+ InfraActiveRequests aq = new InfraActiveRequests ();
+ try {
+
+ org.onap.so.apihandlerinfra.tasksbeans.RequestInfo requestInfo = taskRequest.getRequestDetails().getRequestInfo();
+ aq.setRequestId (requestId);
+ aq.setRequestAction(action.name());
+ aq.setAction(action.name());
+
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
+
+ aq.setStartTime (startTimeStamp);
+ if (requestInfo != null) {
+
+ if(requestInfo.getSource() != null){
+ aq.setSource(requestInfo.getSource());
+ }
+
+ if(requestInfo.getRequestorId() != null) {
+ aq.setRequestorId(requestInfo.getRequestorId());
+ }
+ }
+
+ aq.setRequestBody (originalRequestJSON);
+ aq.setRequestStatus (status.toString ());
+ aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER);
+
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e);
+
+ if (!status.equals (Status.FAILED)) {
+ throw e;
+ }
+ }
+ return aq;
+ }
+
+ public void createErrorRequestRecord (Status status, String requestId, String errorMessage, Actions action, String requestScope, String requestJSON) {
+ try {
+ InfraActiveRequests request = new InfraActiveRequests(requestId);
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
+ request.setStartTime (startTimeStamp);
+ request.setRequestStatus(status.toString());
+ request.setStatusMessage(errorMessage);
+ request.setProgress((long) 100);
+ request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ request.setRequestAction(action.toString());
+ request.setRequestScope(requestScope);
+ request.setRequestBody(requestJSON);
+ Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
+ request.setEndTime(endTimeStamp);
+ iarRepo.save(request);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB");
+ msoLogger.debug ("Exception: ", e);
+ }
+ }
+
+
+
+
+ public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) {
+ return buildResponseWithError (httpResponseCode, errorCode, inProgress, null);
+ }
+
+ public Response buildResponseWithError (int httpResponseCode,
+ String errorCode,
+ InfraActiveRequests inProgress,
+ String errorString) {
+
+
+
+ // Log the failed request into the MSO Requests database
+
+ return Response.status (httpResponseCode).entity (null).build ();
+
+ }
+
+ public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) {
+
+ return Response.status (httpResponseCode).entity (null).build ();
+ }
+
+
+
+ public String getServiceType (VnfInputs vnfInputs) {
+ if (vnfInputs.getServiceType () != null)
+ return vnfInputs.getServiceType ();
+ if (vnfInputs.getServiceId () != null)
+ return vnfInputs.getServiceId ();
+ return null;
+ }
+
+ public long translateStatus (RequestStatusType status) {
+ switch (status) {
+ case FAILED:
+ case COMPLETE:
+ return Constants.PROGRESS_REQUEST_COMPLETED;
+ case IN_PROGRESS:
+ return Constants.PROGRESS_REQUEST_IN_PROGRESS;
+ default:
+ return 0;
+ }
+ }
+
+ public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage){
+ if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
+ aq.setStatusMessage (errorMessage);
+ aq.setProgress(new Long(100));
+ aq.setRequestStatus(status.toString());
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
+ aq.setEndTime (endTimeStamp);
+ iarRepo.save(aq);
+ }
+ }
+
+
+
+
+ public static String domToStr (Document doc) {
+ if (doc == null) {
+ return null;
+ }
+
+ try {
+ StringWriter sw = new StringWriter ();
+ StreamResult sr = new StreamResult (sw);
+ TransformerFactory tf = TransformerFactory.newInstance ();
+ tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+ tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET,"");
+ Transformer t = tf.newTransformer ();
+ t.setOutputProperty (OutputKeys.STANDALONE, "yes");
+ NodeList nl = doc.getDocumentElement ().getChildNodes ();
+ DOMSource source = null;
+ for (int x = 0; x < nl.getLength (); x++) {
+ Node e = nl.item (x);
+ if (e instanceof Element) {
+ source = new DOMSource (e);
+ break;
+ }
+ }
+ if (source != null) {
+ t.transform (source, sr);
+
+ String s = sw.toString ();
+ return s;
+ }
+
+ return null;
+
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in domToStr", e);
+ }
+ return null;
+ }
+
+ public void addBPMNSpecificInputs(VnfRequest vnfReq, VnfInputs vnfInputs, String personaModelId, String personaModelVersion, Boolean isBaseVfModule,
+ String vnfPersonaModelId, String vnfPersonaModelVersion) {
+ vnfInputs.setPersonaModelId(personaModelId);
+ vnfInputs.setPersonaModelVersion(personaModelVersion);
+ vnfInputs.setIsBaseVfModule(isBaseVfModule);
+ vnfInputs.setVnfPersonaModelId(vnfPersonaModelId);
+ vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion);
+
+ vnfReq.setVnfInputs(vnfInputs);
+
+ }
+
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+
+ public String getRequestJSON(ServiceInstancesRequest sir) throws JsonGenerationException, JsonMappingException, IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ //mapper.configure(Feature.WRAP_ROOT_VALUE, true);
+ msoLogger.debug ("building sir from object " + sir);
+ String requestJSON = mapper.writeValueAsString(sir);
+
+ // Perform mapping from VID-style modelInfo fields to ASDC-style modelInfo fields
+
+ msoLogger.debug("REQUEST JSON before mapping: " + requestJSON);
+ // modelUuid = modelVersionId
+ requestJSON = requestJSON.replaceAll("\"modelVersionId\":","\"modelUuid\":");
+ // modelCustomizationUuid = modelCustomizationId
+ requestJSON = requestJSON.replaceAll("\"modelCustomizationId\":","\"modelCustomizationUuid\":");
+ // modelInstanceName = modelCustomizationName
+ requestJSON = requestJSON.replaceAll("\"modelCustomizationName\":","\"modelInstanceName\":");
+ // modelInvariantUuid = modelInvariantId
+ requestJSON = requestJSON.replaceAll("\"modelInvariantId\":","\"modelInvariantUuid\":");
+ msoLogger.debug("REQUEST JSON after mapping: " + requestJSON);
+
+ return requestJSON;
+ }
+
+
+ public boolean getAlacarteFlag(ServiceInstancesRequest sir) {
+ if(sir.getRequestDetails().getRequestParameters() != null &&
+ sir.getRequestDetails().getRequestParameters().getALaCarte() != null)
+ return sir.getRequestDetails().getRequestParameters().getALaCarte();
+
+ return false;
+ }
+
+
+ public String getNetworkType(ServiceInstancesRequest sir, String requestScope) {
+ if(requestScope.equalsIgnoreCase(ModelType.network.name()))
+ return sir.getRequestDetails().getModelInfo().getModelName();
+ else return null;
+ }
+
+
+ public String getServiceInstanceType(ServiceInstancesRequest sir, String requestScope) {
+ if(requestScope.equalsIgnoreCase(ModelType.network.name()))
+ return sir.getRequestDetails().getModelInfo().getModelName();
+ else return null;
+ }
+
+
+ public String getSDCServiceModelVersion(ServiceInstancesRequest sir) {
+ String sdcServiceModelVersion = null;
+ if(sir.getRequestDetails().getRelatedInstanceList() != null)
+ for(RelatedInstanceList relatedInstanceList : sir.getRequestDetails().getRelatedInstanceList()){
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo ();
+ if(relatedInstanceModelInfo.getModelType().equals(ModelType.service))
+ sdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion ();
+ }
+ return sdcServiceModelVersion;
+ }
+
+
+ public String getVfModuleType(ServiceInstancesRequest sir, String requestScope, Actions action, int reqVersion) {
+
+ String serviceInstanceType = null;
+ String networkType = null;
+ String vnfType = null;
+ String vfModuleType = null;
+ String vfModuleModelName = null;
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
+ String serviceModelName = null;
+ String vnfModelName = null;
+ String asdcServiceModelVersion = null;
+ String volumeGroupId = null;
+ boolean isRelatedServiceInstancePresent = false;
+ boolean isRelatedVnfInstancePresent = false;
+ boolean isSourceVnfPresent = false;
+ boolean isDestinationVnfPresent = false;
+ boolean isConnectionPointPresent = false;
+
+ if (instanceList != null) {
+ for(RelatedInstanceList relatedInstanceList : instanceList){
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo ();
+
+ if (action != Action.deleteInstance) {
+
+ if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) {
+ isSourceVnfPresent = true;
+ } else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) &&
+ (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) && reqVersion == 6))) {
+ isDestinationVnfPresent = true;
+ }
+ }
+
+ if(ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ isConnectionPointPresent = true;
+ }
+ }
+
+
+ if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
+ isRelatedServiceInstancePresent = true;
+ serviceModelName = relatedInstanceModelInfo.getModelName ();
+ asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion ();
+ } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) {
+ isRelatedVnfInstancePresent = true;
+ vnfModelName = relatedInstanceModelInfo.getModelCustomizationName();
+ } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) {
+ volumeGroupId = relatedInstance.getInstanceId ();
+ }
+ }
+
+ if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) {
+ serviceInstanceType = serviceModelName;
+ vnfType = serviceModelName + "/" + vnfModelName;
+ }
+ else if(requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) {
+ vfModuleModelName = modelInfo.getModelName ();
+ serviceInstanceType = serviceModelName;
+ vnfType = serviceModelName + "/" + vnfModelName;
+ vfModuleType = vnfType + "::" + vfModuleModelName;
+ sir.setVolumeGroupInstanceId (volumeGroupId);
+ }
+ else if (requestScope.equalsIgnoreCase (ModelType.vnf.name ()))
+ vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName();
+
+ }
+
+ return vfModuleType;
+
+ }
+
+ public String getVnfType(ServiceInstancesRequest sir, String requestScope, Actions action, int reqVersion) {
+
+ String serviceInstanceType = null;
+ String networkType = null;
+ String vnfType = null;
+ String vfModuleType = null;
+ String vfModuleModelName = null;
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, MsoRequest.class);
+ RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
+ String serviceModelName = null;
+ String vnfModelName = null;
+ String asdcServiceModelVersion = null;
+ String volumeGroupId = null;
+ boolean isRelatedServiceInstancePresent = false;
+ boolean isRelatedVnfInstancePresent = false;
+ boolean isSourceVnfPresent = false;
+ boolean isDestinationVnfPresent = false;
+ boolean isConnectionPointPresent = false;
+
+ if (instanceList != null) {
+ for(RelatedInstanceList relatedInstanceList : instanceList){
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo ();
+
+ if (action != Action.deleteInstance) {
+
+ if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) {
+ isSourceVnfPresent = true;
+ } else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) &&
+ (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) && reqVersion == 6))) {
+ isDestinationVnfPresent = true;
+ }
+ }
+
+ if(ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ isConnectionPointPresent = true;
+ }
+ }
+
+
+ if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
+ isRelatedServiceInstancePresent = true;
+ serviceModelName = relatedInstanceModelInfo.getModelName ();
+ asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion ();
+ } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) {
+ isRelatedVnfInstancePresent = true;
+ vnfModelName = relatedInstanceModelInfo.getModelCustomizationName();
+ } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) {
+ volumeGroupId = relatedInstance.getInstanceId ();
+ }
+ }
+
+ if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) {
+ serviceInstanceType = serviceModelName;
+ vnfType = serviceModelName + "/" + vnfModelName;
+ }
+ else if(requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) {
+ vfModuleModelName = modelInfo.getModelName ();
+ serviceInstanceType = serviceModelName;
+ vnfType = serviceModelName + "/" + vnfModelName;
+ vfModuleType = vnfType + "::" + vfModuleModelName;
+ sir.setVolumeGroupInstanceId (volumeGroupId);
+ }
+ else if (requestScope.equalsIgnoreCase (ModelType.vnf.name ()))
+ vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName();
+
+ }
+
+ return vnfType;
+
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java
index 3a7235d370..35f196b263 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java
@@ -1,64 +1,68 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Response;
-
-import org.openecomp.mso.HealthCheckUtils;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/nodehealthcheck")
-@Api(value="/nodehealthcheck",description="API Handler Infra Node Health Check")
-public class NodeHealthcheckHandler {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
-
- @HEAD
- @GET
- @Produces("text/html")
- @ApiOperation(value="Performing node health check",response=Response.class)
- public Response nodeHealthcheck () {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName ("NodeHealthcheck");
- // Generate a Request Id
- String requestId = UUIDChecker.generateUUID(msoLogger);
- HealthCheckUtils healthCheck = new HealthCheckUtils ();
- if (!healthCheck.siteStatusCheck (msoLogger)) {
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
-
- if (healthCheck.verifyNodeHealthCheck(HealthCheckUtils.NodeType.APIH, requestId)) {
- msoLogger.debug("nodeHealthcheck - Successful");
- return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
- } else {
- msoLogger.debug("nodeHealthcheck - At leaset one of the sub-modules is not available.");
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import java.net.UnknownHostException;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.utils.UUIDChecker;
+import org.springframework.stereotype.Component;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Path("/nodehealthcheck")
+@Api(value="/nodehealthcheck",description="API Handler Infra Node Health Check")
+@Component
+public class NodeHealthcheckHandler {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, NodeHealthcheckHandler.class);
+
+ private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
+
+ public static final Response HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK)
+ .entity (CHECK_HTML)
+ .build ();
+
+ @GET
+ @Produces("text/html")
+ @ApiOperation(value="Performing node health check",response=Response.class)
+ @Transactional
+ public Response nodeHealthcheck (@Context ContainerRequestContext requestContext) throws UnknownHostException {
+ long startTime = System.currentTimeMillis ();
+ MsoLogger.setServiceName ("NodeHealthcheck");
+ // Generated RequestId
+ String requestId = requestContext.getProperty("requestId").toString();
+ MsoLogger.setLogContext(requestId, null);
+ msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, "", "");
+ return HEALTH_CHECK_RESPONSE;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
new file mode 100644
index 0000000000..e1993aa632
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -0,0 +1,342 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoAlarmLogger;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
+import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
+import org.onap.so.serviceinstancebeans.InstanceReferences;
+import org.onap.so.serviceinstancebeans.Request;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestList;
+import org.onap.so.serviceinstancebeans.RequestStatus;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Path("onap/so/infra/orchestrationRequests")
+@Api(value="onap/so/infra/orchestrationRequests",description="API Requests for Orchestration requests")
+@Component
+public class OrchestrationRequests {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, OrchestrationRequests.class);
+
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+
+ @Autowired
+ private InfraActiveRequestsRepository infraActiveRequestsRepository;
+
+ @Autowired
+ private MsoRequest msoRequest;
+
+ @Autowired
+ private ResponseBuilder builder;
+
+ @GET
+ @Path("/{version:[vV][4-7]}/{requestId}")
+ @ApiOperation(value="Find Orchestrated Requests for a given requestId",response=Response.class)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Transactional
+ public Response getOrchestrationRequest(@PathParam("requestId") String requestId, @PathParam("version") String version) throws ApiException{
+
+ String apiVersion = version.substring(1);
+ GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse();
+
+
+ InfraActiveRequests requestDB = null;
+
+ try {
+ requestDB = infraActiveRequestsRepository.findOneByRequestIdOrClientRequestId(requestId, requestId);
+ } catch (Exception e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.AvailabilityError).build();
+ AlarmLoggerInfo alarmLoggerInfo = new AlarmLoggerInfo.Builder("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL, Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)).build();
+
+
+
+ ValidateException validateException = new ValidateException.Builder("Exception while communciate with Request DB - Infra Request Lookup",
+ HttpStatus.SC_NOT_FOUND,ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB).cause(e).errorInfo(errorLoggerInfo).alarmInfo(alarmLoggerInfo).build();
+
+ throw validateException;
+
+ }
+
+ if(requestDB == null) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB",
+ HttpStatus.SC_NO_CONTENT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+
+ Request request = mapInfraActiveRequestToRequest(requestDB);
+
+ orchestrationResponse.setRequest(request);
+
+ return builder.buildResponse(HttpStatus.SC_OK, requestId, orchestrationResponse, apiVersion);
+ }
+
+ @GET
+ @Path("/{version:[vV][4-7]}")
+ @ApiOperation(value="Find Orchestrated Requests for a URI Information",response=Response.class)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Transactional
+ public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version) throws ApiException{
+
+ long startTime = System.currentTimeMillis ();
+
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+
+ List<InfraActiveRequests> activeRequests = null;
+
+ GetOrchestrationListResponse orchestrationList = null;
+ Map<String, List<String>> orchestrationMap;
+ String apiVersion = version.substring(1);
+
+ try {
+ orchestrationMap = msoRequest.getOrchestrationFilters(queryParams);
+ if (orchestrationMap.isEmpty()) {
+ throw new ValidationException("At least one filter query param must be specified");
+ }
+ }catch(ValidationException ex){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.DataError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder(ex.getMessage(),
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+
+ }
+
+ activeRequests = infraActiveRequestsRepository.getOrchestrationFiltersFromInfraActive(orchestrationMap);
+
+ orchestrationList = new GetOrchestrationListResponse();
+ List<RequestList> requestLists = new ArrayList<>();
+
+ for(InfraActiveRequests infraActive : activeRequests){
+ RequestList requestList = new RequestList();
+ Request request = mapInfraActiveRequestToRequest(infraActive);
+ requestList.setRequest(request);
+ requestLists.add(requestList);
+ }
+
+ orchestrationList.setRequestList(requestLists);
+ return builder.buildResponse(HttpStatus.SC_OK, null, orchestrationList, apiVersion);
+ }
+
+
+ @POST
+ @Path("/{version: [vV][4-7]}/{requestId}/unlock")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Unlock Orchestrated Requests for a given requestId",response=Response.class)
+ @Transactional
+ public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) throws ApiException{
+
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("requestId is: " + requestId);
+ ServiceInstancesRequest sir = null;
+
+ InfraActiveRequests infraActiveRequest = null;
+ Request request = null;
+
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+ } catch(IOException e){
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(),
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+
+ }
+ try{
+ msoRequest.parseOrchestration(sir);
+ } catch (Exception e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
+ ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ throw validateException;
+ }
+
+ infraActiveRequest = infraActiveRequestsRepository.findOneByRequestIdOrClientRequestId(requestId, requestId);
+ if(infraActiveRequest == null) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MsoLogger.ErrorCode.BusinessProcesssError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Null response from RequestDB when searching by RequestId",
+ HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+
+ }else{
+ String status = infraActiveRequest.getRequestStatus();
+ if(status.equalsIgnoreCase("IN_PROGRESS") || status.equalsIgnoreCase("PENDING") || status.equalsIgnoreCase("PENDING_MANUAL_TASK")){
+ infraActiveRequest.setRequestStatus("UNLOCKED");
+ infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ infraActiveRequestsRepository.save(infraActiveRequest);
+ }else{
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MsoLogger.ErrorCode.DataError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked",
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ }
+ return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build ();
+ }
+
+ private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar) throws ApiException{
+
+ String requestBody = iar.getRequestBody();
+ Request request = new Request();
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ request.setRequestId(iar.getRequestId());
+ request.setRequestScope(iar.getRequestScope());
+ request.setRequestType(iar.getRequestAction());
+
+ InstanceReferences ir = new InstanceReferences();
+ if(iar.getNetworkId() != null)
+ ir.setNetworkInstanceId(iar.getNetworkId());
+ if(iar.getNetworkName() != null)
+ ir.setNetworkInstanceName(iar.getNetworkName());
+ if(iar.getServiceInstanceId() != null)
+ ir.setServiceInstanceId(iar.getServiceInstanceId());
+ if(iar.getServiceInstanceName() != null)
+ ir.setServiceInstanceName(iar.getServiceInstanceName());
+ if(iar.getVfModuleId() != null)
+ ir.setVfModuleInstanceId(iar.getVfModuleId());
+ if(iar.getVfModuleName() != null)
+ ir.setVfModuleInstanceName(iar.getVfModuleName());
+ if(iar.getVnfId() != null)
+ ir.setVnfInstanceId(iar.getVnfId());
+ if(iar.getVnfName() != null)
+ ir.setVnfInstanceName(iar.getVnfName());
+ if(iar.getVolumeGroupId() != null)
+ ir.setVolumeGroupInstanceId(iar.getVolumeGroupId());
+ if(iar.getVolumeGroupName() != null)
+ ir.setVolumeGroupInstanceName(iar.getVolumeGroupName());
+ if(iar.getRequestorId() != null)
+ ir.setRequestorId(iar.getRequestorId());
+
+
+ request.setInstanceReferences(ir);
+
+ RequestDetails requestDetails = null;
+
+ if(StringUtils.isNotBlank(requestBody)) {
+ try {
+ if(requestBody.contains("\"requestDetails\":")){
+ ServiceInstancesRequest sir = mapper.readValue(requestBody, ServiceInstancesRequest.class);
+ requestDetails = sir.getRequestDetails();
+ } else {
+ requestDetails = mapper.readValue(requestBody, RequestDetails.class);
+ }
+ } catch (IOException e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : ",
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ }
+ request.setRequestDetails(requestDetails);
+
+ if(iar.getStartTime() != null) {
+ String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getStartTime()) + " GMT";
+ request.setStartTime(startTimeStamp);
+ }
+
+ RequestStatus status = new RequestStatus();
+ if(iar.getStatusMessage() != null){
+ status.setStatusMessage(iar.getStatusMessage());
+ }
+
+ if(iar.getEndTime() != null){
+ String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT";
+ status.setFinishTime(endTimeStamp);
+ }
+
+
+ if(iar.getRequestStatus() != null){
+ status.setRequestState(iar.getRequestStatus());
+ }
+
+ if(iar.getProgress() != null){
+ status.setPercentProgress(iar.getProgress().intValue());
+ }
+
+ request.setRequestStatus(status);
+
+ return request;
+ }
+ }
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RecipeLookupResult.java
index 2a02344ab3..83d270552d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RecipeLookupResult.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
public class RecipeLookupResult {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestActionMap.java
index e68093e166..86dd048120 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestActionMap.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
import java.util.HashMap;
import java.util.Map;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
new file mode 100644
index 0000000000..ba6635e737
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -0,0 +1,1661 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.camundabeans.CamundaResponse;
+import org.onap.so.apihandler.common.CommonConstants;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.RequestClient;
+import org.onap.so.apihandler.common.RequestClientFactory;
+import org.onap.so.apihandler.common.RequestClientParameter;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandler.common.ResponseHandler;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
+import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
+import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.ServiceRecipe;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfRecipe;
+import org.onap.so.db.catalog.beans.VnfResource;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository;
+import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.ServiceRecipeRepository;
+import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.VFModuleRepository;
+import org.onap.so.db.catalog.data.repository.VnfComponentRecipeRepository;
+import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.VnfRecipeRepository;
+import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.Networks;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.RequestReferences;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
+import org.onap.so.serviceinstancebeans.VfModules;
+import org.onap.so.serviceinstancebeans.Vnfs;
+import org.onap.so.utils.UUIDChecker;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Component
+@Path("/onap/so/infra/serviceInstantiation")
+@Api(value="/onap/so/infra/serviceInstantiation",description="Infrastructure API Requests for Service Instances")
+public class ServiceInstances {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH,MsoRequest.class);
+ private static String NAME = "name";
+ private static String VALUE = "value";
+
+ @Autowired
+ private Environment env;
+
+ @Autowired
+ private RequestClientFactory reqClientFactory;
+
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Autowired
+ private ServiceRecipeRepository serviceRecipeRepo;
+
+ @Autowired
+ private NetworkRecipeRepository networkRecipeRepo;
+
+ @Autowired
+ private NetworkResourceCustomizationRepository networkCustomizationRepo;
+
+ @Autowired
+ private VnfResourceRepository vnfRepo;
+
+ @Autowired
+ private VnfCustomizationRepository vnfCustomRepo;
+
+ @Autowired
+ private VnfRecipeRepository vnfRecipeRepo;
+
+ @Autowired
+ private VFModuleCustomizationRepository vfModuleCustomRepo;
+
+ @Autowired
+ private VFModuleRepository vfModuleRepo;
+
+ @Autowired
+ private VnfComponentRecipeRepository vnfComponentRecipeRepo;
+
+ @Autowired
+ private InfraActiveRequestsRepository iar;
+
+ @Autowired
+ private ResponseBuilder builder;
+
+ @Autowired
+ private MsoRequest msoRequest;
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create a Service Instance on a version provided",response=Response.class)
+ @Transactional
+ public Response createServiceInstance(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ return serviceInstances(request, Action.createInstance, null, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/activate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Activate provided Service Instance",response=Response.class)
+ @Transactional
+ public Response activateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ return serviceInstances(request, Action.activateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/deactivate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Deactivate provided Service Instance",response=Response.class)
+ @Transactional
+ public Response deactivateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ return serviceInstances(request, Action.deactivateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @DELETE
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided Service Instance",response=Response.class)
+ @Transactional
+ public Response deleteServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][7]}/serviceInstances/assign")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Assign Service Instance", response=Response.class)
+ @Transactional
+ public Response assignServiceInstance(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ return serviceInstances(request, Action.assignInstance, null, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/unassign")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Unassign Service Instance", response=Response.class)
+ @Transactional
+ public Response unassignServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<String,String>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ return serviceInstances(request, Action.unassignInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create Port Mirroring Configuration",response=Response.class)
+ @Transactional
+ public Response createPortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ return configurationRecipeLookup(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @DELETE
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided Port",response=Response.class)
+ @Transactional
+ public Response deletePortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("configurationInstanceId", configurationInstanceId);
+ return configurationRecipeLookup(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/enablePort")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Enable Port Mirroring",response=Response.class)
+ @Transactional
+ public Response enablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("configurationInstanceId", configurationInstanceId);
+ return configurationRecipeLookup(request, Action.enablePort, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/disablePort")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Disable Port Mirroring",response=Response.class)
+ @Transactional
+ public Response disablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("configurationInstanceId", configurationInstanceId);
+ return configurationRecipeLookup(request, Action.disablePort, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/activate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Activate Port Mirroring",response=Response.class)
+ @Transactional
+ public Response activatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("configurationInstanceId", configurationInstanceId);
+ return configurationRecipeLookup(request, Action.activateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/deactivate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Deactivate Port Mirroring",response=Response.class)
+ @Transactional
+ public Response deactivatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("configurationInstanceId", configurationInstanceId);
+ return configurationRecipeLookup(request, Action.deactivateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/addRelationships")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Add Relationships to a Service Instance",response=Response.class)
+ @Transactional
+ public Response addRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ return configurationRecipeLookup(request, Action.addRelationships, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/removeRelationships")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Remove Relationships from Service Instance",response=Response.class)
+ @Transactional
+ public Response removeRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ return configurationRecipeLookup(request, Action.removeRelationships, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create VNF on a specified version and serviceInstance",response=Response.class)
+ @Transactional
+ public Response createVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/replace")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Replace provided VNF instance",response=Response.class)
+ @Transactional
+ public Response replaceVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @PUT
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Update VNF on a specified version, serviceInstance and vnfInstance",response=Response.class)
+ @Transactional
+ public Response updateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/applyUpdatedConfig")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Apply updated configuration",response=Response.class)
+ public Response applyUpdatedConfig(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+
+ @DELETE
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided VNF instance",response=Response.class)
+ @Transactional
+ public Response deleteVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create VfModule on a specified version, serviceInstance and vnfInstance",response=Response.class)
+ @Transactional
+ public Response createVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}/replace")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create VfModule on a specified version, serviceInstance and vnfInstance",response=Response.class)
+ @Transactional
+ public Response replaceVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
+ return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @PUT
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Update VfModule on a specified version, serviceInstance, vnfInstance and vfModule",response=Response.class)
+ @Transactional
+ public Response updateVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/inPlaceSoftwareUpdate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Perform VNF software update",response=Response.class)
+ @Transactional
+ public Response inPlaceSoftwareUpdate(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ return serviceInstances(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @DELETE
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided VfModule instance",response=Response.class)
+ @Transactional
+ public Response deleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}/deactivateAndCloudDelete")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Deactivate and Cloud Delete VfModule instance",response=Response.class)
+ @Transactional
+ public Response deactivateAndCloudDeleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
+ Response response = serviceInstances(request, Action.deactivateAndCloudDelete, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ return response;
+ }
+
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create VolumeGroup on a specified version, serviceInstance, vnfInstance",response=Response.class)
+ @Transactional
+ public Response createVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @PUT
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Update VolumeGroup on a specified version, serviceInstance, vnfInstance and volumeGroup",response=Response.class)
+ @Transactional
+ public Response updateVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId);
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @DELETE
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided VolumeGroup instance",response=Response.class)
+ @Transactional
+ public Response deleteVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId);
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create NetworkInstance on a specified version and serviceInstance ",response=Response.class)
+ @Transactional
+ public Response createNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @PUT
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks/{networkInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Update VolumeGroup on a specified version, serviceInstance, networkInstance",response=Response.class)
+ @Transactional
+ public Response updateNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("networkInstanceId", networkInstanceId);
+ return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ @DELETE
+ @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks/{networkInstanceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided Network instance",response=Response.class)
+ @Transactional
+ public Response deleteNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) throws ApiException {
+ String requestId = getRequestId(requestContext);
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("networkInstanceId", networkInstanceId);
+ return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, getRequestUri(requestContext));
+ }
+
+ public String getRequestUri(ContainerRequestContext context){
+ String requestUri = context.getUriInfo().getPath();
+ requestUri = requestUri.substring(requestUri.indexOf("/serviceInstantiation/") + 22);
+ return requestUri;
+ }
+
+ public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException {
+ String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId");
+ Boolean aLaCarte = null;
+ long startTime = System.currentTimeMillis ();
+ ServiceInstancesRequest sir = null;
+ String apiVersion = version.substring(1);
+
+ sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
+ String requestScope = deriveRequestScope(action, sir, requestUri);
+ InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.PENDING, requestJSON, requestScope);
+ if(sir.getRequestDetails().getRequestParameters() != null){
+ aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
+ }
+ parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
+ setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+
+ int requestVersion = Integer.parseInt(version.substring(1));
+ String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+ boolean alaCarteFlag = msoRequest.getAlacarteFlag(sir);
+ String vnfType = msoRequest.getVnfType(sir,requestScope,action,requestVersion);
+ String networkType = msoRequest.getNetworkType(sir,requestScope);
+ String sdcServiceModelVersion = msoRequest.getSDCServiceModelVersion(sir);
+ String serviceInstanceType = msoRequest.getServiceInstanceType(sir,requestScope);
+ String vfModuleType = msoRequest.getVfModuleType(sir,requestScope,action,requestVersion);
+
+ if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null){
+ currentActiveReq.setVnfType(vnfType);
+ }else if(requestScope.equalsIgnoreCase(ModelType.network.name()) && networkType != null){
+ currentActiveReq.setNetworkType(networkType);
+ }
+
+ InfraActiveRequests dup = null;
+
+
+ dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
+
+ if (dup != null) {
+ buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
+ }
+ ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
+
+ RequestReferences referencesResponse = new RequestReferences();
+
+ referencesResponse.setRequestId(requestId);
+
+ serviceResponse.setRequestReferences(referencesResponse);
+ Boolean isBaseVfModule = false;
+
+ RecipeLookupResult recipeLookupResult = getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq);
+
+ ModelType modelType;
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
+ modelType = ModelType.vnf;
+ }else {
+ modelType =modelInfo.getModelType();
+ }
+
+ if (modelType.equals(ModelType.vfModule)) {
+
+
+ // Get VF Module-specific base module indicator
+ VfModule vfm;
+
+ String modelVersionId = modelInfo.getModelVersionId();
+
+ if(modelVersionId != null) {
+ vfm = vfModuleRepo.findByModelUUID(modelVersionId);
+ } else {
+ vfm = vfModuleRepo.findByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), modelInfo.getModelVersion());
+ }
+
+ if (vfm != null) {
+ if (vfm.getIsBase()) {
+ isBaseVfModule = true;
+ }
+ } else if (action == Action.createInstance || action == Action.updateInstance) {
+ // There is no entry for this vfModuleType with this version, if specified, in VF_MODULE table in Catalog DB.
+ // This request cannot proceed
+
+ String serviceVersionText = "";
+ if (sdcServiceModelVersion != null && !sdcServiceModelVersion.isEmpty ()) {
+ serviceVersionText = " with version " + sdcServiceModelVersion;
+ }
+
+ String errorMessage = "VnfType " + vnfType + " and VF Module Model Name " + modelInfo.getModelName() + serviceVersionText + " not found in MSO Catalog DB";
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder(errorMessage, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage());
+
+ throw vfModuleException;
+ }
+ }
+
+
+ serviceInstanceId = "";
+ String vnfId = "";
+ String vfModuleId = "";
+ String volumeGroupId = "";
+ String networkId = "";
+ String correlationId = "";
+
+ if(sir.getServiceInstanceId () != null){
+ serviceInstanceId = sir.getServiceInstanceId ();
+ }
+
+ if(sir.getVnfInstanceId () != null){
+ vnfId = sir.getVnfInstanceId ();
+ }
+
+ if(sir.getVfModuleInstanceId () != null){
+ vfModuleId = sir.getVfModuleInstanceId ();
+ }
+
+ if(sir.getVolumeGroupInstanceId () != null){
+ volumeGroupId = sir.getVolumeGroupInstanceId ();
+ }
+
+ if(sir.getNetworkInstanceId () != null){
+ networkId = sir.getNetworkInstanceId ();
+ }
+
+ if (sir.getCorrelationId() != null) {
+ correlationId = sir.getCorrelationId();
+ }
+ iar.save(currentActiveReq);
+
+ if(!requestScope.equalsIgnoreCase(ModelType.service.name())){
+ aLaCarte = true;
+ }else if(aLaCarte == null){
+ aLaCarte = false;
+ }
+
+ return postBPELRequest(currentActiveReq,action, requestId, startTime, requestJSON, recipeLookupResult.getOrchestrationURI(), recipeLookupResult.getRecipeTimeout(),
+ isBaseVfModule, serviceInstanceId, correlationId, vnfId, vfModuleId, volumeGroupId, networkId, null,
+ serviceInstanceType,vnfType, vfModuleType,networkType, apiVersion, aLaCarte, requestUri, null, requestScope, sir);
+ }
+
+ private String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) {
+ if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){
+ return (ModelType.vnf.name());
+ }else{
+ String requestScope;
+ if(sir.getRequestDetails().getModelInfo().getModelType() == null){
+ requestScope = requestScopeFromUri(requestUri);
+ }else{
+ requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
+ }
+ return requestScope;
+ }
+ }
+ private String requestScopeFromUri(String requestUri){
+ String requestScope;
+ if(requestUri.contains(ModelType.network.name())){
+ requestScope = ModelType.network.name();
+ }else if(requestUri.contains(ModelType.vfModule.name())){
+ requestScope = ModelType.vfModule.name();
+ }else if(requestUri.contains(ModelType.volumeGroup.name())){
+ requestScope = ModelType.volumeGroup.name();
+ }else if(requestUri.contains(ModelType.configuration.name())){
+ requestScope = ModelType.configuration.name();
+ }else if(requestUri.contains(ModelType.vnf.name())){
+ requestScope = ModelType.vnf.name();
+ }else{
+ requestScope = ModelType.service.name();
+ }
+ return requestScope;
+ }
+ private Response postBPELRequest(InfraActiveRequests currentActiveReq, Actions action, String requestId, long startTime, String msoRawRequest,
+ String orchestrationUri, int timeOut, Boolean isBaseVfModule,
+ String serviceInstanceId, String correlationId, String vnfId, String vfModuleId, String volumeGroupId, String networkId,
+ String configurationId, String serviceInstanceType, String vnfType, String vfModuleType, String networkType,
+ String apiVersion, boolean aLaCarte, String requestUri, String paramXsd, String requestScope, ServiceInstancesRequest sir) throws ApiException {
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+ try {
+ requestClient = reqClientFactory.getRequestClient (orchestrationUri);
+ response = requestClient.post(new RequestClientParameter.Builder()
+ .setRequestId(requestId)
+ .setBaseVfModule(isBaseVfModule)
+ .setRecipeTimeout(timeOut)
+ .setRequestAction(action.toString())
+ .setServiceInstanceId(serviceInstanceId)
+ .setCorrelationId(correlationId)
+ .setVnfId(vnfId)
+ .setVfModuleId(vfModuleId)
+ .setVolumeGroupId(volumeGroupId)
+ .setNetworkId(networkId)
+ .setConfigurationId(configurationId)
+ .setServiceType(serviceInstanceType)
+ .setVnfType(vnfType)
+ .setVfModuleType(vfModuleType)
+ .setNetworkType(networkType)
+ .setRequestDetails(mapJSONtoMSOStyle(msoRawRequest, sir, aLaCarte, action))
+ .setApiVersion(apiVersion)
+ .setALaCarte(aLaCarte)
+ .setRecipeParamXsd(paramXsd)
+ .setRequestUri(requestUri).build());
+
+
+ } catch (Exception e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ String url = requestClient != null ? requestClient.getUrl() : "";
+ ClientConnectionException clientException = new ClientConnectionException.Builder(url, HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build();
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
+
+ throw clientException;
+ }
+
+ if (response == null) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ClientConnectionException clientException = new ClientConnectionException.Builder(requestClient.getUrl(), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build();
+
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
+
+ throw clientException;
+ }
+
+ ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
+ int bpelStatus = respHandler.getStatus ();
+
+ // BPEL accepted the request, the request is in progress
+ if (bpelStatus == HttpStatus.SC_ACCEPTED) {
+ ServiceInstancesResponse jsonResponse;
+ CamundaResponse camundaResp = respHandler.getResponse();
+
+ if("Success".equalsIgnoreCase(camundaResp.getMessage())) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
+ } catch (IOException e) {
+ e.printStackTrace();
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ currentActiveReq.setRequestStatus(Status.FAILED.name());
+ currentActiveReq.setStatusMessage(validateException.getMessage());
+ throw validateException;
+ }
+
+ currentActiveReq.setRequestStatus(Status.IN_PROGRESS.name());
+ setInstanceId(currentActiveReq, requestScope, jsonResponse.getRequestReferences().getInstanceId(), new HashMap<>());
+
+ iar.save(currentActiveReq);
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion);
+ }
+ }
+
+ List<String> variables = new ArrayList<>();
+ variables.add(bpelStatus + "");
+ String camundaJSONResponseBody = respHandler.getResponseBody ();
+ if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
+ BPMNFailureException bpmnException = new BPMNFailureException.Builder(String.valueOf(bpelStatus) + camundaJSONResponseBody, bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
+
+ throw bpmnException;
+ } else {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build();
+
+
+ BPMNFailureException servException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, servException.getMessage());
+
+ throw servException;
+ }
+ }
+
+ private void setInstanceId(InfraActiveRequests currentActiveReq, String requestScope, String instanceId, Map<String, String> instanceIdMap) {
+ if(StringUtils.isNotBlank(instanceId)) {
+ if(ModelType.service.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setServiceInstanceId(instanceId);
+ } else if(ModelType.vnf.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setVnfId(instanceId);
+ } else if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setVfModuleId(instanceId);
+ } else if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setVolumeGroupId(instanceId);
+ } else if(ModelType.network.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setNetworkId(instanceId);
+ } else if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ currentActiveReq.setConfigurationId(instanceId);
+ }
+ } else if(instanceIdMap != null && !instanceIdMap.isEmpty()) {
+ if(instanceIdMap.get("serviceInstanceId") != null){
+ currentActiveReq.setServiceInstanceId(instanceIdMap.get("serviceInstanceId"));
+ }
+ if(instanceIdMap.get("vnfInstanceId") != null){
+ currentActiveReq.setVnfId(instanceIdMap.get("vnfInstanceId"));
+ }
+ if(instanceIdMap.get("vfModuleInstanceId") != null){
+ currentActiveReq.setVfModuleId(instanceIdMap.get("vfModuleInstanceId"));
+ }
+ if(instanceIdMap.get("volumeGroupInstanceId") != null){
+ currentActiveReq.setVolumeGroupId(instanceIdMap.get("volumeGroupInstanceId"));
+ }
+ if(instanceIdMap.get("networkInstanceId") != null){
+ currentActiveReq.setNetworkId(instanceIdMap.get("networkInstanceId"));
+ }
+ if(instanceIdMap.get("configurationInstanceId") != null){
+ currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
+ }
+ }
+ }
+
+ protected String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest, boolean isAlaCarte, Actions action) throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class);
+ if( !isAlaCarte && Action.createInstance.equals(action) && serviceInstRequest != null &&
+ serviceInstRequest.getRequestDetails() != null &&
+ serviceInstRequest.getRequestDetails().getRequestParameters() != null) {
+ sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration());
+ sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams());
+ }
+ msoLogger.debug("Value as string: " + mapper.writeValueAsString(sir));
+ return mapper.writeValueAsString(sir);
+ }
+
+ private void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest,
+ String instanceName, String requestScope, InfraActiveRequests dup) throws ApiException {
+
+ // Found the duplicate record. Return the appropriate error.
+ String instance = null;
+ if(instanceName != null){
+ instance = instanceName;
+ }else{
+ instance = instanceIdMap.get(requestScope + "InstanceId");
+ }
+ //List<String> variables = new ArrayList<String>();
+ //variables.add(dup.getRequestStatus());
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ DuplicateRequestException dupException = new DuplicateRequestException.Builder(requestScope,instance,dup.getRequestStatus(),dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage());
+
+ throw dupException;
+ }
+
+ private InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime,
+ MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException {
+ InfraActiveRequests dup = null;
+ try {
+ if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance || action == Action.assignInstance))){
+ dup = iar.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
+ }
+ } catch (Exception e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Duplicate Check Request", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+
+ throw validateException;
+ }
+ return dup;
+ }
+
+ private ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action, long startTime,
+ ServiceInstancesRequest sir, MsoRequest msoRequest, String requestId, String requestUri) throws ApiException {
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ return mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+
+ } catch (IOException e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+ ValidateException validateException = new ValidateException.Builder("Error mapping request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ String requestScope = requestScopeFromUri(requestUri);
+
+ msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON);
+
+ throw validateException;
+ }
+ }
+
+ private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version,
+ String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException {
+ int reqVersion = Integer.parseInt(version.substring(1));
+ try {
+ msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte);
+ } catch (Exception e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+
+ throw validateException;
+ }
+ }
+
+ private RecipeLookupResult getServiceInstanceOrchestrationURI(ServiceInstancesRequest sir, Actions action, boolean alaCarteFlag,
+ InfraActiveRequests currentActiveReq) throws ApiException {
+ RecipeLookupResult recipeLookupResult = null;
+ //if the aLaCarte flag is set to TRUE, the API-H should choose the VID_DEFAULT recipe for the requested action
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ // Query MSO Catalog DB
+
+ if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
+ recipeLookupResult = getDefaultVnfUri(sir, action);
+ } else if (modelInfo.getModelType().equals(ModelType.service)) {
+ try {
+ recipeLookupResult = getServiceURI(sir, action,alaCarteFlag);
+ } catch (IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+
+ throw validateException;
+ }
+ } else if (modelInfo.getModelType().equals(ModelType.vfModule) ||
+ modelInfo.getModelType().equals(ModelType.volumeGroup) || modelInfo.getModelType().equals(ModelType.vnf)) {
+ try {
+ recipeLookupResult = getVnfOrVfModuleUri( sir, action);
+ } catch (ValidationException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+
+ throw validateException;
+ }
+ }else if (modelInfo.getModelType().equals(ModelType.network)) {
+ try {
+ recipeLookupResult = getNetworkUri( sir, action);
+ } catch (ValidationException e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+
+ throw validateException;
+ }
+ }
+
+ if (recipeLookupResult == null) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ RecipeNotFoundException recipeNotFoundExceptionException = new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
+ throw recipeNotFoundExceptionException;
+ }
+ return recipeLookupResult;
+ }
+
+
+ private RecipeLookupResult getServiceURI(ServiceInstancesRequest servInstReq, Actions action, boolean alaCarteFlag) throws IOException {
+ // SERVICE REQUEST
+ // Construct the default service name
+ // TODO need to make this a configurable property
+ String defaultServiceModelName = getDefaultModel(servInstReq);
+ RequestDetails requestDetails = servInstReq.getRequestDetails();
+ ModelInfo modelInfo = requestDetails.getModelInfo();
+ org.onap.so.db.catalog.beans.Service serviceRecord;
+ List<org.onap.so.db.catalog.beans.Service> serviceRecordList;
+ ServiceRecipe recipe = null;
+
+ if(alaCarteFlag){
+ serviceRecord = serviceRepo.findByModelNameOrderByModelVersionDesc(defaultServiceModelName);
+ if(serviceRecord !=null){
+ recipe = serviceRecord.getRecipes().get(action.toString());
+ }
+ }else{
+ serviceRecord = serviceRepo.findOneByModelUUID(modelInfo.getModelVersionId());
+ recipe = serviceRecipeRepo.findFirstByServiceModelUUIDAndAction(modelInfo.getModelVersionId(), action.toString());
+ if (recipe == null){
+ serviceRecordList = serviceRepo.findByModelInvariantUUIDOrderByModelVersionDesc(modelInfo.getModelInvariantId());
+ if(!serviceRecordList.isEmpty()){
+ for(org.onap.so.db.catalog.beans.Service record : serviceRecordList){
+ recipe = record.getRecipes().get(action.toString());
+ if(recipe != null){
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ //if an aLaCarte flag was sent in the request, throw an error if the recipe was not found
+ RequestParameters reqParam = requestDetails.getRequestParameters();
+ if(reqParam!=null && alaCarteFlag && recipe==null){
+ return null;
+ } else if(!alaCarteFlag && recipe != null && Action.createInstance.equals(action)) {
+ mapToLegacyRequest(requestDetails);
+ }else if (recipe == null) { //aLaCarte wasn't sent, so we'll try the default
+ serviceRecord = serviceRepo.findByModelNameOrderByModelVersionDesc(defaultServiceModelName);
+ recipe = serviceRecord.getRecipes().get( action.toString());
+ }
+ if(modelInfo.getModelVersionId() == null) {
+ modelInfo.setModelVersionId(serviceRecord.getModelUUID());
+ }
+ if(recipe==null){
+ return null;
+ }
+ return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
+ }
+
+ protected void mapToLegacyRequest(RequestDetails requestDetails) throws IOException {
+ RequestParameters reqParam;
+ if (requestDetails.getRequestParameters() == null) {
+ reqParam = new RequestParameters();
+ } else {
+ reqParam = requestDetails.getRequestParameters();
+ }
+ if(requestDetails.getCloudConfiguration() == null) {
+ CloudConfiguration cloudConfig = configureCloudConfig(reqParam);
+ if(cloudConfig != null) {
+ requestDetails.setCloudConfiguration(cloudConfig);
+ }
+ }
+
+ List<Map<String, Object>> userParams = configureUserParams(reqParam);
+ if(!userParams.isEmpty()) {
+ if (reqParam == null) {
+ requestDetails.setRequestParameters(new RequestParameters());
+ }
+ requestDetails.getRequestParameters().setUserParams(userParams);
+ }
+ }
+
+ protected CloudConfiguration configureCloudConfig(RequestParameters reqParams) throws IOException {
+
+ for(Map<String, Object> params : reqParams.getUserParams()){
+ if(params.containsKey("service")){
+ Service service = serviceMapper(params);
+
+ Optional<CloudConfiguration> targetConfiguration = addCloudConfig(service.getCloudConfiguration());
+
+ if (targetConfiguration.isPresent()) {
+ return targetConfiguration.get();
+ } else {
+ for(Networks network : service.getResources().getNetworks()) {
+ targetConfiguration = addCloudConfig(network.getCloudConfiguration());
+ if(targetConfiguration.isPresent()) {
+ return targetConfiguration.get();
+ }
+ }
+
+ for(Vnfs vnf : service.getResources().getVnfs()) {
+ targetConfiguration = addCloudConfig(vnf.getCloudConfiguration());
+
+ if(targetConfiguration.isPresent()) {
+ return targetConfiguration.get();
+ }
+
+ for(VfModules vfModule : vnf.getVfModules()) {
+ targetConfiguration = addCloudConfig(vfModule.getCloudConfiguration());
+
+ if(targetConfiguration.isPresent()) {
+ return targetConfiguration.get();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private Optional<CloudConfiguration> addCloudConfig(CloudConfiguration sourceCloudConfiguration) {
+ CloudConfiguration targetConfiguration = new CloudConfiguration();
+ if(sourceCloudConfiguration != null) {
+ targetConfiguration.setAicNodeClli(sourceCloudConfiguration.getAicNodeClli());
+ targetConfiguration.setTenantId(sourceCloudConfiguration.getTenantId());
+ targetConfiguration.setLcpCloudRegionId(sourceCloudConfiguration.getLcpCloudRegionId());
+ return Optional.of(targetConfiguration);
+ }
+ return Optional.empty();
+ }
+
+ protected List<Map<String, Object>> configureUserParams(RequestParameters reqParams) throws IOException {
+ msoLogger.debug("Configuring UserParams for Macro Request");
+ Map<String, Object> userParams = new HashMap<>();
+
+ for(Map<String, Object> params : reqParams.getUserParams()){
+ if(params.containsKey("service")){
+ Service service = serviceMapper(params);
+
+ addUserParams(userParams, service.getInstanceParams());
+
+ for(Networks network : service.getResources().getNetworks()) {
+ addUserParams(userParams, network.getInstanceParams());
+ }
+
+ for(Vnfs vnf: service.getResources().getVnfs()) {
+ addUserParams(userParams, vnf.getInstanceParams());
+
+ for(VfModules vfModule: vnf.getVfModules()) {
+ addUserParams(userParams, vfModule.getInstanceParams());
+ }
+ }
+ }
+ }
+
+ return mapFlatMapToNameValue(userParams);
+ }
+
+ private Service serviceMapper(Map<String, Object> params)
+ throws JsonProcessingException, IOException, JsonParseException, JsonMappingException {
+ ObjectMapper obj = new ObjectMapper();
+ String input = obj.writeValueAsString(params.get("service"));
+ return obj.readValue(input, Service.class);
+ }
+
+ private void addUserParams(Map<String, Object> targetUserParams, List<Map<String, String>> sourceUserParams) {
+ for(Map<String, String> map : sourceUserParams) {
+ for (Map.Entry<String, String> entry : map.entrySet()) {
+ targetUserParams.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ protected List<Map<String, Object>> mapFlatMapToNameValue(Map<String, Object> flatMap) {
+ List<Map<String, Object>> targetUserParams = new ArrayList<>();
+
+ for(Map.Entry<String, Object> map : flatMap.entrySet()) {
+ Map<String, Object> targetMap = new HashMap<>();
+ targetMap.put(NAME, map.getKey());
+ targetMap.put(VALUE, map.getValue());
+ targetUserParams.add(targetMap);
+ }
+ return targetUserParams;
+ }
+
+ private RecipeLookupResult getVnfOrVfModuleUri(ServiceInstancesRequest servInstReq, Actions action) throws ValidationException {
+
+ ModelInfo modelInfo = servInstReq.getRequestDetails().getModelInfo();
+ String vnfComponentType = modelInfo.getModelType().name();
+
+ RelatedInstanceList[] instanceList = null;
+ if (servInstReq.getRequestDetails() != null) {
+ instanceList = servInstReq.getRequestDetails().getRelatedInstanceList();
+ }
+
+ Recipe recipe = null;
+ String defaultSource = getDefaultModel(servInstReq);
+ String modelCustomizationId = modelInfo.getModelCustomizationId();
+ String modelCustomizationName = modelInfo.getModelCustomizationName();
+ String relatedInstanceModelVersionId = null;
+ String relatedInstanceModelInvariantId = null;
+ String relatedInstanceVersion = null;
+ String relatedInstanceModelCustomizationName = null;
+
+ if (instanceList != null) {
+
+ for(RelatedInstanceList relatedInstanceList : instanceList){
+
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+ ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo();
+ if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)){
+ relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId();
+ relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion();
+ }
+
+ if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)){
+ relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId();
+ relatedInstanceModelInvariantId = relatedInstanceModelInfo.getModelInvariantId();
+ relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion();
+ relatedInstanceModelCustomizationName = relatedInstanceModelInfo.getModelCustomizationName();
+ }
+ }
+
+ if(modelInfo.getModelType().equals(ModelType.vnf)) {
+ // a. For a vnf request (only create, no update currently):
+ // i. (v3-v4) If modelInfo.modelCustomizationId is provided, use it to validate catalog DB has record in vnf_resource_customization.model_customization_uuid.
+ // ii. (v2-v4) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or pre-v3), then modelInfo.modelCustomizationName must have
+ // been provided (else create request should be rejected). APIH should use the relatedInstance.modelInfo[service].modelVersionId** + modelInfo[vnf].modelCustomizationName
+ // to “join�? service_to_resource_customizations with vnf_resource_customization to confirm a vnf_resource_customization.model_customization_uuid record exists.
+ // **If relatedInstance.modelInfo[service].modelVersionId was not provided, use relatedInstance.modelInfo[service].modelInvariantId + modelVersion instead to lookup modelVersionId
+ // (MODEL_UUID) in SERVICE table.
+ // iii. Regardless of how the value was provided/obtained above, APIH must always populate vnfModelCustomizationId in bpmnRequest. It would be assumed it was MSO generated
+ // during 1707 data migration if VID did not provide it originally on request.
+ // iv. Note: continue to construct the “vnf-type�? value and pass to BPMN (must still be populated in A&AI).
+ // 1. If modelCustomizationName is NOT provided on a vnf/vfModule request, use modelCustomizationId to look it up in our catalog to construct vnf-type value to pass to BPMN.
+
+ VnfResource vnfResource = null;
+ VnfResourceCustomization vrc=null;
+ // Validation for vnfResource
+
+ if(modelCustomizationId!=null) {
+ vrc = vnfCustomRepo.findOneByModelCustomizationUUID(modelCustomizationId);
+ if(vrc != null){
+ vnfResource = vrc.getVnfResources();
+ }
+ } else {
+ org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(relatedInstanceModelVersionId);
+ if(service == null) {
+ service = serviceRepo.findByModelVersionAndModelInvariantUUID(relatedInstanceVersion, relatedInstanceModelInvariantId);
+ }
+
+ if(service == null) {
+ throw new ValidationException("service in relatedInstance");
+ }
+ for (VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()) {
+ if (vnfResourceCustom.getModelInstanceName().equals(modelCustomizationName)) {
+ vrc=vnfResourceCustom;
+ }
+ }
+
+ if(vrc != null) {
+ vnfResource = vrc.getVnfResources();
+ modelInfo.setModelCustomizationId(vrc.getModelCustomizationUUID());
+ modelInfo.setModelCustomizationUuid(vrc.getModelCustomizationUUID());
+ }
+ }
+
+ if(vnfResource==null){
+ throw new ValidationException("vnfResource");
+ } else {
+ if(modelInfo.getModelVersionId() == null) {
+ modelInfo.setModelVersionId(vnfResource.getModelUUID());
+ }
+ }
+
+ VnfRecipe vnfRecipe = null;
+
+ if(vrc != null) {
+ String nfRole = vrc.getNfRole();
+ if(nfRole != null) {
+ vnfRecipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(vrc.getNfRole(), action.toString());
+ }
+ }
+
+ if(vnfRecipe == null) {
+ vnfRecipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(defaultSource, action.toString());
+ }
+
+ if (vnfRecipe == null) {
+ return null;
+ }
+
+ return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout());
+ } else {
+ /* (v5-v7) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or pre-v3), then modelInfo.modelCustomizationName must have
+ // been provided (else create request should be rejected). APIH should use the relatedInstance.modelInfo[vnf].modelVersionId + modelInfo[vnf].modelCustomizationName
+ // to join vnf_to_resource_customizations with vf_resource_customization to confirm a vf_resource_customization.model_customization_uuid record exists.
+ // Once the vnfs model_customization_uuid has been obtained, use it to find all vfModule customizations for that vnf customization in the vnf_res_custom_to_vf_module_custom join table.
+ // For each vf_module_cust_model_customization_uuid value returned, use that UUID to query vf_module_customization table along with modelInfo[vfModule|volumeGroup].modelVersionId to
+ // confirm record matches request data (and to identify the modelCustomizationId associated with the vfModule in the request). This means taking each record found
+ // in vf_module_customization and looking up in vf_module (using vf_module_customization’s FK into vf_module) to find a match on MODEL_INVARIANT_UUID (modelInvariantId)
+ // and MODEL_VERSION (modelVersion).
+ */
+ VfModuleCustomization vfmc = null;
+ VnfResource vnfr;
+ VnfResourceCustomization vnfrc;
+ VfModule vfModule = null;
+
+ if(modelInfo.getModelCustomizationId() != null) {
+ vfmc = vfModuleCustomRepo.findByModelCustomizationUUID(modelInfo.getModelCustomizationId());
+ } else {
+ vnfr = vnfRepo.findResourceByModelUUID(relatedInstanceModelVersionId);
+ if(vnfr == null){
+ vnfr = vnfRepo.findResourceByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion);
+ }
+ vnfrc = vnfCustomRepo.findByModelInstanceNameAndVnfResources(relatedInstanceModelCustomizationName, vnfr);
+
+ List<VfModuleCustomization> list = vnfrc.getVfModuleCustomizations();
+
+ String vfModuleModelUUID = modelInfo.getModelVersionId();
+ for(VfModuleCustomization vf : list) {
+ VfModuleCustomization vfmCustom;
+ if(vfModuleModelUUID != null){
+ vfmCustom = vfModuleCustomRepo.findByModelCustomizationUUIDAndVfModuleModelUUID(vf.getModelCustomizationUUID(), vfModuleModelUUID);
+ if(vfmCustom != null){
+ vfModule = vfmCustom.getVfModule();
+ }
+ }else{
+ vfmCustom = vfModuleCustomRepo.findByModelCustomizationUUID(vf.getModelCustomizationUUID());
+ if(vfmCustom != null){
+ vfModule = vfmCustom.getVfModule();
+ }else{
+ vfModule = vfModuleRepo.findByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion);
+ }
+ }
+
+ if(vfModule != null) {
+ modelInfo.setModelCustomizationId(vf.getModelCustomizationUUID());
+ modelInfo.setModelCustomizationUuid(vf.getModelCustomizationUUID());
+ break;
+ }
+ }
+ }
+
+ if(vfmc == null && vfModule == null) {
+ throw new ValidationException("vfModuleCustomization");
+ } else if (vfModule == null && vfmc != null) {
+ vfModule = vfmc.getVfModule(); // can't be null as vfModuleModelUUID is not-null property in VfModuleCustomization table
+ }
+
+ if(modelInfo.getModelVersionId() == null) {
+ modelInfo.setModelVersionId(vfModule.getModelUUID());
+ }
+
+
+ recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(vfModule.getModelUUID(), vnfComponentType, action.toString());
+ if(recipe == null){
+ List<VfModule> vfModuleRecords= vfModuleRepo.findByModelInvariantUUIDOrderByModelVersionDesc(vfModule.getModelInvariantUUID());
+ if(!vfModuleRecords.isEmpty()){
+ for(VfModule record : vfModuleRecords){
+ recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(record.getModelUUID(), vnfComponentType, action.toString());
+ if(recipe != null){
+ break;
+ }
+ }
+ }
+ }
+ if(recipe == null) {
+ recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString());
+ if (recipe == null) {
+ recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVnfComponentTypeAndAction(vnfComponentType, action.toString());
+ }
+
+ if(recipe == null) {
+ return null;
+ }
+ }
+ }
+ } else {
+
+ if(modelInfo.getModelType().equals(ModelType.vnf)) {
+ recipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(defaultSource, action.toString());
+ if (recipe == null) {
+ return null;
+ }
+ } else {
+ recipe = vnfComponentRecipeRepo.findVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString());
+
+ if (recipe == null) {
+ return null;
+ }
+ }
+ }
+
+ return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
+ }
+
+ private RecipeLookupResult getDefaultVnfUri(ServiceInstancesRequest sir, Actions action) {
+
+ String defaultSource = getDefaultModel(sir);
+
+ VnfRecipe vnfRecipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(defaultSource, action.toString());
+
+ if (vnfRecipe == null) {
+ return null;
+ }
+
+ return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout());
+ }
+
+
+ private RecipeLookupResult getNetworkUri(ServiceInstancesRequest sir, Actions action) throws ValidationException {
+
+ String defaultNetworkType = getDefaultModel(sir);
+
+ ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
+ String modelName = modelInfo.getModelName();
+ Recipe recipe = null;
+
+ if(modelInfo.getModelCustomizationId()!=null){
+ NetworkResource networkResource = networkCustomizationRepo.findOneByModelCustomizationUUID(modelInfo.getModelCustomizationId()).getNetworkResource();
+ if(networkResource!=null){
+ if(modelInfo.getModelVersionId() == null) {
+ modelInfo.setModelVersionId(networkResource.getModelUUID());
+ }
+ recipe = networkRecipeRepo.findByModelNameAndAction(networkResource.getModelName(), action.toString());
+ }else{
+ throw new ValidationException("no catalog entry found");
+ }
+ }else{
+ //ok for version < 3 and action delete
+ recipe = networkRecipeRepo.findByModelNameAndAction(modelName, action.toString());
+ }
+
+ if(recipe == null){
+ recipe = networkRecipeRepo.findByModelNameAndAction(defaultNetworkType, action.toString());
+ }
+
+ return recipe !=null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null;
+ }
+
+ private Optional<String> retrieveModelName(RequestParameters requestParams) {
+ String requestTestApi = null;
+ TestApi testApi = null;
+
+ if (requestParams != null) {
+ requestTestApi = requestParams.getTestApi();
+ }
+
+ if (requestTestApi == null) {
+ if(requestParams != null && requestParams.getALaCarte() != null && !requestParams.getALaCarte()) {
+ requestTestApi = env.getProperty(CommonConstants.MACRO_TEST_API);
+ } else {
+ requestTestApi = env.getProperty(CommonConstants.ALACARTE_TEST_API);
+ }
+ }
+
+ try {
+ testApi = TestApi.valueOf(requestTestApi);
+ return Optional.of(testApi.getModelName());
+ } catch (Exception e) {
+ msoLogger.warnSimple("Catching the exception on the valueOf enum call and continuing", e);
+ throw new IllegalArgumentException("Invalid TestApi is provided", e);
+ }
+ }
+
+ private String getDefaultModel(ServiceInstancesRequest sir) {
+ String defaultModel = sir.getRequestDetails().getRequestInfo().getSource() + "_DEFAULT";
+ Optional<String> oModelName = retrieveModelName(sir.getRequestDetails().getRequestParameters());
+ if (oModelName.isPresent()) {
+ defaultModel = oModelName.get();
+ }
+ return defaultModel;
+ }
+
+ private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException {
+ String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId");
+ Boolean aLaCarte = null;
+ String apiVersion = version.substring(1);
+
+ long startTime = System.currentTimeMillis ();
+ ServiceInstancesRequest sir = null;
+
+ sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri);
+ String requestScope = deriveRequestScope(action,sir, requestUri);
+ InfraActiveRequests currentActiveReq = msoRequest.createRequestObject ( sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope);
+ if(sir.getRequestDetails().getRequestParameters() != null){
+ aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
+ }
+ parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq);
+ setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
+ String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+
+ InfraActiveRequests dup = null;
+
+ dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq);
+
+ if (instanceIdMap != null && dup != null) {
+ buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
+ }
+
+ ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
+ RequestReferences referencesResponse = new RequestReferences();
+ referencesResponse.setRequestId(requestId);
+ serviceResponse.setRequestReferences(referencesResponse);
+
+
+ String orchestrationUri = env.getProperty(CommonConstants.ALACARTE_ORCHESTRATION);
+ String timeOut = env.getProperty(CommonConstants.ALACARTE_RECIPE_TIMEOUT);
+
+ if (StringUtils.isBlank(orchestrationUri) || StringUtils.isBlank(timeOut)) {
+ String error = StringUtils.isBlank(orchestrationUri) ? "ALaCarte Orchestration URI not found in properties" : "ALaCarte Recipe Timeout not found in properties";
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ ValidateException validateException = new ValidateException.Builder(error, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+
+ throw validateException;
+
+ }
+
+ serviceInstanceId = "";
+ String configurationId = "";
+ String correlationId = "";
+
+ if(sir.getServiceInstanceId () != null){
+ serviceInstanceId = sir.getServiceInstanceId ();
+ }
+
+ if(sir.getConfigurationId() != null){
+ configurationId = sir.getConfigurationId();
+ }
+ if (sir.getCorrelationId() != null) {
+ correlationId = sir.getCorrelationId();
+ }
+ iar.save(currentActiveReq);
+
+ if(!requestScope.equalsIgnoreCase(ModelType.service.name())){
+ aLaCarte = true;
+ }else if(aLaCarte == null){
+ aLaCarte = false;
+ }
+
+ return postBPELRequest(currentActiveReq,action, requestId, startTime, requestJSON, orchestrationUri, Integer.parseInt(timeOut), false,
+ serviceInstanceId, correlationId, null, null, null, null, configurationId, null, null, null, null, apiVersion, aLaCarte, requestUri, null, requestScope, null);
+ }
+
+ public String getRequestId(ContainerRequestContext requestContext) throws ValidateException {
+ String requestId = null;
+ if (requestContext.getProperty("requestId") != null) {
+ requestId = requestContext.getProperty("requestId").toString();
+ }
+ if (UUIDChecker.isValidUUID(requestId)) {
+ return requestId;
+ } else {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER)
+ .errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java
index 3ce4759577..0a996dc3dc 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SpringContextHelper.java
@@ -7,9 +7,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.
@@ -18,28 +18,24 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap;
+package org.onap.so.apihandlerinfra;
-import java.util.Map;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.client.dmaap.DmaapProperties;
-import org.openecomp.mso.properties.MsoJavaProperties;
+@Component
+public class SpringContextHelper implements ApplicationContextAware {
-public class DmaapPropertiesImpl implements DmaapProperties {
+ private static ApplicationContext context;
- private final Map<String, String> props;
-
- public DmaapPropertiesImpl () {
-
- MsoJavaProperties properties = MsoPropertiesUtils.loadMsoProperties();
- this.props = properties.asMap();
- }
-
@Override
- public Map<String, String> getProperties() {
-
- return this.props;
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ context = applicationContext;
}
+ public static ApplicationContext getAppContext() {
+ return context;
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Status.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Status.java
index b2b90f76b0..fe9764a2f2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Status.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Status.java
@@ -7,9 +7,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.
@@ -18,7 +18,8 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra;
+
/*
* Enum for Status values returned by API Handler to Tail-F
@@ -27,6 +28,7 @@ public enum Status {
PENDING,
IN_PROGRESS,
COMPLETE,
+ COMPLETED,
FAILED,
TIMEOUT,
UNLOCKED,
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
new file mode 100644
index 0000000000..4900696546
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
@@ -0,0 +1,337 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.RequestClient;
+import org.onap.so.apihandler.common.RequestClientFactory;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandler.common.ResponseHandler;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tasksbeans.TaskList;
+import org.onap.so.apihandlerinfra.tasksbeans.TaskVariableValue;
+import org.onap.so.apihandlerinfra.tasksbeans.TaskVariables;
+import org.onap.so.apihandlerinfra.tasksbeans.TasksGetResponse;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoAlarmLogger;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.utils.UUIDChecker;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Path("onap/so/infra/tasks")
+@Api(value="onap/so/infra/tasks",description="Queries of Manual Tasks")
+@Component
+public class TasksHandler {
+
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH,TasksHandler.class);
+
+ @Value("${mso.camunda.rest.task.uri}")
+ private String requestUrl;
+
+ @Autowired
+ private RequestClientFactory reqClientFactory;
+
+ @Autowired
+ private ResponseBuilder builder;
+
+ @Path("/{version:[vV]1}")
+ @GET
+ @ApiOperation(value="Finds Manual Tasks",response=Response.class)
+ @Transactional
+ public Response queryFilters (@QueryParam("taskId") String taskId,
+ @QueryParam("originalRequestId") String originalRequestId,
+ @QueryParam("subscriptionServiceType") String subscriptionServiceType,
+ @QueryParam("nfRole") String nfRole,
+ @QueryParam("buildingBlockName") String buildingBlockName,
+ @QueryParam("originalRequestDate") String originalRequestDate,
+ @QueryParam("originalRequestorId") String originalRequestorId,
+ @PathParam("version") String version) throws ApiException {
+ Response responseBack = null;
+
+ String requestId = UUIDChecker.generateUUID(msoLogger);
+ MsoLogger.setServiceName ("ManualTasksQuery");
+ // Generate a Request Id
+ UUIDChecker.generateUUID(msoLogger);
+ String apiVersion = version.substring(1);
+
+ // Prepare the query string to /task interface
+ TaskVariables tv = new TaskVariables();
+
+ List<TaskVariableValue> tvvList = new ArrayList<>();
+
+ if (originalRequestId != null) {
+ TaskVariableValue tvv = new TaskVariableValue();
+ tvv.setName("originalRequestId");
+ tvv.setValue(originalRequestId);
+ tvv.setOperator("eq");
+ tvvList.add(tvv);
+ }
+ if (subscriptionServiceType != null) {
+ TaskVariableValue tvv = new TaskVariableValue();
+ tvv.setName("subscriptionServiceType");
+ tvv.setValue(subscriptionServiceType);
+ tvv.setOperator("eq");
+ tvvList.add(tvv);
+ }
+ if (nfRole != null) {
+ TaskVariableValue tvv = new TaskVariableValue();
+ tvv.setName("nfRole");
+ tvv.setValue(nfRole);
+ tvv.setOperator("eq");
+ tvvList.add(tvv);
+ }
+ if (buildingBlockName != null) {
+ TaskVariableValue tvv = new TaskVariableValue();
+ tvv.setName("buildingBlockName");
+ tvv.setValue(buildingBlockName);
+ tvv.setOperator("eq");
+ tvvList.add(tvv);
+ }
+ if (originalRequestDate != null) {
+ TaskVariableValue tvv = new TaskVariableValue();
+ tvv.setName("originalRequestDate");
+ tvv.setValue(originalRequestDate);
+ tvv.setOperator("eq");
+ tvvList.add(tvv);
+ }
+ if (originalRequestorId != null) {
+ TaskVariableValue tvv = new TaskVariableValue();
+ tvv.setName("originalRequestorId");
+ tvv.setValue(originalRequestorId);
+ tvv.setOperator("eq");
+ tvvList.add(tvv);
+ }
+
+ tv.setTaskVariables(tvvList);
+
+ RequestClient requestClient = null;
+
+ HttpResponse response = null;
+
+ try {
+ requestClient = reqClientFactory.getRequestClient(requestUrl);
+ // Capture audit event
+ ObjectMapper mapper = new ObjectMapper();
+ String camundaJsonReq = mapper.writeValueAsString(tv);
+ response = requestClient.post(camundaJsonReq);
+
+ } catch(JsonProcessingException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(),
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ } catch(IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.AvailabilityError).build();
+ AlarmLoggerInfo alarmLoggerInfo = new AlarmLoggerInfo.Builder("MsoConfigurationError",
+ MsoAlarmLogger.CRITICAL,
+ Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)).build();
+
+
+
+ BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY),HttpStatus.SC_BAD_GATEWAY,ErrorNumbers.SVC_NO_SERVER_RESOURCES)
+ .errorInfo(errorLoggerInfo).alarmInfo(alarmLoggerInfo).build();
+
+ throw bpmnFailureException;
+ }
+ TasksGetResponse trr = new TasksGetResponse();
+ List<TaskList> taskList = new ArrayList<>();
+
+ ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
+ int bpelStatus = respHandler.getStatus ();
+ if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) {
+ String respBody = respHandler.getResponseBody();
+ if (respBody != null) {
+ JSONArray data = new JSONArray(respBody);
+
+ for (int i=0; i<data.length();i++) {
+ JSONObject taskEntry = data.getJSONObject(i);
+ String id = taskEntry.getString("id");
+ if (taskId != null && !taskId.equals(id)) {
+ continue;
+ }
+ // Get variables info for each task ID
+ TaskList taskListEntry = null;
+ taskListEntry = getTaskInfo(id);
+
+ taskList.add(taskListEntry);
+
+ }
+ trr.setTaskList(taskList);
+ }
+
+ } else {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).build();
+
+
+ BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ throw bpmnFailureException;
+ }
+
+ String jsonResponse = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ jsonResponse = mapper.writeValueAsString(trr);
+ }
+ catch (JsonProcessingException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(),
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion);
+ }
+
+ protected MsoLogger getMsoLogger () {
+ return msoLogger;
+ }
+
+ // Makes a GET call to Camunda to get variables for this task
+ private TaskList getTaskInfo(String taskId) throws ApiException{
+ TaskList taskList;
+ String getRequestUrl = UriBuilder.fromUri(requestUrl).path(taskId).path("variables").build().toString();
+ HttpResponse getResponse;
+
+ RequestClient requestClient = reqClientFactory.getRequestClient (getRequestUrl);
+ // Capture audit event
+ try {
+ getResponse = requestClient.get();
+ }catch(IOException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.AvailabilityError).build();
+ AlarmLoggerInfo alarmLoggerInfo = new AlarmLoggerInfo.Builder("MsoConfigurationError",
+ MsoAlarmLogger.CRITICAL, Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)).build();
+
+
+
+ BPMNFailureException validateException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES)
+ .errorInfo(errorLoggerInfo).alarmInfo(alarmLoggerInfo).build();
+ throw validateException;
+ }
+ ResponseHandler respHandler = new ResponseHandler (getResponse, requestClient.getType ());
+ int bpelStatus = respHandler.getStatus ();
+ if (bpelStatus == HttpStatus.SC_ACCEPTED) {
+ String respBody = respHandler.getResponseBody();
+ if (respBody != null) {
+ taskList = buildTaskList(taskId, respBody);
+ }
+ else {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.AvailabilityError).build();
+ AlarmLoggerInfo alarmLoggerInfo = new AlarmLoggerInfo.Builder("MsoConfigurationError", MsoAlarmLogger.CRITICAL, Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)).build();
+
+
+
+ BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES)
+ .errorInfo(errorLoggerInfo).alarmInfo(alarmLoggerInfo).build();
+ throw bpmnFailureException;
+ }
+
+ }
+ else {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.AvailabilityError).build();
+ AlarmLoggerInfo alarmLoggerInfo = new AlarmLoggerInfo.Builder("MsoConfigurationError", MsoAlarmLogger.CRITICAL, Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)).build();
+
+
+
+ BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_NO_SERVER_RESOURCES)
+ .errorInfo(errorLoggerInfo).alarmInfo(alarmLoggerInfo).build();
+
+ throw bpmnFailureException;
+ }
+
+ return taskList;
+
+ }
+
+ private TaskList buildTaskList(String taskId, String respBody) throws JSONException {
+ TaskList taskList = new TaskList();
+ JSONObject variables = new JSONObject(respBody);
+
+ taskList.setTaskId(taskId);
+ taskList.setType(getOptVariableValue(variables, "type"));
+ taskList.setNfRole(getOptVariableValue(variables, "nfRole"));
+ taskList.setSubscriptionServiceType(getOptVariableValue(variables, "subscriptionServiceType"));
+ taskList.setOriginalRequestId(getOptVariableValue(variables, "originalRequestId"));
+ taskList.setOriginalRequestorId(getOptVariableValue(variables, "originalRequestorId"));
+ taskList.setErrorSource(getOptVariableValue(variables, "errorSource"));
+ taskList.setErrorCode(getOptVariableValue(variables, "errorCode"));
+ taskList.setErrorMessage(getOptVariableValue(variables, "errorMessage"));
+ taskList.setBuildingBlockName(getOptVariableValue(variables, "buildingBlockName"));
+ taskList.setBuildingBlockStep(getOptVariableValue(variables, "buildingBlockStep"));
+
+ String validResponses = getOptVariableValue(variables, "validResponses").toLowerCase();
+ List<String> items = Arrays.asList(validResponses.split("\\s*,\\s*"));
+ taskList.setValidResponses(items);
+
+ return taskList;
+ }
+
+ private String getOptVariableValue(JSONObject variables, String name) throws JSONException {
+ String variableEntry = variables.optString(name);
+ String value = "";
+ if (!variableEntry.isEmpty()) {
+ JSONObject variableEntryJson = new JSONObject(variableEntry);
+ value = variableEntryJson.optString("value");
+ }
+ return value;
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TestApi.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TestApi.java
new file mode 100644
index 0000000000..d2e96562ea
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TestApi.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+public enum TestApi {
+ GR_API("GR-API-DEFAULT"),
+ VNF_API("VNF-API-DEFAULT");
+
+ private final String modelName;
+
+ private TestApi(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java
new file mode 100644
index 0000000000..aca0fa511e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra;
+
+import org.onap.so.security.MSOSpringFirewall;
+import org.onap.so.security.WebSecurityConfig;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.web.firewall.StrictHttpFirewall;
+import org.springframework.util.StringUtils;
+
+@EnableWebSecurity
+@Configuration("att-security-config")
+@Order(2)
+public class WebSecurityConfigImpl extends WebSecurityConfig {
+
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.csrf().disable()
+ .authorizeRequests()
+ .antMatchers("/manage/health","/manage/info").permitAll()
+ .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString())
+ .and()
+ .httpBasic();
+
+ }
+
+ @Override
+ public void configure(WebSecurity web) throws Exception {
+ super.configure(web);
+ StrictHttpFirewall firewall = new MSOSpringFirewall();
+ web.httpFirewall(firewall);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java
new file mode 100644
index 0000000000..f7d719048f
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.configuration;
+
+
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Profile;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@Configuration
+@EnableTransactionManagement
+@EnableJpaRepositories(
+ entityManagerFactoryRef = "entityManagerFactory",
+ basePackages = {"org.onap.so.db.catalog.data.repository"}
+ )
+@Profile({"!test"})
+public class CatalogDBConfig {
+
+ @Primary
+ @Bean(name = "dataSource")
+ @ConfigurationProperties(prefix = "spring.datasource")
+ public DataSource dataSource() {
+ return DataSourceBuilder.create().build();
+ }
+
+ @Primary
+ @Bean(name = "entityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean
+ entityManagerFactory(
+ EntityManagerFactoryBuilder builder,
+ @Qualifier("dataSource") DataSource dataSource
+ ) {
+ return builder
+ .dataSource(dataSource)
+ .packages("org.onap.so.db.catalog.beans")
+ .persistenceUnit("catalogDB")
+ .build();
+ }
+
+ @Primary
+ @Bean(name = "transactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("entityManagerFactory") EntityManagerFactory
+ entityManagerFactory
+ ) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java
new file mode 100644
index 0000000000..2298ccdb26
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.configuration;
+
+
+import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.orm.jpa.JpaTransactionManager;
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@Configuration
+@EnableTransactionManagement
+@EnableJpaRepositories(
+ entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager",
+ basePackages = { "org.onap.so.db.request.data.repository"}
+ )
+@Profile({"!test"})
+public class RequestDBConfig {
+
+ @Bean(name = "requestDataSource")
+ @ConfigurationProperties(prefix = "request.datasource")
+ public DataSource dataSource() {
+ return DataSourceBuilder.create().build();
+ }
+
+
+ @Bean(name = "requestEntityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean
+ entityManagerFactory(
+ EntityManagerFactoryBuilder builder,
+ @Qualifier("requestDataSource") DataSource dataSource
+ ) {
+ return builder
+ .dataSource(dataSource)
+ .packages("org.onap.so.db.request.beans")
+ .persistenceUnit("requestDB")
+ .build();
+ }
+
+
+ @Bean(name = "requestTransactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory
+ entityManagerFactory
+ ) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java
index 2c61d6eb6b..89482f7879 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java
index a88e8f5831..a2b410f57f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java
index 3e17828e0a..6dfa4b6587 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java
@@ -7,9 +7,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.
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.List;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java
index 5b48cbecbc..dfe94dd2f0 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java
@@ -1,113 +1,113 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
-
-import java.sql.Timestamp;
-
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT)
-public class E2ERequest {
-
- protected String operationId;
- protected String operation;
- protected String result;
- protected String reason;
- protected String userId;
- protected String operationContent;
- protected long progress;
- protected String operateAt;
- protected String finishedAt;
-
- public String getOperationId() {
- return operationId;
- }
-
- public void setOperationId(String operationId) {
- this.operationId = operationId;
- }
-
- public String getOperation() {
- return operation;
- }
-
- public void setOperation(String operation) {
- this.operation = operation;
- }
-
- public String getResult() {
- return result;
- }
-
- public void setResult(String result) {
- this.result = result;
- }
-
- public String getReason() {
- return reason;
- }
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- public String getOperationContent() {
- return operationContent;
- }
-
- public void setOperationContent(String operationContent) {
- this.operationContent = operationContent;
- }
-
- public long getProgress() {
- return progress;
- }
-
- public void setProgress(long progress) {
- this.progress = progress;
- }
-
- public String getOperateAt() {
- return operateAt;
- }
-
- public void setOperateAt(String operateAt) {
- this.operateAt = operateAt;
- }
-
- public String getFinishedAt() {
- return finishedAt;
- }
-
- public void setFinishedAt(String finishedAt) {
- this.finishedAt = finishedAt;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
+
+import java.sql.Timestamp;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT)
+public class E2ERequest {
+
+ protected String operationId;
+ protected String operation;
+ protected String result;
+ protected String reason;
+ protected String userId;
+ protected String operationContent;
+ protected long progress;
+ protected String operateAt;
+ protected String finishedAt;
+
+ public String getOperationId() {
+ return operationId;
+ }
+
+ public void setOperationId(String operationId) {
+ this.operationId = operationId;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getOperationContent() {
+ return operationContent;
+ }
+
+ public void setOperationContent(String operationContent) {
+ this.operationContent = operationContent;
+ }
+
+ public long getProgress() {
+ return progress;
+ }
+
+ public void setProgress(long progress) {
+ this.progress = progress;
+ }
+
+ public String getOperateAt() {
+ return operateAt;
+ }
+
+ public void setOperateAt(String operateAt) {
+ this.operateAt = operateAt;
+ }
+
+ public String getFinishedAt() {
+ return finishedAt;
+ }
+
+ public void setFinishedAt(String finishedAt) {
+ this.finishedAt = finishedAt;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EService.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EService.java
index 4466a284fe..9f6a9b438c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EService.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EService.java
@@ -7,9 +7,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.
@@ -18,15 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
-
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import java.util.HashMap;
import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
@JsonIgnoreProperties({ "additionalProperties" })
public class E2EService {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java
index 157ee72535..a920bdfdc8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java
@@ -1,46 +1,46 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
-
-
-public class E2EServiceInstanceDeleteRequest {
-
- private String globalSubscriberId;
-
- private String serviceType;
-
- public String getGlobalSubscriberId() {
- return globalSubscriberId;
- }
-
- public void setGlobalSubscriberId(String globalSubscriberId) {
- this.globalSubscriberId = globalSubscriberId;
- }
-
- public String getServiceType() {
- return serviceType;
- }
-
- public void setServiceType(String serviceType) {
- this.serviceType = serviceType;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
+
+
+public class E2EServiceInstanceDeleteRequest {
+
+ private String globalSubscriberId;
+
+ private String serviceType;
+
+ public String getGlobalSubscriberId() {
+ return globalSubscriberId;
+ }
+
+ public void setGlobalSubscriberId(String globalSubscriberId) {
+ this.globalSubscriberId = globalSubscriberId;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public void setServiceType(String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java
index 01ea4a9c7d..e3edf3b742 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java
@@ -7,9 +7,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.
@@ -18,14 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import java.util.HashMap;
import java.util.Map;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
@JsonIgnoreProperties({ "additionalProperties" })
public class E2EServiceInstanceRequest {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceScaleRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceScaleRequest.java
index b8bd810f4f..f7cdd7ab04 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceScaleRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceScaleRequest.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
public class E2EServiceInstanceScaleRequest {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java
index cc0582080f..531824e379 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java
@@ -7,9 +7,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.
@@ -18,13 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import java.util.HashMap;
import java.util.Map;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
public class E2EUserParam {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java
index 18cdd993c6..45aa5e24db 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java
@@ -1,48 +1,49 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
-
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import org.openecomp.mso.requestsdb.OperationStatus;
-
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
-public class GetE2EServiceInstanceResponse {
-
- protected OperationStatus operation;
-
- public OperationStatus getOperationStatus() {
- return operation;
- }
-
- public void setOperationStatus(OperationStatus requestDB) {
- this.operation = requestDB;
- }
-
- public OperationStatus getOperation() {
- return operation;
- }
-
- public void setOperation(OperationStatus operation) {
- this.operation = operation;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
+
+import org.onap.so.db.request.beans.OperationStatus;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class GetE2EServiceInstanceResponse {
+
+ protected OperationStatus operation;
+
+ public OperationStatus getOperationStatus() {
+ return operation;
+ }
+
+ public void setOperationStatus(OperationStatus requestDB) {
+ this.operation = requestDB;
+ }
+
+ public OperationStatus getOperation() {
+ return operation;
+ }
+
+ public void setOperation(OperationStatus operation) {
+ this.operation = operation;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java
index 46ab896cb5..b1256a236b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java
@@ -17,9 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* <br>
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java
index 4343847b59..e7baf98411 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java
@@ -17,7 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import java.util.HashMap;
import java.util.List;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java
index a77c88ed3c..6518523256 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java
@@ -7,9 +7,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.
@@ -18,10 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsByStepsData.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleNsByStepsData.java
index c64f5fa207..0744028dbf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsByStepsData.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleNsByStepsData.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
public class ScaleNsByStepsData {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsData.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleNsData.java
index 49cfe75a5b..ebb8ab8dcb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleNsData.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleNsData.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
public class ScaleNsData {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleResource.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleResource.java
index f19e2bdb80..3a906bcb4b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleResource.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleResource.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
public class ScaleResource {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleService.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleService.java
index c694f550f8..3b6ec58d8c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/ScaleService.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ScaleService.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
import java.util.List;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java
index 55d6c8997a..72d370425f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java
@@ -1,45 +1,45 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
-
-import org.codehaus.jackson.annotate.JsonProperty;
-
-public class VimLocation {
-
- @JsonProperty("vimId")
- private String vimId;
-
-
- /**
- * @return Returns the vimId.
- */
- public String getVimId() {
- return vimId;
- }
-
-
- /**
- * @param vimId The vimId to set.
- */
- public void setVimId(String vimId) {
- this.vimId = vimId;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.apihandlerinfra.e2eserviceinstancebeans;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class VimLocation {
+
+ @JsonProperty("vimId")
+ private String vimId;
+
+
+ /**
+ * @return Returns the vimId.
+ */
+ public String getVimId() {
+ return vimId;
+ }
+
+
+ /**
+ * @param vimId The vimId to set.
+ */
+ public void setVimId(String vimId) {
+ this.vimId = vimId;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/package-info.java
index 2fd36547d2..2312678460 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/package-info.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/package-info.java
@@ -25,6 +25,6 @@
// Generated on: 2015.01.08 at 03:50:12 PM EST
//
-@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/mso/request/types/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
-package org.openecomp.mso.apihandlerinfra;
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap/so/request/types/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package org.onap.so.apihandlerinfra;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetails.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetails.java
index 795b8f4b7a..957450fab0 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetails.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetails.java
@@ -1,55 +1,55 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-@JsonRootName(value = "requestDetails")
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
-public class RequestDetails {
-
- protected RequestInfo requestInfo;
- /**
- * Gets the value of the requestInfo property.
- *
- * @return
- * possible object is
- * {@link RequestInfo }
- *
- */
- public RequestInfo getRequestInfo() {
- return requestInfo;
- }
-
- /**
- * Sets the value of the requestInfo property.
- *
- * @param value
- * allowed object is
- * {@link RequestInfo }
- *
- */
- public void setRequestInfo(RequestInfo value) {
- this.requestInfo = value;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tasksbeans;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+@JsonRootName(value = "requestDetails")
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class RequestDetails {
+
+ protected RequestInfo requestInfo;
+ /**
+ * Gets the value of the requestInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link RequestInfo }
+ *
+ */
+ public RequestInfo getRequestInfo() {
+ return requestInfo;
+ }
+
+ /**
+ * Sets the value of the requestInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link RequestInfo }
+ *
+ */
+ public void setRequestInfo(RequestInfo value) {
+ this.requestInfo = value;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java
index 1406c11590..aae8786bb0 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfo.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java
@@ -1,73 +1,73 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
-public class RequestInfo {
-
- protected String source;
- protected ValidResponses responseValue;
- protected String requestorId;
-
- /**
- * Gets the value of the source property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getSource() {
- return source;
- }
-
- /**
- * Sets the value of the source property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setSource(String value) {
- this.source = value;
- }
-
- public ValidResponses getResponseValue() {
- return responseValue;
- }
-
- public void setResponseValue(ValidResponses responseValue) {
- this.responseValue = responseValue;
- }
-
-
- public String getRequestorId() {
- return requestorId;
- }
-
- public void setRequestorId(String requestorId) {
- this.requestorId = requestorId;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tasksbeans;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class RequestInfo {
+
+ protected String source;
+ protected ValidResponses responseValue;
+ protected String requestorId;
+
+ /**
+ * Gets the value of the source property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSource() {
+ return source;
+ }
+
+ /**
+ * Sets the value of the source property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSource(String value) {
+ this.source = value;
+ }
+
+ public ValidResponses getResponseValue() {
+ return responseValue;
+ }
+
+ public void setResponseValue(ValidResponses responseValue) {
+ this.responseValue = responseValue;
+ }
+
+
+ public String getRequestorId() {
+ return requestorId;
+ }
+
+ public void setRequestorId(String requestorId) {
+ this.requestorId = requestorId;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskList.java
index d18070fbb7..b88521f813 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskList.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskList.java
@@ -7,9 +7,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.
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
+package org.onap.so.apihandlerinfra.tasksbeans;
-import org.json.JSONArray;
+import java.util.List;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -37,7 +37,7 @@ public class TaskList {
protected String errorMessage;
protected String buildingBlockName;
protected String buildingBlockStep;
- protected JSONArray validResponses;
+ protected List<String> validResponses;
/**
* Gets the value of the taskId property.
@@ -311,7 +311,7 @@ public class TaskList {
* {@link ValidResponses }
*
*/
- public JSONArray getValidResponses() {
+ public List<String> getValidResponses() {
return validResponses;
}
@@ -323,7 +323,7 @@ public class TaskList {
* {@link ValidResponses }
*
*/
- public void setValidResponses(JSONArray value) {
+ public void setValidResponses(List<String> value) {
this.validResponses = value;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReference.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReference.java
index b081f3924f..860fe6bddb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReference.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReference.java
@@ -1,56 +1,56 @@
-/* ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-@JsonRootName(value = "taskRequestReference")
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
-public class TaskRequestReference {
-
- protected String taskId;
-
- /**
- * Gets the value of the taskId property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getTaskId() {
- return taskId;
- }
-
- /**
- * Sets the value of the taskId property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setTaskId(String value) {
- this.taskId = value;
- }
-
-
-
-}
+/* ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tasksbeans;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+@JsonRootName(value = "taskRequestReference")
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class TaskRequestReference {
+
+ protected String taskId;
+
+ /**
+ * Gets the value of the taskId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTaskId() {
+ return taskId;
+ }
+
+ /**
+ * Sets the value of the taskId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTaskId(String value) {
+ this.taskId = value;
+ }
+
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValue.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java
index 2a0641a424..441d4f315a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValue.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java
@@ -1,107 +1,107 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
-public class TaskVariableValue {
-
- protected String name;
- protected String value;
- protected String operator;
-
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setName(String value) {
- this.name = value;
- }
-
-
- /**
- * Gets the value of the value property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- /**
- * Gets the value of the operator property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getOperator() {
- return operator;
- }
-
- /**
- * Sets the value of the operator property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setOperator(String value) {
- this.operator = value;
- }
-
-
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tasksbeans;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class TaskVariableValue {
+
+ protected String name;
+ protected String value;
+ protected String operator;
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the operator property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getOperator() {
+ return operator;
+ }
+
+ /**
+ * Sets the value of the operator property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setOperator(String value) {
+ this.operator = value;
+ }
+
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariables.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariables.java
index 943635ff0c..7d5b465891 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariables.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariables.java
@@ -7,9 +7,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.
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+package org.onap.so.apihandlerinfra.tasksbeans;
import java.util.List;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
public class TaskVariables {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponse.java
index c21792acc1..5ee01aeaf6 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponse.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponse.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
+package org.onap.so.apihandlerinfra.tasksbeans;
import java.util.List;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequest.java
index 9f65aa07a5..0544f536a2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequest.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
+package org.onap.so.apihandlerinfra.tasksbeans;
public class TasksRequest {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValidResponses.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/ValidResponses.java
index 9310cd4730..977e7c4f2e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValidResponses.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/ValidResponses.java
@@ -1,51 +1,52 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.09.03 at 02:02:13 PM EDT
-//
-
-
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
-
-public enum ValidResponses {
-
- rollback,
- abort,
- skip,
- retry
- ;
-
- public String value() {
- return name();
- }
-
- public static ValidResponses fromValue(String v) {
- return valueOf(v);
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.09.03 at 02:02:13 PM EDT
+//
+
+
+package org.onap.so.apihandlerinfra.tasksbeans;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+
+public enum ValidResponses {
+
+ rollback,
+ abort,
+ skip,
+ retry,
+ manual
+ ;
+
+ public String value() {
+ return name();
+ }
+
+ public static ValidResponses fromValue(String v) {
+ return valueOf(v);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Value.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Value.java
index f2fed8589b..98ed5b653f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Value.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Value.java
@@ -1,55 +1,55 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
-public class Value {
-
- protected String value;
-
- /**
- * Gets the value of the value property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setValue(String value) {
- this.value = value;
- }
-
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tasksbeans;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class Value {
+
+ protected String value;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Variables.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Variables.java
index 9d3852cc07..1ed011db91 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Variables.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Variables.java
@@ -1,74 +1,74 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tasksbeans;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-@JsonRootName(value = "variables")
-@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
-public class Variables {
-
- protected Value source;
- protected Value responseValue;
- protected Value requestorId;
-
- /**
- * Gets the value of the source property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public Value getSource() {
- return source;
- }
-
- /**
- * Sets the value of the source property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setSource(Value value) {
- this.source = value;
- }
-
- public Value getResponseValue() {
- return responseValue;
- }
-
- public void setResponseValue(Value responseValue) {
- this.responseValue = responseValue;
- }
-
-
- public Value getRequestorId() {
- return requestorId;
- }
-
- public void setRequestorId(Value requestorId) {
- this.requestorId = requestorId;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tasksbeans;
+
+import com.fasterxml.jackson.annotation.JsonRootName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+@JsonRootName(value = "variables")
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class Variables {
+
+ protected Value source;
+ protected Value responseValue;
+ protected Value requestorId;
+
+ /**
+ * Gets the value of the source property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public Value getSource() {
+ return source;
+ }
+
+ /**
+ * Sets the value of the source property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSource(Value value) {
+ this.source = value;
+ }
+
+ public Value getResponseValue() {
+ return responseValue;
+ }
+
+ public void setResponseValue(Value responseValue) {
+ this.responseValue = responseValue;
+ }
+
+
+ public Value getRequestorId() {
+ return requestorId;
+ }
+
+ public void setRequestorId(Value requestorId) {
+ this.requestorId = requestorId;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java
index 92e74e8de2..5675588f62 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java
@@ -18,26 +18,32 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
+package org.onap.so.apihandlerinfra.tenantisolation;
import java.net.MalformedURLException;
import java.net.URL;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.client.aai.AAIProperties;
-import org.openecomp.mso.client.aai.AAIVersion;
-import org.openecomp.mso.properties.MsoJavaProperties;
+import org.onap.so.apihandlerinfra.SpringContextHelper;
+import org.onap.so.client.aai.AAIProperties;
+import org.onap.so.client.aai.AAIVersion;
+import org.springframework.context.ApplicationContext;
public class AaiClientPropertiesImpl implements AAIProperties {
- final MsoJavaProperties props;
+ private String aaiEndpoint;
+ private String auth;
+ private String key;
public AaiClientPropertiesImpl() {
- this.props = MsoPropertiesUtils.loadMsoProperties ();
+
+ ApplicationContext context = SpringContextHelper.getAppContext();
+ aaiEndpoint = context.getEnvironment().getProperty("mso.aai.endpoint");
+ this.auth = context.getEnvironment().getProperty("aai.auth");
+ this.key = context.getEnvironment().getProperty("mso.msoKey");
}
@Override
public URL getEndpoint() throws MalformedURLException {
- return new URL(props.getProperty("aai.endpoint", null));
+ return new URL(aaiEndpoint);
}
@Override
@@ -52,11 +58,11 @@ public class AaiClientPropertiesImpl implements AAIProperties {
@Override
public String getAuth() {
- return props.getProperty("aai.auth", null);
+ return this.auth;
}
@Override
public String getKey() {
- return props.getProperty("mso.msoKey", null);
+ return this.key;
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java
new file mode 100644
index 0000000000..dd1f19ff62
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java
@@ -0,0 +1,238 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation;
+
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+
+import javax.inject.Provider;
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Action;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestReferences;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.TenantSyncResponse;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.utils.UUIDChecker;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Component
+@Path("/onap/so/infra/cloudResources")
+@Api(value="/onap/so/infra/cloudResources",description="API Requests for cloud resources - Tenant Isolation")
+public class CloudOrchestration {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, CloudOrchestration.class);
+ private static final String ENVIRONMENT_ID_KEY = "operationalEnvironmentId";
+
+ @Autowired
+ private TenantIsolationRequest tenantIsolationRequest ;
+ @Autowired
+ private InfraActiveRequestsRepository iarRepo;
+ @Autowired
+ private Provider<TenantIsolationRunnable> tenantIsolationRunnable;
+
+ @POST
+ @Path("/{version:[vV][1]}/operationalEnvironments")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create an Operational Environment",response=Response.class)
+ @Transactional
+ public Response createOperationEnvironment(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException{
+ msoLogger.debug("Received request to Create Operational Environment");
+ return cloudOrchestration(request, Action.create, null, version, getRequestId(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/activate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Activate an Operational Environment",response=Response.class)
+ @Transactional
+ public Response activateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId,
+ @Context ContainerRequestContext requestContext) throws ApiException{
+ msoLogger.debug("Received request to Activate an Operational Environment");
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put(ENVIRONMENT_ID_KEY, operationalEnvironmentId);
+ return cloudOrchestration(request, Action.activate, instanceIdMap, version, getRequestId(requestContext));
+ }
+
+ @POST
+ @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/deactivate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Deactivate an Operational Environment",response=Response.class)
+ @Transactional
+ public Response deactivateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId, @Context ContainerRequestContext requestContext) throws ApiException{
+ msoLogger.debug("Received request to Deactivate an Operational Environment");
+ HashMap<String, String> instanceIdMap = new HashMap<>();
+ instanceIdMap.put(ENVIRONMENT_ID_KEY, operationalEnvironmentId);
+ return cloudOrchestration(request, Action.deactivate, instanceIdMap, version, getRequestId(requestContext));
+ }
+
+
+ private Response cloudOrchestration(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId) throws ApiException{
+ MsoLogger.setLogContext(requestId, null);
+ msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, "", "");
+ long startTime = System.currentTimeMillis ();
+ CloudOrchestrationRequest cor = null;
+ tenantIsolationRequest.setRequestId(requestId);
+
+ cor = convertJsonToCloudOrchestrationRequest(requestJSON, action, startTime, cor);
+
+ try {
+ tenantIsolationRequest.parse(cor, instanceIdMap, action);
+ }catch(ValidationException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,MsoLogger.ErrorCode.SchemaError).build();
+
+
+ throw new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER)
+ .cause(e).errorInfo(errorLoggerInfo).build();
+ }
+
+ String instanceName = cor.getRequestDetails().getRequestInfo().getInstanceName();
+ String resourceType = cor.getRequestDetails().getRequestInfo().getResourceType().name();
+ InfraActiveRequests dup = null;
+
+ dup = duplicateCheck(action, instanceIdMap, startTime, instanceName, resourceType);
+
+ if(dup == null && (Action.activate.equals(action) || Action.deactivate.equals(action))) {
+ dup = iarRepo.checkVnfIdStatus(cor.getOperationalEnvironmentId());
+ }
+
+ if(dup != null) {
+ String instance = null;
+ if(instanceName != null){
+ instance = instanceName;
+ }else if (instanceIdMap != null){
+ instance = instanceIdMap.get(resourceType + "InstanceId");
+ }
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, MsoLogger.ErrorCode.SchemaError).build();
+
+
+ throw new DuplicateRequestException.Builder(resourceType,instance,dup.getRequestStatus(),dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+ }
+
+ String instanceId = null;
+
+ if(instanceIdMap != null && instanceIdMap.get(ENVIRONMENT_ID_KEY) != null) {
+ instanceId = instanceIdMap.get(ENVIRONMENT_ID_KEY);
+ } else {
+ instanceId = UUIDChecker.generateUUID(msoLogger);
+ tenantIsolationRequest.setOperationalEnvironmentId(instanceId);
+ cor.setOperationalEnvironmentId(instanceId);
+ }
+
+ tenantIsolationRequest.createRequestRecord(Status.IN_PROGRESS, action);
+
+ OperationalEnvironment opEnv = cor.getRequestDetails().getRequestParameters().getOperationalEnvironmentType();
+ String operationalEnvType = opEnv != null ? opEnv.name() : null;
+
+ TenantIsolationRunnable runnable = tenantIsolationRunnable.get();
+ runnable.run(action, operationalEnvType, cor, requestId);
+
+ String encodedValue;
+ try {
+ encodedValue = new String(instanceId.getBytes("UTF-8"));
+ } catch(UnsupportedEncodingException ex) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,MsoLogger.ErrorCode.DataError).build();
+
+
+ throw new ValidateException.Builder("Could not encode instanceID" + ex.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER)
+ .cause(ex).errorInfo(errorLoggerInfo).build();
+ }
+
+ TenantSyncResponse tenantResponse = new TenantSyncResponse();
+ RequestReferences reqReference = new RequestReferences();
+ reqReference.setInstanceId(encodedValue);
+ reqReference.setRequestId(requestId);
+ tenantResponse.setRequestReferences(reqReference);
+
+ return Response.ok(tenantResponse).build();
+ }
+
+ private InfraActiveRequests duplicateCheck(Action action, HashMap<String, String> instanceIdMap, long startTime,
+ String instanceName, String requestScope) throws ApiException {
+ try {
+ return iarRepo.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
+ } catch (Exception e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+
+
+ throw new ValidateException.Builder("Duplicate Check Request", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ }
+ }
+
+ private CloudOrchestrationRequest convertJsonToCloudOrchestrationRequest(String requestJSON, Action action, long startTime,
+ CloudOrchestrationRequest cor) throws ApiException {
+ try{
+ msoLogger.debug("Converting incoming JSON request to Object");
+ ObjectMapper mapper = new ObjectMapper();
+ return mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
+ } catch(IOException e){
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,MsoLogger.ErrorCode.SchemaError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER)
+ .cause(e).errorInfo(errorLoggerInfo).build();
+ if (tenantIsolationRequest.getRequestId () != null) {
+ tenantIsolationRequest.createRequestRecord (Status.FAILED, action);
+ }
+ throw validateException;
+ }
+ }
+
+ private String getRequestId(ContainerRequestContext requestContext) {
+ return requestContext.getProperty("requestId").toString();
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java
index 5e6c1ecd60..d387928e22 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java
@@ -1,81 +1,81 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
-
-import java.io.Serializable;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Distribution;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestDetails;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class CloudOrchestrationRequest implements Serializable {
-
- private static final long serialVersionUID = -4959169541182257787L;
- @JsonProperty("requestDetails")
- private RequestDetails requestDetails;
- @JsonProperty("operationalEnvironmentId")
- private String operationalEnvironmentId;
- @JsonProperty("distribution")
- private Distribution distribution;
- @JsonProperty("distributionId")
- private String distributionId;
-
- public String getOperationalEnvironmentId() {
- return operationalEnvironmentId;
- }
-
- public void setOperationalEnvironmentId(String operationalEnvironmentId) {
- this.operationalEnvironmentId = operationalEnvironmentId;
- }
-
- public RequestDetails getRequestDetails() {
- return requestDetails;
- }
-
- public void setRequestDetails(RequestDetails requestDetails){
- this.requestDetails = requestDetails;
- }
-
- public Distribution getDistribution() {
- return distribution;
- }
-
- public void setDistribution(Distribution distribution) {
- this.distribution = distribution;
- }
-
- public String getDistributionId() {
- return distributionId;
- }
-
- public void setDistributionId(String distributionId) {
- this.distributionId = distributionId;
- }
-
- @Override
- public String toString() {
- return "ServiceInstancesRequest [requestDetails=" + requestDetails
- + ", operationalEnvironmentId=" + operationalEnvironmentId
- + ", distribution=" + distribution
- + ", distributionId=" + distributionId + "]";
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation;
+
+import java.io.Serializable;
+
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class CloudOrchestrationRequest implements Serializable {
+
+ private static final long serialVersionUID = -4959169541182257787L;
+ @JsonProperty("requestDetails")
+ private RequestDetails requestDetails;
+ @JsonProperty("operationalEnvironmentId")
+ private String operationalEnvironmentId;
+ @JsonProperty("distribution")
+ private Distribution distribution;
+ @JsonProperty("distributionId")
+ private String distributionId;
+
+ public String getOperationalEnvironmentId() {
+ return operationalEnvironmentId;
+ }
+
+ public void setOperationalEnvironmentId(String operationalEnvironmentId) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ }
+
+ public RequestDetails getRequestDetails() {
+ return requestDetails;
+ }
+
+ public void setRequestDetails(RequestDetails requestDetails){
+ this.requestDetails = requestDetails;
+ }
+
+ public Distribution getDistribution() {
+ return distribution;
+ }
+
+ public void setDistribution(Distribution distribution) {
+ this.distribution = distribution;
+ }
+
+ public String getDistributionId() {
+ return distributionId;
+ }
+
+ public void setDistributionId(String distributionId) {
+ this.distributionId = distributionId;
+ }
+
+ @Override
+ public String toString() {
+ return "ServiceInstancesRequest [requestDetails=" + requestDetails
+ + ", operationalEnvironmentId=" + operationalEnvironmentId
+ + ", distribution=" + distribution
+ + ", distributionId=" + distributionId + "]";
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
new file mode 100644
index 0000000000..a3835f1551
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
@@ -0,0 +1,297 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.transaction.Transactional;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.CommonConstants;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandler.common.ResponseBuilder;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.Messages;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationRequestList;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.InstanceReferences;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Request;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestStatus;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoAlarmLogger;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.utils.UUIDChecker;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Component
+@Path("onap/so/infra/cloudResourcesRequests")
+@Api(value="onap/so/infra/cloudResourcesRequests",description="API GET Requests for cloud resources - Tenant Isolation")
+public class CloudResourcesOrchestration {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, CloudResourcesOrchestration.class);
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+ @Autowired
+ private InfraActiveRequestsRepository iarRepo;
+ @Autowired
+ private InfraActiveRequestsRepository infraActiveRequestsRepository;
+ @Autowired
+ private ResponseBuilder builder;
+
+ @POST
+ @Path("/{version: [vV][1]}/{requestId}/unlock")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Unlock CloudOrchestration requests for a specified requestId")
+ @Transactional
+ public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) throws ApiException{
+ TenantIsolationRequest msoRequest = new TenantIsolationRequest(requestId);
+ InfraActiveRequests infraActiveRequest = null;
+
+ CloudOrchestrationRequest cor = null;
+
+ msoLogger.debug ("requestId is: " + requestId);
+
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
+ } catch(IOException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,MsoLogger.ErrorCode.SchemaError).build();
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER)
+ .cause(e).errorInfo(errorLoggerInfo).build();
+ throw validateException;
+ }
+
+ try{
+ msoRequest.parseOrchestration(cor);
+ } catch (ValidationException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,MsoLogger.ErrorCode.SchemaError).build();
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER)
+ .cause(e).errorInfo(errorLoggerInfo).build();
+ throw validateException;
+ }
+ try {
+ infraActiveRequest = infraActiveRequestsRepository.findOneByRequestIdOrClientRequestId(requestId, requestId);
+ }catch(Exception e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.AvailabilityError).build();
+ AlarmLoggerInfo alarmLoggerInfo = new AlarmLoggerInfo.Builder("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
+ Messages.getErrors().get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)).build();
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).alarmInfo(alarmLoggerInfo).build();
+
+ throw validateException;
+ }
+ if(infraActiveRequest == null) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND,MsoLogger.ErrorCode.BusinessProcesssError).build();
+ ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB", HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+
+ }else{
+ String status = infraActiveRequest.getRequestStatus();
+ if(status.equalsIgnoreCase("IN_PROGRESS") || status.equalsIgnoreCase("PENDING") || status.equalsIgnoreCase("PENDING_MANUAL_TASK")){
+ infraActiveRequest.setRequestStatus("UNLOCKED");
+ infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ infraActiveRequestsRepository.save(infraActiveRequest);
+ }else{
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND,MsoLogger.ErrorCode.DataError).build();
+ ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked",
+ HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ }
+
+ return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build ();
+ }
+
+ @GET
+ @Path("/{version:[vV][1]}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Get status of an Operational Environment based on filter criteria",response=Response.class)
+ @Transactional
+ public Response getOperationEnvironmentStatusFilter(@Context UriInfo ui, @PathParam("version") String version ) throws ApiException{
+ MsoLogger.setServiceName ("getOperationEnvironmentStatusFilter");
+ UUIDChecker.generateUUID(msoLogger);
+
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ List<String> requestIdKey = queryParams.get("requestId");
+ String apiVersion = version.substring(1);
+
+ if(queryParams.size() == 1 && requestIdKey != null) {
+ String requestId = requestIdKey.get(0);
+
+ CloudOrchestrationResponse cloudOrchestrationGetResponse = new CloudOrchestrationResponse();
+ TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest (requestId);
+ InfraActiveRequests requestDB = null;
+
+ try {
+ requestDB = infraActiveRequestsRepository.findOneByRequestIdOrClientRequestId(requestId, requestId);
+ } catch (Exception e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.AvailabilityError).build();
+ AlarmLoggerInfo alarmLoggerInfo = new AlarmLoggerInfo.Builder("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
+ Messages.getErrors().get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)).build();
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
+ .errorInfo(errorLoggerInfo).alarmInfo(alarmLoggerInfo).build();
+
+ throw validateException;
+ // TODO Will need to set Status for tenantIsolationRequest
+ // tenantIsolationRequest.setStatus (org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ }
+
+ if(requestDB == null) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).build();
+ ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB",
+ HttpStatus.SC_NO_CONTENT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+
+ Request request = mapInfraActiveRequestToRequest(requestDB);
+ cloudOrchestrationGetResponse.setRequest(request);
+ return builder.buildResponse(HttpStatus.SC_OK, requestId, cloudOrchestrationGetResponse, apiVersion);
+
+ } else {
+ TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest ();
+ List<InfraActiveRequests> activeRequests = null;
+ CloudOrchestrationRequestList orchestrationList = null;
+
+
+ Map<String, String> orchestrationMap;
+ try{
+ orchestrationMap = tenantIsolationRequest.getOrchestrationFilters(queryParams);
+ }catch(ValidationException ex){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
+ ValidateException validateException = new ValidateException.Builder(ex.getMessage(),
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex)
+ .errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+
+ }
+ activeRequests = iarRepo.getCloudOrchestrationFiltersFromInfraActive(orchestrationMap);
+ orchestrationList = new CloudOrchestrationRequestList();
+ List<CloudOrchestrationResponse> requestLists = new ArrayList<CloudOrchestrationResponse>();
+
+ for(InfraActiveRequests infraActive : activeRequests){
+
+ Request request = mapInfraActiveRequestToRequest(infraActive);
+ CloudOrchestrationResponse requestList = new CloudOrchestrationResponse();
+ requestList.setRequest(request);
+ requestLists.add(requestList);
+ }
+ orchestrationList.setRequestList(requestLists);
+
+ return builder.buildResponse(HttpStatus.SC_OK, null, orchestrationList, apiVersion);
+ }
+ }
+
+ private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar) throws ApiException {
+ Request request = new Request();
+ request.setRequestId(iar.getRequestId());
+ request.setRequestScope(iar.getRequestScope());
+ request.setRequestType(iar.getRequestAction());
+
+ InstanceReferences ir = new InstanceReferences();
+
+ if(iar.getOperationalEnvId() != null)
+ ir.setOperationalEnvironmentId(iar.getOperationalEnvId());
+ if(iar.getOperationalEnvName() != null)
+ ir.setOperationalEnvName(iar.getOperationalEnvName());
+ if(iar.getRequestorId() != null)
+ ir.setRequestorId(iar.getRequestorId());
+
+ request.setInstanceReferences(ir);
+ String requestBody = iar.getRequestBody();
+ RequestDetails requestDetails = null;
+
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ requestDetails = mapper.readValue(requestBody, RequestDetails.class);
+ }catch(IOException e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,MsoLogger.ErrorCode.SchemaError).build();
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER)
+ .cause(e).errorInfo(errorLoggerInfo).build();
+ throw validateException;
+ }
+
+ request.setRequestDetails(requestDetails);
+ String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getStartTime()) + " GMT";
+ request.setStartTime(startTimeStamp);
+
+ RequestStatus status = new RequestStatus();
+ if(iar.getStatusMessage() != null){
+ status.setStatusMessage(iar.getStatusMessage());
+ }
+
+ if(iar.getEndTime() != null){
+ String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT";
+ status.setTimeStamp(endTimeStamp);
+ }
+
+ if(iar.getRequestStatus() != null){
+ status.setRequestState(iar.getRequestStatus());
+ }
+
+ if(iar.getProgress() != null){
+ status.setPercentProgress(iar.getProgress().toString());
+ }
+
+ request.setRequestStatus(status);
+
+ return request;
+ }
+
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java
index fc6d1a551f..58a7cb2bff 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java
@@ -7,9 +7,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.
@@ -18,28 +18,34 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
+package org.onap.so.apihandlerinfra.tenantisolation;
import java.net.MalformedURLException;
import java.net.URL;
import javax.ws.rs.core.MediaType;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.client.grm.GRMProperties;
-import org.openecomp.mso.properties.MsoJavaProperties;
+import org.onap.so.apihandlerinfra.SpringContextHelper;
+import org.onap.so.client.grm.GRMProperties;
+import org.springframework.context.ApplicationContext;
public class GrmClientPropertiesImpl implements GRMProperties {
- final MsoJavaProperties props;
+ private String grmEndpoint;
+ private String grmUsername;
+ private String grmPassword;
public GrmClientPropertiesImpl() {
- this.props = MsoPropertiesUtils.loadMsoProperties ();
+ ApplicationContext context = SpringContextHelper.getAppContext();
+
+ grmEndpoint = context.getEnvironment().getProperty("mso.grm.endpoint");
+ grmUsername = context.getEnvironment().getProperty("mso.grm.username");
+ grmPassword = context.getEnvironment().getProperty("mso.grm.password");
}
-
+
@Override
public URL getEndpoint() throws MalformedURLException {
- return new URL(props.getProperty("grm.endpoint", null));
+ return new URL(grmEndpoint);
}
@Override
@@ -54,12 +60,12 @@ public class GrmClientPropertiesImpl implements GRMProperties {
@Override
public String getUsername() {
- return props.getProperty("grm.username", null);
+ return grmUsername;
}
@Override
public String getPassword() {
- return props.getProperty("grm.password", null);
+ return grmPassword;
}
@Override
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java
index eb5306a155..e75d56e7d3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/ModelDistributionRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java
@@ -7,9 +7,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.
@@ -18,94 +18,95 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
+package org.onap.so.apihandlerinfra.tenantisolation;
+import java.io.IOException;
import java.util.List;
+import javax.inject.Provider;
+import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.xml.bind.ValidationException;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.MsoException;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Distribution;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Status;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.serviceinstancebeans.RequestError;
-import org.openecomp.mso.serviceinstancebeans.ServiceException;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.MsoException;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Action;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Status;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.springframework.beans.factory.annotation.Autowired;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-import com.wordnik.swagger.jaxrs.PATCH;
-@Path("/modelDistributions")
-@Api(value="/modelDistributions",description="API Requests for Model Distributions")
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+
+@Path("/onap/so/infra/modelDistributions")
+@Api(value="/onap/so/infra/modelDistributions",description="API Requests for Model Distributions")
public class ModelDistributionRequest {
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private TenantIsolationRunnable tenantIsolation = null;
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, ModelDistributionRequest.class);
+ @Autowired
+ private Provider<TenantIsolationRunnable> tenantIsolationRunnable;
- @PATCH
+ @POST
@Path("/{version:[vV][1]}/distributions/{distributionId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value="Update model distribution status",response=Response.class)
- public Response updateModelDistributionStatus(String requestJSON, @PathParam("version") String version, @PathParam("distributionId") String distributionId) {
+ @Transactional
+ public Response updateModelDistributionStatus(String requestJSON, @PathParam("version") String version, @PathParam("distributionId") String distributionId) throws ApiException{
long startTime = System.currentTimeMillis ();
Distribution distributionRequest = null;
-
+
try {
ObjectMapper mapper = new ObjectMapper();
distributionRequest = mapper.readValue(requestJSON, Distribution.class);
- } catch(Exception e) {
- msoLogger.debug ("Mapping of request to JSON object failed : ", e);
- Response response = buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
+ } catch(IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,MsoLogger.ErrorCode.SchemaError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER)
+ .cause(e).errorInfo(errorLoggerInfo).build();
+ throw validateException;
+
}
try {
parse(distributionRequest);
- } catch(Exception e) {
- msoLogger.debug ("Validation failed: ", e);
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
- Response response = buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
+ } catch(ValidationException e) {
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,MsoLogger.ErrorCode.SchemaError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER)
+ .cause(e).errorInfo(errorLoggerInfo).build();
+ throw validateException;
}
CloudOrchestrationRequest cor = new CloudOrchestrationRequest();
cor.setDistribution(distributionRequest);
cor.setDistributionId(distributionId);
- TenantIsolationRunnable runnable = getThread();
- runnable.setAction(Action.distributionStatus);
- runnable.setCor(cor);
- runnable.setOperationalEnvType(null);
- runnable.setRequestId(null);
-
- Thread thread = new Thread(runnable);
- thread.start();
+ TenantIsolationRunnable runnable = tenantIsolationRunnable.get();
+ runnable.run(Action.distributionStatus, null, cor, null);
return Response.ok().build();
}
@@ -121,7 +122,7 @@ public class ModelDistributionRequest {
}
private Response buildServiceErrorResponse (int httpResponseCode, MsoException exceptionType, String text,
- String messageId, List<String> variables) {
+ String messageId, List<String> variables) throws ApiException{
RequestError re = new RequestError();
ServiceException se = new ServiceException();
se.setMessageId(messageId);
@@ -140,21 +141,16 @@ public class ModelDistributionRequest {
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_DEFAULT);
requestErrorStr = mapper.writeValueAsString(re);
- }catch(Exception e){
- msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in buildServiceErrorResponse writing exceptionType to string ", e);
+ }catch(JsonProcessingException e){
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR,MsoLogger.ErrorCode.DataError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER)
+ .cause(e).errorInfo(errorLoggerInfo).build();
+ throw validateException;
}
return Response.status (httpResponseCode).entity(requestErrorStr).build ();
}
-
- public TenantIsolationRunnable getThread() {
- if(tenantIsolation == null) {
- tenantIsolation = new TenantIsolationRunnable();
- }
- return tenantIsolation;
- }
-
- public void setThread(TenantIsolationRunnable thread) {
- this.tenantIsolation = thread;
- }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java
index ce9d7b3a30..a6452a44ac 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
+package org.onap.so.apihandlerinfra.tenantisolation;
import java.sql.Timestamp;
import java.util.HashMap;
@@ -30,36 +30,39 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
-import org.hibernate.Session;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.MsoException;
-import org.openecomp.mso.apihandlerinfra.Status;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Manifest;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RelatedInstance;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RelatedInstanceList;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestDetails;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestInfo;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestParameters;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.ResourceType;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.ServiceModelList;
-import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
-import org.openecomp.mso.serviceinstancebeans.PolicyException;
-import org.openecomp.mso.serviceinstancebeans.RequestError;
-import org.openecomp.mso.serviceinstancebeans.ServiceException;
-import org.openecomp.mso.utils.UUIDChecker;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.apihandlerinfra.MsoException;
+import org.onap.so.apihandlerinfra.Status;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Action;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RelatedInstance;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RelatedInstanceList;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.ResourceType;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList;
+import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType;
+import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.serviceinstancebeans.PolicyException;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.ServiceException;
+import org.onap.so.utils.UUIDChecker;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+@Component
+@Scope("prototype")
public class TenantIsolationRequest {
private String requestId;
@@ -71,15 +74,16 @@ public class TenantIsolationRequest {
private String httpResponse;
private String responseBody;
private RequestStatusType status;
- private CloudOrchestrationRequest cor;
private String operationalEnvironmentId;
private long progress = Constants.PROGRESS_REQUEST_RECEIVED;
private String requestScope;
-
+ private CloudOrchestrationRequest cor;
+ @Autowired
+ private InfraActiveRequestsRepository infraActiveRequestsRepository;
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager ();
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRequest.class);
+
TenantIsolationRequest (String requestId) {
this.requestId = requestId;
@@ -91,23 +95,22 @@ public class TenantIsolationRequest {
}
void parse(CloudOrchestrationRequest request, HashMap<String,String> instanceIdMap, Action action) throws ValidationException {
- msoLogger.debug ("Validating the Cloud Orchestration request");
this.cor = request;
this.requestInfo = request.getRequestDetails().getRequestInfo();
try{
- ObjectMapper mapper = new ObjectMapper();
+ ObjectMapper mapper = new ObjectMapper();
requestJSON = mapper.writeValueAsString(request.getRequestDetails());
- } catch(Exception e){
- throw new ValidationException ("Parse ServiceInstanceRequest to JSON string");
+ } catch(JsonProcessingException e){
+ throw new ValidationException ("Parse ServiceInstanceRequest to JSON string", true);
}
String envId = null;
if(instanceIdMap != null) {
envId = instanceIdMap.get("operationalEnvironmentId");
if(envId != null && !UUIDChecker.isValidUUID (envId)){
- throw new ValidationException ("operationalEnvironmentId");
+ throw new ValidationException ("operationalEnvironmentId", true);
}
cor.setOperationalEnvironmentId(envId);
}
@@ -128,8 +131,11 @@ public class TenantIsolationRequest {
private void relatedInstanceValidation(Action action, RequestDetails requestDetails, RequestParameters requestParameters) throws ValidationException {
RelatedInstanceList[] instanceList = requestDetails.getRelatedInstanceList();
+ if (requestParameters == null) {
+ throw new ValidationException("requestParameters", true);
+ }
if((Action.activate.equals(action) || Action.deactivate.equals(action)) && OperationalEnvironment.ECOMP.equals(requestParameters.getOperationalEnvironmentType())) {
- throw new ValidationException("operationalEnvironmentType in requestParameters");
+ throw new ValidationException("operationalEnvironmentType in requestParameters", true);
}
if(!Action.deactivate.equals(action) && OperationalEnvironment.VNF.equals(requestParameters.getOperationalEnvironmentType())) {
@@ -138,23 +144,23 @@ public class TenantIsolationRequest {
RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
if(relatedInstance.getResourceType() == null) {
- throw new ValidationException("ResourceType in relatedInstance");
+ throw new ValidationException("ResourceType in relatedInstance", true);
}
if(!empty(relatedInstance.getInstanceName()) && !relatedInstance.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) {
- throw new ValidationException ("instanceName format");
+ throw new ValidationException ("instanceName format", true);
}
if (empty (relatedInstance.getInstanceId ())) {
- throw new ValidationException ("instanceId in relatedInstance");
+ throw new ValidationException ("instanceId in relatedInstance", true);
}
if (!UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) {
- throw new ValidationException ("instanceId format in relatedInstance");
+ throw new ValidationException ("instanceId format in relatedInstance", true);
}
}
} else {
- throw new ValidationException ("relatedInstanceList");
+ throw new ValidationException ("relatedInstanceList", true);
}
}
}
@@ -163,69 +169,69 @@ public class TenantIsolationRequest {
if(requestParameters != null) {
if(!Action.deactivate.equals(action) && requestParameters.getOperationalEnvironmentType() == null) {
- throw new ValidationException ("OperationalEnvironmentType");
+ throw new ValidationException ("OperationalEnvironmentType", true);
}
if (Action.create.equals(action) && empty(requestParameters.getTenantContext())) {
- throw new ValidationException ("Tenant Context");
+ throw new ValidationException ("Tenant Context", true);
}
if (!Action.deactivate.equals(action) && empty(requestParameters.getWorkloadContext())) {
- throw new ValidationException ("Workload Context");
+ throw new ValidationException ("Workload Context", true);
}
Manifest manifest = requestParameters.getManifest();
if(Action.activate.equals(action)) {
if(manifest == null) {
- throw new ValidationException ("Manifest on Activate");
+ throw new ValidationException ("Manifest on Activate", true);
} else {
List<ServiceModelList> serviceModelList = manifest.getServiceModelList();
- if(serviceModelList.size() == 0) {
- throw new ValidationException (" empty ServiceModelList");
+ if(serviceModelList.isEmpty()) {
+ throw new ValidationException (" empty ServiceModelList", true);
}
for(ServiceModelList list : serviceModelList) {
if(empty(list.getServiceModelVersionId())) {
- throw new ValidationException ("ServiceModelVersionId");
+ throw new ValidationException ("ServiceModelVersionId", true);
}
if (!UUIDChecker.isValidUUID (list.getServiceModelVersionId())) {
- throw new ValidationException ("ServiceModelVersionId format");
+ throw new ValidationException ("ServiceModelVersionId format", true);
}
if(list.getRecoveryAction() == null) {
- throw new ValidationException ("RecoveryAction");
+ throw new ValidationException ("RecoveryAction", true);
}
}
}
}
} else if(!Action.deactivate.equals(action)) {
- throw new ValidationException("request Parameters");
+ throw new ValidationException("request Parameters", true);
}
}
private void requestInfoValidation(Action action, RequestInfo requestInfo) throws ValidationException {
if(Action.create.equals(action) && empty(requestInfo.getInstanceName())) {
- throw new ValidationException ("instanceName");
+ throw new ValidationException ("instanceName", true);
}
if(!empty(requestInfo.getInstanceName()) && !requestInfo.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) {
- throw new ValidationException ("instanceName format");
+ throw new ValidationException ("instanceName format", true);
}
if (empty(requestInfo.getSource())) {
- throw new ValidationException ("source");
+ throw new ValidationException ("source", true);
}
if(empty(requestInfo.getRequestorId())) {
- throw new ValidationException ("requestorId");
+ throw new ValidationException ("requestorId", true);
}
ResourceType resourceType = requestInfo.getResourceType();
if(resourceType == null) {
- throw new ValidationException ("resourceType");
+ throw new ValidationException ("resourceType", true);
}
this.requestScope = resourceType.name();
@@ -233,136 +239,113 @@ public class TenantIsolationRequest {
void parseOrchestration (CloudOrchestrationRequest cor) throws ValidationException {
- msoLogger.debug ("Validating the Orchestration request");
-
this.cor = cor;
try{
ObjectMapper mapper = new ObjectMapper();
- //mapper.configure(Feature.WRAP_ROOT_VALUE, true);
requestJSON = mapper.writeValueAsString(cor.getRequestDetails());
- } catch(Exception e){
+ } catch(JsonProcessingException e){
throw new ValidationException ("Parse CloudOrchestrationRequest to JSON string", e);
}
+ if(cor.getRequestDetails() == null){
+ throw new ValidationException("requestDetails", true);
+ }
this.requestInfo = cor.getRequestDetails().getRequestInfo();
if (this.requestInfo == null) {
- throw new ValidationException ("requestInfo");
+ throw new ValidationException ("requestInfo", true);
}
if (empty (requestInfo.getSource ())) {
- throw new ValidationException ("source");
+ throw new ValidationException ("source", true);
}
if (empty (requestInfo.getRequestorId ())) {
- throw new ValidationException ("requestorId");
+ throw new ValidationException ("requestorId", true);
}
}
- public void createRequestRecord (Status status, Action action) {
- Session session = null;
- try {
+ public void createRequestRecord (Status status, Action action){
- session = requestsDbSessionFactoryManager.getSessionFactory ().openSession ();
- session.beginTransaction ();
+ InfraActiveRequests aq = new InfraActiveRequests ();
+ aq.setRequestId (requestId);
- if (null == cor) {
- cor = new CloudOrchestrationRequest();
- }
+ aq.setRequestAction(action.name());
+ aq.setAction(action.name());
- InfraActiveRequests aq = new InfraActiveRequests ();
- aq.setRequestId (requestId);
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
- aq.setRequestAction(action.name());
- aq.setAction(action.name());
+ aq.setStartTime (startTimeStamp);
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
+ if (requestInfo != null) {
- aq.setStartTime (startTimeStamp);
+ if(requestInfo.getSource() != null){
+ aq.setSource(requestInfo.getSource());
+ }
+ if(requestInfo.getRequestorId() != null) {
+ aq.setRequestorId(requestInfo.getRequestorId());
+ }
+ if(requestInfo.getResourceType() != null) {
+ aq.setRequestScope(requestInfo.getResourceType().name());
+ }
+ }
+
+ if(ResourceType.operationalEnvironment.name().equalsIgnoreCase(requestScope) && requestInfo != null) {
+ aq.setOperationalEnvId(operationalEnvironmentId);
+ aq.setOperationalEnvName(requestInfo.getInstanceName());
+ }
- if (requestInfo != null) {
+ aq.setRequestBody (this.requestJSON);
- if(requestInfo.getSource() != null){
- aq.setSource(requestInfo.getSource());
- }
- if(requestInfo.getRequestorId() != null) {
- aq.setRequestorId(requestInfo.getRequestorId());
- }
- if(requestInfo.getResourceType() != null) {
- aq.setRequestScope(requestInfo.getResourceType().name());
- }
- }
-
- if(ResourceType.operationalEnvironment.name().equalsIgnoreCase(requestScope)) {
- aq.setOperationalEnvId(operationalEnvironmentId);
- aq.setOperationalEnvName(requestInfo.getInstanceName());
- }
-
- aq.setRequestBody (this.requestJSON);
-
- aq.setRequestStatus (status.toString ());
- aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER);
-
- if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
- aq.setStatusMessage (this.errorMessage);
- aq.setResponseBody (this.responseBody);
- aq.setProgress(new Long(100));
-
- Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
- aq.setEndTime (endTimeStamp);
- } else if(status == Status.IN_PROGRESS) {
- aq.setProgress(Constants.PROGRESS_REQUEST_IN_PROGRESS);
- }
-
- msoLogger.debug ("About to insert a record");
-
- session.save (aq);
- session.getTransaction ().commit ();
- session.close ();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e);
- if (session != null) {
- session.close ();
- }
- if (!status.equals (Status.FAILED)) {
- throw e;
- }
- }
+ aq.setRequestStatus (status.toString ());
+ aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER);
+
+ if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
+ aq.setStatusMessage (this.errorMessage);
+ aq.setResponseBody (this.responseBody);
+ aq.setProgress(Long.valueOf(100));
+
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
+ aq.setEndTime (endTimeStamp);
+ } else if(status == Status.IN_PROGRESS) {
+ aq.setProgress(Constants.PROGRESS_REQUEST_IN_PROGRESS);
+ }
+ infraActiveRequestsRepository.save(aq);
}
public Map<String, String> getOrchestrationFilters (MultivaluedMap<String, String> queryParams) throws ValidationException {
String queryParam = null;
- Map<String, String> orchestrationFilterParams = new HashMap<String, String>();
+ Map<String, String> orchestrationFilterParams = new HashMap<>();
for (Entry<String,List<String>> entry : queryParams.entrySet()) {
queryParam = entry.getKey();
try{
for(String value : entry.getValue()) {
if(StringUtils.isBlank(value)) {
- throw new Exception(queryParam + " value");
+ throw (new Exception(queryParam + " value"));
}
orchestrationFilterParams.put(queryParam, value);
}
}catch(Exception e){
- throw new ValidationException (e.getMessage());
+ throw new ValidationException (e.getMessage(), true);
}
}
return orchestrationFilterParams;
}
-
+
/**
* Build Error Response for Exception handling.
- *
+ *
* @param int
* @param httpResponseCode the HTTP response code
* @param exceptionType.
* @param text the error description
* @param messageId
* @return the web service response
- *
+ *
*/
public Response buildServiceErrorResponse (int httpResponseCode,
MsoException exceptionType,
@@ -372,13 +355,9 @@ public class TenantIsolationRequest {
this.errorCode = messageId;
- if (text != null) {
- this.errorMessage = text;
- }
- else {
- this.errorMessage = "";
- }
+ this.errorCode = text != null ? text : "";
this.httpResponse = Integer.toString(httpResponseCode);
+
if(errorMessage.length() > 1999){
errorMessage = errorMessage.substring(0, 1999);
}
@@ -403,11 +382,9 @@ public class TenantIsolationRequest {
se.setMessageId(messageId);
se.setText(text);
if(variables != null){
- if(variables != null){
- for(String variable: variables){
- se.getVariables().add(variable);
- }
- }
+ for(String variable: variables){
+ se.getVariables().add(variable);
+ }
}
re.setServiceException(se);
}
@@ -422,7 +399,6 @@ public class TenantIsolationRequest {
msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in buildServiceErrorResponse writing exceptionType to string ", e);
}
-
return Response.status (httpResponseCode).entity(requestErrorStr).build ();
}
@@ -439,14 +415,15 @@ public class TenantIsolationRequest {
this.requestId = requestId;
}
- public void updateFinalStatus(Status failed) {
+ public void updateFinalStatus() {
try {
- (RequestsDatabase.getInstance()).updateInfraFinalStatus (requestId,
- status.toString (),
- this.errorMessage,
- this.progress,
- this.responseBody,
- Constants.MODIFIED_BY_APIHANDLER);
+ InfraActiveRequests request = new InfraActiveRequests(requestId);
+ request.setRequestStatus(status.toString());
+ request.setStatusMessage(this.errorMessage);
+ request.setProgress(this.progress);
+ request.setResponseBody(this.responseBody);
+ request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ infraActiveRequestsRepository.save(request);
} catch (Exception e) {
msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB");
msoLogger.debug ("Exception: ", e);
@@ -463,6 +440,14 @@ public class TenantIsolationRequest {
case IN_PROGRESS:
this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS;
break;
+ case PENDING:
+ break;
+ case TIMEOUT:
+ break;
+ case UNLOCKED:
+ break;
+ default:
+ break;
}
}
@@ -473,4 +458,4 @@ public class TenantIsolationRequest {
public void setOperationalEnvironmentId(String operationalEnvironmentId) {
this.operationalEnvironmentId = operationalEnvironmentId;
}
-}
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
new file mode 100644
index 0000000000..461acab96d
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation;
+
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolation.process.ActivateVnfOperationalEnvironment;
+import org.onap.so.apihandlerinfra.tenantisolation.process.ActivateVnfStatusOperationalEnvironment;
+import org.onap.so.apihandlerinfra.tenantisolation.process.CreateEcompOperationalEnvironment;
+import org.onap.so.apihandlerinfra.tenantisolation.process.CreateVnfOperationalEnvironment;
+import org.onap.so.apihandlerinfra.tenantisolation.process.DeactivateVnfOperationalEnvironment;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Action;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
+import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository;
+import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.RequestsDBHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+@Component
+@Scope("prototype")
+public class TenantIsolationRunnable {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRunnable.class);
+
+ @Autowired
+ private RequestsDBHelper requestDb;
+ @Autowired
+ private CreateEcompOperationalEnvironment createEcompOpEnv;
+ @Autowired
+ private CreateVnfOperationalEnvironment createVnfOpEnv;
+ @Autowired
+ private ActivateVnfOperationalEnvironment activateVnfOpEnv;
+ @Autowired
+ private DeactivateVnfOperationalEnvironment deactivateVnfOpEnv;
+ @Autowired
+ private ActivateVnfStatusOperationalEnvironment activateVnfStatusOpEnv;
+ @Autowired
+ private OperationalEnvDistributionStatusRepository distributionStatusRepository;
+ @Autowired
+ private OperationalEnvServiceModelStatusRepository modelStatusRepository;
+
+ @Async
+ public void run(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws ApiException {
+ msoLogger.debug ("Starting threadExecution in TenantIsolationRunnable for Action " + action.name() + " and OperationalEnvType: " + operationalEnvType);
+ try {
+
+ if(Action.create.equals(action)) {
+ if(OperationalEnvironment.ECOMP.name().equalsIgnoreCase(operationalEnvType)) {
+ createEcompOpEnv.execute(requestId, cor);
+ } else if(OperationalEnvironment.VNF.name().equalsIgnoreCase(operationalEnvType)) {
+ createVnfOpEnv.execute(requestId, cor);
+ } else {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build();
+ ValidateException validateException = new ValidateException.Builder("Invalid OperationalEnvironment Type specified for Create Action",
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ } else if(Action.activate.equals(action)) {
+ activateVnfOpEnv.execute(requestId, cor, distributionStatusRepository, modelStatusRepository);
+ } else if(Action.deactivate.equals(action)) {
+ deactivateVnfOpEnv.execute(requestId, cor);
+ } else if(Action.distributionStatus.equals(action)) {
+ activateVnfStatusOpEnv.execute(requestId, cor, distributionStatusRepository, modelStatusRepository);
+ } else {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build();
+ ValidateException validateException = new ValidateException.Builder("Invalid Action specified: " + action,
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
+ throw validateException;
+ }
+ }catch(ApiException e) {
+ requestDb.updateInfraFailureCompletion(e.getMessage(), requestId, cor.getOperationalEnvironmentId());
+ throw e;
+ }
+ }
+}
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java
new file mode 100644
index 0000000000..44198d727d
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java
@@ -0,0 +1,162 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.dmaap;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "operationalEnvironmentId",
+ "operationalEnvironmentName",
+ "operationalEnvironmentType",
+ "tenantContext",
+ "workloadContext"
+})
+
+public class CreateEcompOperationEnvironmentBean {
+
+ @JsonProperty("operationalEnvironmentId")
+ private String operationalEnvironmentId;
+ @JsonProperty("operationalEnvironmentName")
+ private String operationalEnvironmentName;
+ @JsonProperty("operationalEnvironmentType")
+ private String operationalEnvironmentType;
+ @JsonProperty("tenantContext")
+ private String tenantContext;
+ @JsonProperty("workloadContext")
+ private String workloadContext;
+ @JsonProperty("action")
+ private String action;
+
+ public CreateEcompOperationEnvironmentBean() {}
+
+ /**
+ *
+ * @param operationalEnvironmentId
+ * @param operationalEnvironmentName
+ * @param operationalEnvironmentType
+ * @param tenantContext
+ * @param workloadContext
+ */
+ public CreateEcompOperationEnvironmentBean(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType,
+ String tenantContext, String workloadContext, String action) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ this.tenantContext = tenantContext;
+ this.workloadContext = workloadContext;
+ this.action = action;
+ }
+
+ @JsonProperty("operationalEnvironmentId")
+ public String getOperationalEnvironmentId() {
+ return operationalEnvironmentId;
+ }
+
+ @JsonProperty("operationalEnvironmentId")
+ public void setOperationalEnvironmentId(String operationalEnvironmentId) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ }
+
+ public CreateEcompOperationEnvironmentBean withOperationalEnvironmentId(String operationalEnvironmentId) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ return this;
+ }
+
+
+ @JsonProperty("operationalEnvironmentName")
+ public String getoperationalEnvironmentName() {
+ return operationalEnvironmentName;
+ }
+
+ @JsonProperty("operationalEnvironmentName")
+ public void setoperationalEnvironmentName(String operationalEnvironmentName) {
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ }
+
+ public CreateEcompOperationEnvironmentBean withOperationalEnvironmentName(String operationalEnvironmentName) {
+ this.operationalEnvironmentName = operationalEnvironmentName;
+ return this;
+ }
+
+ @JsonProperty("operationalEnvironmentType")
+ public String getoperationalEnvironmentType() {
+ return operationalEnvironmentType;
+ }
+
+ @JsonProperty("operationalEnvironmentType")
+ public void setoperationalEnvironmentType(String operationalEnvironmentType) {
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ }
+
+ public CreateEcompOperationEnvironmentBean withOperationalEnvironmentType(String operationalEnvironmentType) {
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ return this;
+ }
+
+ @JsonProperty("tenantContext")
+ public String gettenantContext() {
+ return tenantContext;
+ }
+
+ @JsonProperty("tenantContext")
+ public void settenantContext(String tenantContext) {
+ this.tenantContext = tenantContext;
+ }
+
+ public CreateEcompOperationEnvironmentBean withTenantContext(String tenantContext) {
+ this.tenantContext = tenantContext;
+ return this;
+ }
+
+ @JsonProperty("workloadContext")
+ public String getworkloadContext() {
+ return workloadContext;
+ }
+
+ @JsonProperty("workloadContext")
+ public void setworkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ public CreateEcompOperationEnvironmentBean withWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ return this;
+ }
+
+ @JsonProperty("action")
+ public String getaction() {
+ return action;
+ }
+
+ @JsonProperty("action")
+ public void setaction(String action) {
+ this.action = action;
+ }
+
+ public CreateEcompOperationEnvironmentBean withaction(String action) {
+ this.action = action;
+ return this;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java
index 4d47acdd22..f718431534 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java
@@ -7,9 +7,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.
@@ -18,20 +18,33 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap;
+package org.onap.so.apihandlerinfra.tenantisolation.dmaap;
import java.io.IOException;
+import javax.inject.Provider;
+
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
-import org.openecomp.mso.client.dmaap.DmaapPublisher;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+@Component
public class DmaapOperationalEnvClient {
+ @Autowired
+ private Provider<OperationalEnvironmentPublisher> dmaapPublisher;
protected String buildRequest(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String tenantContext, String workloadContext, String action )
- throws JsonProcessingException {
+ throws ApiException {
final CreateEcompOperationEnvironmentBean operationalEnv = new CreateEcompOperationEnvironmentBean();
operationalEnv.withOperationalEnvironmentId(operationalEnvironmentId)
.withOperationalEnvironmentName(operationalEnvironmentName)
@@ -39,9 +52,15 @@ public class DmaapOperationalEnvClient {
.withTenantContext(tenantContext)
.withWorkloadContext(workloadContext)
.withaction(action);
-
- return this.getJson(operationalEnv);
-
+ try {
+ return this.getJson(operationalEnv);
+ }catch(JsonProcessingException ex){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build();
+ ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + ex.getMessage(),
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(ex).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
}
protected String getJson(CreateEcompOperationEnvironmentBean obj) throws JsonProcessingException {
@@ -51,17 +70,12 @@ public class DmaapOperationalEnvClient {
}
- protected DmaapPublisher getPublisher() throws IOException {
- return new OperationalEnvironmentPublisher();
- }
-
public void dmaapPublishOperationalEnvRequest(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType,
- String tenantContext, String workloadContext, String action ) throws Exception {
-
+ String tenantContext, String workloadContext, String action ) throws ApiException, IOException, InterruptedException {
+
String request = this.buildRequest(operationalEnvironmentId, operationalEnvironmentName, operationalEnvironmentType, tenantContext, workloadContext, action);
- final DmaapPublisher publisher = this.getPublisher();
- publisher.send(request);
-
+ dmaapPublisher.get().send(request);
+
}
-
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/InfraUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java
index 1d70224100..0e26178e56 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/InfraUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java
@@ -18,26 +18,38 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra;
+package org.onap.so.apihandlerinfra.tenantisolation.dmaap;
+import java.util.HashMap;
+import java.util.Map;
+import org.onap.so.apihandlerinfra.SpringContextHelper;
+import org.onap.so.client.dmaap.DmaapProperties;
+import org.springframework.context.ApplicationContext;
-import java.util.Arrays;
+public class DmaapPropertiesImpl implements DmaapProperties {
-import org.openecomp.mso.properties.MsoJavaProperties;
+ private final Map<String, String> props = new HashMap<>();
+ private static final String[] propertyNames = {
+ "mso.so.operational-environment.dmaap.username",
+ "mso.so.operational-environment.dmaap.password",
+ "mso.so.operational-environment.publisher.topic",
+ "mso.so.operational-environment.dmaap.host"
+ };
+ public DmaapPropertiesImpl () {
+ ApplicationContext context = SpringContextHelper.getAppContext();
+
+ for (String name : propertyNames) {
+ this.props.put(name, context.getEnvironment().getProperty(name));
+
+ }
-public class InfraUtils {
- public static boolean isActionAllowed(MsoJavaProperties props, String requestType, String version, String action) {
- // Check for allowable actions
- String actionsPropertyName = requestType + "." + version + ".ApiAllowableActions";
- String allowableActions = props.getProperty(actionsPropertyName, null);
- return allowableActions == null || Arrays.asList(allowableActions.split(",")).contains(action);
}
- // Checks if the name is acceptable for heat stack
- public static boolean isValidHeatName(String name) {
- return name.matches("^[a-zA-Z][a-zA-Z0-9_\\.-]*$");
+ @Override
+ public Map<String, String> getProperties() {
+
+ return this.props;
}
-
-
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java
index 36c1085655..52c395e1d1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java
@@ -7,9 +7,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.
@@ -18,41 +18,44 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap;
+package org.onap.so.apihandlerinfra.tenantisolation.dmaap;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Optional;
-import org.openecomp.mso.client.dmaap.DmaapPublisher;
+import org.onap.so.client.dmaap.DmaapPublisher;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+@Component
+@Scope("prototype")
public class OperationalEnvironmentPublisher extends DmaapPublisher {
- public OperationalEnvironmentPublisher() throws FileNotFoundException, IOException {
+ public OperationalEnvironmentPublisher() throws IOException {
super();
}
@Override
public String getUserName() {
- return this.msoProperties.get("so.operational-environment.dmaap.username");
+ return this.msoProperties.get("mso.so.operational-environment.dmaap.username");
}
@Override
public String getPassword() {
- return this.msoProperties.get("so.operational-environment.dmaap.password");
+ return this.msoProperties.get("mso.so.operational-environment.dmaap.password");
}
@Override
public String getTopic() {
- return this.msoProperties.get("so.operational-environment.publisher.topic");
+ return this.msoProperties.get("mso.so.operational-environment.publisher.topic");
}
@Override
public Optional<String> getHost() {
- return Optional.ofNullable(this.msoProperties.get("so.operational-environment.dmaap.host"));
+ return Optional.ofNullable(this.msoProperties.get("mso.so.operational-environment.dmaap.host"));
}
-} \ No newline at end of file
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java
index 993c7dc9b7..4f4fa1ae35 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions;
+package org.onap.so.apihandlerinfra.tenantisolation.exceptions;
public class AAIClientCallFailed extends Exception {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AsdcClientCallFailed.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailed.java
index 3e9009d2e3..9cdef3c9d1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/AsdcClientCallFailed.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailed.java
@@ -7,9 +7,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.
@@ -18,15 +18,17 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions;
+package org.onap.so.apihandlerinfra.tenantisolation.exceptions;
-public class AsdcClientCallFailed extends Exception {
+public class SDCClientCallFailed extends Exception {
- public AsdcClientCallFailed(String message, Throwable cause) {
+ private static final long serialVersionUID = 3066575499816576134L;
+
+ public SDCClientCallFailed(String message, Throwable cause) {
super(message, cause);
}
- public AsdcClientCallFailed(String message) {
+ public SDCClientCallFailed(String message) {
super(message);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java
index 279a93e1b7..af3e7937af 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java
@@ -1,36 +1,36 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions;
-
-public class TenantIsolationException extends Exception {
-
- private static final long serialVersionUID = 6948152225371031774L;
-
- public TenantIsolationException() {
- super();
-
- }
-
- public TenantIsolationException(String msg) {
- super ("Tenant Isolation error: " + msg);
-
- }
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.exceptions;
+
+public class TenantIsolationException extends Exception {
+
+ private static final long serialVersionUID = 6948152225371031774L;
+
+ public TenantIsolationException() {
+ super();
+
+ }
+
+ public TenantIsolationException(String msg) {
+ super ("Tenant Isolation error: " + msg);
+
+ }
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
new file mode 100644
index 0000000000..6fd33a6afc
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
@@ -0,0 +1,120 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.helpers;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Map;
+
+import javax.ws.rs.NotFoundException;
+
+import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class AAIClientHelper {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, AAIClientHelper.class);
+
+ /**
+ * Get managing ECOMP Environment Info from A&AI
+ * @param id = operationalEnvironmentId
+ * @return AAIResultWrapper object
+ */
+ public AAIResultWrapper getAaiOperationalEnvironment(String id){
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
+ uri.depth(Depth.ZERO); //Do not return relationships if any
+ AAIResourcesClient client = this.getClient();
+ return client.get(uri, NotFoundException.class);
+ }
+
+
+ /**
+ * Update managing ECOMP Environment Info from A&AI
+ * @param id = operationalEnvironmentId
+ * @param AAIOperationalEnvironment object
+ */
+ public void updateAaiOperationalEnvironment(String id, AAIOperationalEnvironment aaiRequest){
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
+ AAIResourcesClient client = this.getClient();
+ client.update(uri, aaiRequest);
+
+ }
+
+
+ public void updateAaiOperationalEnvironment(String operationalEnvironmentId, Map<String, String> payload) throws Exception {
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironmentId);
+ AAIResourcesClient aaiClient = this.getClient();
+ aaiClient.update(uri, payload);
+ }
+ catch(Exception ex) {
+ logStackTrace(ex);
+ throw new AAIClientCallFailed("Call to A&AI failed!", ex);
+ }
+ }
+
+ /**
+ * Create an Operational Environment object in A&AI
+ * @param AAIOperationalEnvironment object
+ */
+ public void createOperationalEnvironment(AAIOperationalEnvironment operationalEnvironment){
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironment.getOperationalEnvironmentId());
+ AAIResourcesClient client = this.getClient();
+ client.create(uri, operationalEnvironment);
+ }
+
+ /**
+ * Create a relationship between ECOMP managing and VNF Operational Environments
+ * @param managingEcompOperationalEnvironmentId
+ * @param vnfOperationalEnvironmentId
+ * @throws Exception
+ */
+ public void createRelationship(String managingEcompOperationalEnvironmentId, String vnfOperationalEnvironmentId) {
+
+ AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, managingEcompOperationalEnvironmentId);
+ AAIResourceUri vnfEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, vnfOperationalEnvironmentId);
+ AAIResourcesClient client = this.getClient();
+ client.connect(vnfEnvUri, ecompEnvUri);
+
+ }
+
+ private void logStackTrace(Exception e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ }
+
+ protected AAIResourcesClient getClient() {
+ return new AAIResourcesClient();
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java
new file mode 100644
index 0000000000..23642bdfb4
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.helpers;
+
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AAIClientObjectBuilder {
+
+ public AAIOperationalEnvironment buildAAIOperationalEnvironment(String status, CloudOrchestrationRequest cloudOrchestrationRequest) {
+ AAIOperationalEnvironment env = new AAIOperationalEnvironment();
+ env.setOperationalEnvironmentId(cloudOrchestrationRequest.getOperationalEnvironmentId());
+ env.setOperationalEnvironmentName(cloudOrchestrationRequest.getRequestDetails().getRequestInfo().getInstanceName());
+ env.setOperationalEnvironmentType(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString());
+ env.setOperationalEnvironmentStatus(status);
+ env.setTenantContext(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getTenantContext());
+ env.setWorkloadContext(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getWorkloadContext());
+ return env;
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java
new file mode 100644
index 0000000000..dcd3a42875
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java
@@ -0,0 +1,118 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.helpers;
+
+import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
+import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ActivateVnfDBHelper {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfDBHelper.class);
+
+ /**
+ * Insert record to OperationalEnvServiceModelStatus table
+ * @param requestId - String
+ * @param operationalEnvironmentId - String
+ * @param serviceModelVersionId - String
+ * @param status - String
+ * @param recoveryAction - String
+ * @param retryCount - int
+ * @param workloadContext - String
+ * @return serviceModelStatus - OperationalEnvServiceModelStatus object
+ */
+ public OperationalEnvServiceModelStatus insertRecordToOperationalEnvServiceModelStatus( String requestId,
+ String operationalEnvironmentId,
+ String serviceModelVersionId,
+ String status,
+ String recoveryAction,
+ int retryCount,
+ String workloadContext) {
+ OperationalEnvServiceModelStatus serviceModelStatus = new OperationalEnvServiceModelStatus();
+ serviceModelStatus.setRequestId(requestId);
+ serviceModelStatus.setOperationalEnvId(operationalEnvironmentId);
+ serviceModelStatus.setServiceModelVersionId(serviceModelVersionId);
+ serviceModelStatus.setServiceModelVersionDistrStatus(status);
+ serviceModelStatus.setRecoveryAction(recoveryAction);
+ serviceModelStatus.setRetryCount(new Integer(retryCount));
+ serviceModelStatus.setWorkloadContext(workloadContext);
+ return serviceModelStatus;
+ }
+
+ /**
+ * Update RetryCount & Status in OperationalEnvServiceModelStatus table
+ * @param serviceModelStatusResponse - OperationalEnvServiceModelStatus object
+ * @param status - String
+ * @param retryCount - int
+ * @return serviceModelStatusResponse - OperationalEnvServiceModelStatus object
+ */
+ public OperationalEnvServiceModelStatus updateRetryCountAndStatusInOperationalEnvServiceModelStatus(OperationalEnvServiceModelStatus serviceModelStatusResponse,
+ String status,
+ int retryCount) {
+ serviceModelStatusResponse.setServiceModelVersionDistrStatus(status);
+ serviceModelStatusResponse.setRetryCount(new Integer(retryCount));
+ return serviceModelStatusResponse;
+ }
+
+ /**
+ * Insert record to OperationalEnvDistributionStatus table
+ * @param distributionId - String
+ * @param operationalEnvironmentId - String
+ * @param serviceModelVersionId - String
+ * @param requestId - String
+ * @param status - String
+ * @param distributionIdErrorReason - String
+ * @return distStatus - OperationalEnvDistributionStatus object
+ */
+ public OperationalEnvDistributionStatus insertRecordToOperationalEnvDistributionStatus( String distributionId,
+ String operationalEnvironmentId,
+ String serviceModelVersionId,
+ String requestId,
+ String status,
+ String distributionIdErrorReason) {
+ OperationalEnvDistributionStatus distStatus = new OperationalEnvDistributionStatus();
+ distStatus.setDistributionId(distributionId);
+ distStatus.setOperationalEnvId(operationalEnvironmentId);
+ distStatus.setServiceModelVersionId(serviceModelVersionId);
+ distStatus.setRequestId(requestId);
+ distStatus.setDistributionIdStatus(status);
+ distStatus.setDistributionIdErrorReason(distributionIdErrorReason);
+ return distStatus;
+ }
+
+ /**
+ * Update Status in OperationalEnvDistributionStatus table
+ * @param distributionStatusResponse - OperationalEnvDistributionStatus object
+ * @param status - String
+ * @param distributionIdErrorReason - String
+ * @return distributionStatusResponse - OperationalEnvDistributionStatus object
+ */
+ public OperationalEnvDistributionStatus updateStatusInOperationalEnvDistributionStatus(OperationalEnvDistributionStatus distributionStatusResponse,
+ String status,
+ String distributionIdErrorReason) {
+ distributionStatusResponse.setDistributionIdStatus(status);
+ distributionStatusResponse.setDistributionIdErrorReason(distributionIdErrorReason);
+ return distributionStatusResponse;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java
new file mode 100644
index 0000000000..804eb696cb
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java
@@ -0,0 +1,236 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.helpers;
+
+import java.util.UUID;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+
+import org.apache.http.HttpStatus;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.rest.APIResponse;
+import org.onap.so.rest.RESTClient;
+import org.onap.so.rest.RESTConfig;
+import org.onap.so.rest.RESTException;
+import org.onap.so.utils.CryptoUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SDCClientHelper {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, SDCClientHelper.class);
+ private static final String SDC_CONTENT_TYPE = "application/json";
+ private static final String SDC_ACCEPT_TYPE = "application/json";
+ private static String PARTIAL_SDC_URI = "/sdc/v1/catalog/services/";
+
+ private static String MESSAGE_UNDEFINED_ERROR = "Undefined Error Message!";
+ private static String MESSAGE_UNEXPECTED_FORMAT = "Unexpected response format from SDC.";
+
+ @Value("${mso.sdc.endpoint}")
+ private String sdcEndpoint;
+ @Value("${mso.sdc.activate.userid}")
+ private String sdcActivateUserId;
+ @Value("${mso.sdc.activate.instanceid}")
+ private String sdcActivateInstanceId;
+ @Value("${mso.sdc.client.auth}")
+ private String sdcClientAuth;
+ @Value("${mso.msoKey}")
+ private String msoKey;
+
+ /**
+ * Send POST request to SDC for operational activation
+ * @param serviceModelVersionI - String
+ * @param operationalEnvironmentId - String
+ * @param workloadContext - String
+ * @return sdcResponseJsonObj - JSONObject object
+ * @throws JSONException
+ */
+ public JSONObject postActivateOperationalEnvironment(String serviceModelVersionId, String operationalEnvironmentId, String workloadContext) throws ApiException {
+ JSONObject sdcResponseJsonObj = new JSONObject();
+
+ try {
+ String url = this.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId);
+ String jsonPayload = this.buildJsonWorkloadContext(workloadContext);
+ String basicAuthCred = getBasicAuth();
+
+ if ( basicAuthCred == null || "".equals(basicAuthCred) ) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
+ ValidateException validateException = new ValidateException.Builder(" SDC credentials 'mso.sdc.client.auth' not setup in properties file!",
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+
+ RESTConfig config = new RESTConfig(url);
+ RESTClient client = setRestClient(config);
+ client.addAuthorizationHeader(basicAuthCred);
+
+ APIResponse apiResponse = setHttpPostResponse(client, jsonPayload);
+ int statusCode = apiResponse.getStatusCode();
+
+ String responseData = apiResponse.getResponseBodyAsString();
+ sdcResponseJsonObj = enhanceJsonResponse(new JSONObject(responseData), statusCode);
+
+ } catch (Exception ex) {
+ msoLogger.debug("calling SDC Exception message: " + ex.getMessage());
+ String errorMessage = " Encountered Error while calling SDC POST Activate. " + ex.getMessage();
+ msoLogger.debug(errorMessage);
+ sdcResponseJsonObj.put("statusCode", String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
+ sdcResponseJsonObj.put("messageId", "");
+ sdcResponseJsonObj.put("message", errorMessage);
+
+ }
+ return sdcResponseJsonObj;
+ }
+
+ /**
+ * set RESTClient
+ * @param config - RESTConfig object
+ * @return client - RestClient object
+ */
+ public RESTClient setRestClient(RESTConfig config) throws Exception {
+ RESTClient client = new RESTClient(config).addHeader("X-ECOMP-InstanceID", sdcActivateInstanceId)
+ .addHeader("X-ECOMP-RequestID", UUID.randomUUID().toString())
+ .addHeader("Content-Type", SDCClientHelper.SDC_CONTENT_TYPE)
+ .addHeader("Accept", SDCClientHelper.SDC_ACCEPT_TYPE)
+ .addHeader("USER_ID", sdcActivateUserId);
+ return client;
+ }
+
+ /**
+ * set HttpPostResponse
+ * @param config - RESTConfig object
+ * @param jsonPayload - String
+ * @return client - RestClient object
+ */
+ public APIResponse setHttpPostResponse(RESTClient client, String jsonPayload) throws ApiException {
+ try {
+ return client.httpPost(jsonPayload);
+ }catch(RESTException ex){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
+ ValidateException validateException = new ValidateException.Builder("Bad request could not post payload",
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
+ }
+ }
+
+ /**
+ * enhance Response
+ * @param sdcResponseJsonObj - JSONObject object
+ * @param statusCode - int
+ * @return enhancedAsdcResponseJsonObj - JSONObject object
+ */
+ public JSONObject enhanceJsonResponse(JSONObject sdcResponseJsonObj, int statusCode) throws JSONException {
+
+ JSONObject enhancedAsdcResponseJsonObj = new JSONObject();
+
+ String message = "";
+ String messageId = "";
+
+ if (statusCode == Response.Status.ACCEPTED.getStatusCode()) { // Accepted
+ enhancedAsdcResponseJsonObj.put("distributionId", sdcResponseJsonObj.get("distributionId"));
+ enhancedAsdcResponseJsonObj.put("statusCode", Integer.toString(statusCode));
+ enhancedAsdcResponseJsonObj.put("messageId", "");
+ enhancedAsdcResponseJsonObj.put("message", "Success");
+
+ } else { // error
+ if (sdcResponseJsonObj.has("requestError") ) {
+ JSONObject requestErrorObj = sdcResponseJsonObj.getJSONObject("requestError");
+ if (sdcResponseJsonObj.getJSONObject("requestError").has("serviceException") ) {
+ message = requestErrorObj.getJSONObject("serviceException").getString("text");
+ messageId = requestErrorObj.getJSONObject("serviceException").getString("messageId");
+ }
+ if (sdcResponseJsonObj.getJSONObject("requestError").has("policyException") ) {
+ message = requestErrorObj.getJSONObject("policyException").getString("text");
+ messageId = requestErrorObj.getJSONObject("policyException").getString("messageId");
+ }
+ enhancedAsdcResponseJsonObj.put("statusCode", Integer.toString(statusCode));
+ enhancedAsdcResponseJsonObj.put("messageId", messageId);
+ enhancedAsdcResponseJsonObj.put("message", message);
+
+ } else {
+ // unexpected format
+ enhancedAsdcResponseJsonObj.put("statusCode", String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()));
+ enhancedAsdcResponseJsonObj.put("messageId", MESSAGE_UNDEFINED_ERROR);
+ enhancedAsdcResponseJsonObj.put("message", MESSAGE_UNEXPECTED_FORMAT);
+ }
+ }
+ return enhancedAsdcResponseJsonObj;
+
+ }
+
+ /**
+ * Build Uri
+ * @param serviceModelVersionId - String
+ * @param operationalEnvironmentId - String
+ * @return uriBuilder - String
+ */
+ public String buildUriBuilder(String serviceModelVersionId, String operationalEnvironmentId) {
+ String path = serviceModelVersionId + "/distribution/" + operationalEnvironmentId +"/activate";
+ UriBuilder uriBuilder = UriBuilder.fromPath(sdcEndpoint + SDCClientHelper.PARTIAL_SDC_URI)
+ .path(path);
+ return uriBuilder.build().toString();
+ }
+
+ /**
+ * Build JSON context
+ * @param workloadContext - String
+ * @return String json
+ * @throws JSONException
+ */
+ public String buildJsonWorkloadContext(String workloadContext) throws JSONException {
+ return new JSONObject().put("workloadContext", workloadContext).toString();
+
+ }
+
+ /**
+ * decrypt value
+ * @param toDecrypt - String
+ * @param msokey - String
+ * @return result - String
+ */
+ public synchronized String decrypt(String toDecrypt, String msokey){
+ String result = null;
+ try {
+ result = CryptoUtils.decrypt(toDecrypt, msokey);
+
+ }
+ catch (Exception e) {
+ msoLogger.debug("Failed to decrypt credentials: " + toDecrypt, e);
+ }
+ return result;
+ }
+
+ private String getBasicAuth() {
+ return decrypt(sdcClientAuth, msoKey);
+ }
+}
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
new file mode 100644
index 0000000000..903639c8f5
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
@@ -0,0 +1,183 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.process;
+
+import java.util.List;
+import java.util.Optional;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.json.JSONObject;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
+import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
+import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
+import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository;
+import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.RequestsDBHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class ActivateVnfOperationalEnvironment {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class);
+ private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3;
+ private static final String DISTRIBUTION_STATUS_SENT = "SENT";
+
+ @Autowired
+ private ActivateVnfDBHelper dbHelper;
+ @Autowired
+ private AAIClientHelper aaiHelper;
+ @Autowired
+ private RequestsDBHelper requestDb;
+ @Autowired
+ private SDCClientHelper sdcClientHelper;
+
+ @Value("${mso.tenant.isolation.retry.count}")
+ private String sdcRetryCount;
+
+ /**
+ * The Point-Of-Entry from APIH with VID request to send activate request
+ * @param requestId - String
+ * @param request - CloudOrchestrationRequest object
+ * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object
+ * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
+ * @return void - nothing
+ */
+ public void execute(String requestId, CloudOrchestrationRequest request, OperationalEnvDistributionStatusRepository distributionStatusRepository,
+ OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException{
+ String operationalEnvironmentId = request.getOperationalEnvironmentId();
+
+ String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext();
+ List<ServiceModelList> serviceModelVersionIdList = request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList();
+
+
+ AAIOperationalEnvironment operationalEnv = getAAIOperationalEnvironment(operationalEnvironmentId);
+ String workloadContext = operationalEnv.getWorkloadContext();
+ msoLogger.debug(" aai workloadContext: " + workloadContext);
+ if (!vidWorkloadContext.equals(workloadContext)) {
+
+
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
+ throw new ValidateException.Builder(" The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext,
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+ }
+
+ processActivateSDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext, distributionStatusRepository, modelStatusRepository);
+
+ }
+
+
+ /**
+ * The Method to send the Activation Requests to SDC
+ * @param requestId - String
+ * @param operationalEnvironmentId - String
+ * @param serviceModelVersionIdList - List<ServiceModelList> list
+ * @param workloadContext - String
+ * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object
+ * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
+ * @return jsonResponse - JSONObject object
+ */
+ public void processActivateSDCRequest(String requestId, String operationalEnvironmentId, List<ServiceModelList> serviceModelVersionIdList,
+ String workloadContext, OperationalEnvDistributionStatusRepository distributionStatusRepository,
+ OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException {
+
+ JSONObject jsonResponse = null;
+ int retryCount = 0;
+ try {
+ retryCount = Integer.parseInt(sdcRetryCount);
+ } catch (NumberFormatException e) {
+ retryCount = DEFAULT_ACTIVATE_RETRY_COUNT;
+ }
+
+ // loop through the serviceModelVersionId, and send request SDC
+ for(ServiceModelList serviceModelList : serviceModelVersionIdList){
+ String serviceModelVersionId = serviceModelList.getServiceModelVersionId();
+ String recoveryAction = serviceModelList.getRecoveryAction().toString().toUpperCase();
+
+ // should insert 1 row
+ OperationalEnvServiceModelStatus serviceModelStatus =
+ dbHelper.insertRecordToOperationalEnvServiceModelStatus(requestId,
+ operationalEnvironmentId,
+ serviceModelVersionId,
+ DISTRIBUTION_STATUS_SENT,
+ recoveryAction,
+ retryCount,
+ workloadContext);
+ modelStatusRepository.save(serviceModelStatus);
+
+ String distributionId = "";
+
+ jsonResponse = sdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
+
+ String statusCode = jsonResponse.get("statusCode").toString();
+ if (statusCode.equals(String.valueOf(Response.Status.ACCEPTED.getStatusCode()))) {
+ distributionId = jsonResponse.get("distributionId").toString();
+ // should insert 1 row
+ OperationalEnvDistributionStatus distStatus =
+ dbHelper.insertRecordToOperationalEnvDistributionStatus(distributionId,
+ operationalEnvironmentId,
+ serviceModelVersionId,
+ requestId,
+ DISTRIBUTION_STATUS_SENT,
+ "");
+ distributionStatusRepository.save(distStatus);
+
+ } else {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
+ String dbErrorMessage = " Failure calling SDC: statusCode: " + statusCode +
+ "; messageId: " + jsonResponse.get("messageId") +
+ "; message: " + jsonResponse.get("message");
+
+ requestDb.updateInfraFailureCompletion(dbErrorMessage, requestId, operationalEnvironmentId);
+ throw new ValidateException.Builder(dbErrorMessage,
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+ }
+ }
+
+ }
+
+ /**
+ * Get AAIOperationalEnvironment object
+ * @param operationalEnvironmentId - String
+ * @return operationalEnv - AAIOperationalEnvironment object
+ */
+ public AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
+ AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
+ return aaiResult.asBean(AAIOperationalEnvironment.class).orElse(new AAIOperationalEnvironment());
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
new file mode 100644
index 0000000000..6a9bec5abb
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
@@ -0,0 +1,300 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.process;
+
+
+import java.util.List;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.json.JSONObject;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus;
+import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
+import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
+import org.onap.so.db.request.data.repository.OperationalEnvDistributionStatusRepository;
+import org.onap.so.db.request.data.repository.OperationalEnvServiceModelStatusRepository;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.RequestsDBHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ActivateVnfStatusOperationalEnvironment {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfStatusOperationalEnvironment.class);
+ private String origRequestId = "";
+ private String errorMessage = "";
+ private OperationalEnvDistributionStatus queryDistributionDbResponse = null;
+ private OperationalEnvServiceModelStatus queryServiceModelResponse = null;
+
+ private final int RETRY_COUNT_ZERO = 0;
+ private final String ERROR_REASON_ABORTED = "ABORTED";
+ private final String RECOVERY_ACTION_RETRY = "RETRY";
+ private final String RECOVERY_ACTION_ABORT = "ABORT";
+ private final String RECOVERY_ACTION_SKIP = "SKIP";
+ private final String DISTRIBUTION_STATUS_OK = DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString();
+ private final String DISTRIBUTION_STATUS_ERROR = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString();
+ private final String DISTRIBUTION_STATUS_SENT = "SENT";
+
+ private final String MESSAGE_UNDEFINED_ID = "Undefined Error Message!";
+
+ @Autowired
+ private ActivateVnfDBHelper dbHelper;
+ @Autowired
+ private RequestsDBHelper requestDb;
+ @Autowired
+ private SDCClientHelper sdcClientHelper;
+
+ /**
+ * The Point-Of-Entry from APIH with activate status from SDC
+ * @param requestId - String
+ * @param request - CloudOrchestrationRequest - object
+ * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository - object
+ * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository - object
+ * @return void - nothing
+ */
+ public void execute(String requestId, CloudOrchestrationRequest request, OperationalEnvDistributionStatusRepository distributionStatusRepository,
+ OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException {
+
+
+ String operationalEnvironmentId = "";
+
+ String sdcDistributionId = request.getDistributionId();
+ Distribution sdcStatus = request.getDistribution();
+
+ // Distribution, Query for operationalEnvironmentId, serviceModelVersionId
+ this.queryDistributionDbResponse = distributionStatusRepository.findOne(sdcDistributionId);
+ operationalEnvironmentId = this.queryDistributionDbResponse.getOperationalEnvId();
+
+ // ServiceModel, Query for dbRequestId, recoveryAction, retryCountString
+ this.queryServiceModelResponse = modelStatusRepository.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId());
+ this.origRequestId = this.queryServiceModelResponse.getRequestId();
+
+ processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse, distributionStatusRepository, modelStatusRepository);
+
+ // After EVERY status processed, need to query the status of all service modelId
+ // to determine the OVERALL status if "COMPLETE" or "FAILURE":
+ checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId, modelStatusRepository);
+
+ }
+
+ /**
+ * The Method to process the Activation Status from SDC
+ * @param sdcDistributionId - string
+ * @param sdcStatus - Distribution object
+ * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object
+ * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object
+ * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object
+ * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
+ * @return void - nothing
+ */
+ public void processActivateSDCStatus(String sdcDistributionId, Distribution sdcStatus, OperationalEnvDistributionStatus queryDistributionDbResponse,
+ OperationalEnvServiceModelStatus queryServiceModelResponse, OperationalEnvDistributionStatusRepository distributionStatusRepository,
+ OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException {
+
+ String sdcStatusValue = sdcStatus.getStatus().toString();
+ String recoveryAction = queryServiceModelResponse.getRecoveryAction();
+ int retryCount = queryServiceModelResponse.getRetryCount();
+
+ // Validate/process status
+ if (sdcStatus.getStatus().toString().equals(DISTRIBUTION_STATUS_OK)) {
+ // should update 1 row, update status to "DISTRIBUTION_COMPLETE_OK"
+ OperationalEnvDistributionStatus updateDistStatusOk =
+ dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse,
+ sdcStatusValue,
+ "");
+ distributionStatusRepository.save(updateDistStatusOk);
+ // should update 1 row, update status and retryCount = 0 (ie, serviceModelVersionId is DONE!)
+ OperationalEnvServiceModelStatus updateRetryCountZeroAndStatusOk =
+ dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse,
+ sdcStatusValue,
+ RETRY_COUNT_ZERO);
+ modelStatusRepository.save(updateRetryCountZeroAndStatusOk);
+ } else {
+
+ // "DISTRIBUTION_COMPLETE_ERROR", Check if recoveryAction is "RETRY"
+ if (recoveryAction.equals(RECOVERY_ACTION_RETRY) && retryCount > RETRY_COUNT_ZERO) {
+
+ // RESEND / RETRY serviceModelVersionId to SDC
+
+ JSONObject jsonResponse = callSDClientForRetry(queryDistributionDbResponse, queryServiceModelResponse, sdcStatus,
+ distributionStatusRepository, modelStatusRepository);
+
+ } else { // either RETRY & Count = 0, or 'ABORT', or 'SKIP'
+
+ if (recoveryAction.equals(RECOVERY_ACTION_SKIP) || recoveryAction.equals(RECOVERY_ACTION_ABORT)) {
+ String modifiedStatus = "";
+ String errorReason = "";
+ if (recoveryAction.equals(RECOVERY_ACTION_SKIP)) { // considered SUCCESS
+ modifiedStatus = DISTRIBUTION_STATUS_OK;
+ } else {
+ if (recoveryAction.equals(RECOVERY_ACTION_ABORT)) {
+ modifiedStatus = DISTRIBUTION_STATUS_ERROR; // ABORT, error
+ errorReason = ERROR_REASON_ABORTED;
+ }
+ }
+
+ sdcStatusValue = modifiedStatus;
+ // should update 1 row, modified status & retryCount set 0
+ OperationalEnvServiceModelStatus updateRetryCountZeroAndStatus =
+ dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse,
+ modifiedStatus,
+ RETRY_COUNT_ZERO);
+ modelStatusRepository.save(updateRetryCountZeroAndStatus);
+ // should update 1 row, modified status
+ OperationalEnvDistributionStatus updateDistStatus =
+ dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse,
+ modifiedStatus,
+ errorReason);
+ distributionStatusRepository.save(updateDistStatus);
+ } else {
+ // RETRY & Count = 0 (do nothing!)
+ }
+ }
+ }
+ }
+
+ /**
+ * The Method to call SDC for recoveryActioin RETRY
+ * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object
+ * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object
+ * @param sdcStatus - Distribution object
+ * @param distributionStatusRepository - OperationalEnvDistributionStatusRepository object
+ * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
+ * @return JSONObject object
+ */
+ public JSONObject callSDClientForRetry(OperationalEnvDistributionStatus queryDistributionDbResponse,
+ OperationalEnvServiceModelStatus queryServiceModelResponse,
+ Distribution sdcStatus,
+ OperationalEnvDistributionStatusRepository distributionStatusRepository,
+ OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException {
+
+ JSONObject jsonResponse = null;
+
+ String operEnvironmentId = queryDistributionDbResponse.getOperationalEnvId();
+ String serviceModelVersionId = queryDistributionDbResponse.getServiceModelVersionId();
+ String originalRequestId = queryServiceModelResponse.getRequestId();
+ int retryCount = queryServiceModelResponse.getRetryCount();
+ String workloadContext = queryServiceModelResponse.getWorkloadContext();
+
+
+ jsonResponse = sdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operEnvironmentId, workloadContext);
+ String statusCode = jsonResponse.get("statusCode").toString();
+ if (statusCode.equals(String.valueOf(Response.Status.ACCEPTED.getStatusCode()))) {
+ String newDistributionId = jsonResponse.get("distributionId").toString();
+ // should insert 1 row, NEW distributionId for replacement of the serviceModelServiceId record
+ OperationalEnvDistributionStatus insertNewDistributionId =
+ dbHelper.insertRecordToOperationalEnvDistributionStatus(newDistributionId,
+ operEnvironmentId,
+ serviceModelVersionId,
+ originalRequestId,
+ DISTRIBUTION_STATUS_SENT,
+ "");
+ distributionStatusRepository.save(insertNewDistributionId);
+
+ // update retryCount (less 1) for the serviceModelServiceId
+ retryCount = retryCount - 1;
+ // should update 1 row, original insert
+ OperationalEnvServiceModelStatus updateRetryCountAndStatus =
+ dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse,
+ DISTRIBUTION_STATUS_SENT,
+ retryCount);
+ modelStatusRepository.save(updateRetryCountAndStatus);
+
+ // should update 1 row, OLD distributionId set to status error (ie, old distributionId is DONE!).
+ OperationalEnvDistributionStatus updateStatus =
+ dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse,
+ DISTRIBUTION_STATUS_ERROR,
+ sdcStatus.getErrorReason());
+ distributionStatusRepository.save(updateStatus);
+ } else {
+ String dbErrorMessage = "Failure calling SDC: statusCode: " + statusCode +
+ "; messageId: " + jsonResponse.get("messageId") +
+ "; message: " + jsonResponse.get("message");
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
+ ValidateException validateException = new ValidateException.Builder(dbErrorMessage,
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+ requestDb.updateInfraFailureCompletion(dbErrorMessage, this.origRequestId, operEnvironmentId);
+ throw validateException;
+ }
+
+ return jsonResponse;
+
+ }
+
+
+ /**
+ * The Method to check the overall status of the Activation for an operationalEnvironmentId
+ * @param operationalEnvironmentId - string
+ * @param origRequestId - string
+ * @param modelStatusRepository - OperationalEnvServiceModelStatusRepository object
+ * @return void - nothing
+ */
+ public void checkOrUpdateOverallStatus(String operationalEnvironmentId, String origRequestId, OperationalEnvServiceModelStatusRepository modelStatusRepository) throws ApiException{
+
+ List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = modelStatusRepository.findAllByOperationalEnvIdAndRequestId(operationalEnvironmentId, origRequestId);
+
+ String status = "Waiting";
+ int count = 0;
+ // loop through the statuses of the service model
+ for (OperationalEnvServiceModelStatus querySrvModelResponse : queryServiceModelResponseList) {
+ status = querySrvModelResponse.getServiceModelVersionDistrStatus();
+ // all should be OK to be completed.
+ if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString()) &&
+ (querySrvModelResponse.getRetryCount() == 0))) {
+ status = "Completed";
+ count ++;
+ }
+ // one error with zero retry, means all are failures.
+ if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString()) &&
+ (querySrvModelResponse.getRetryCount() == 0))) {
+ status = "Failure";
+ count = queryServiceModelResponseList.size();
+ break;
+ }
+ }
+
+ if (status.equals("Completed") && queryServiceModelResponseList.size() == count) {
+ String messageStatus = "Overall Activation process is complete. " + status;
+ requestDb.updateInfraSuccessCompletion(messageStatus, origRequestId, operationalEnvironmentId);
+ } else {
+ if (status.equals("Failure") && queryServiceModelResponseList.size() == count) {
+ this.errorMessage = "Overall Activation process is a Failure. " + status;
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build();
+ ValidateException validateException = new ValidateException.Builder(this.errorMessage,
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+ requestDb.updateInfraFailureCompletion(this.errorMessage, origRequestId, operationalEnvironmentId);
+ throw validateException;
+ }
+
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java
new file mode 100644
index 0000000000..c16f7bb9ef
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.process;
+
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolation.dmaap.DmaapOperationalEnvClient;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.RequestsDBHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CreateEcompOperationalEnvironment {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CreateEcompOperationalEnvironment.class);
+
+ @Autowired
+ private AAIClientObjectBuilder aaiClientObjectBuilder;
+ @Autowired
+ private AAIClientHelper aaiHelper;
+ @Autowired
+ private RequestsDBHelper requestDb;
+ @Autowired
+ private DmaapOperationalEnvClient dmaapClient;
+
+ public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{
+
+ //Create ECOMP Managing Environment object in A&AI
+ aaiHelper.createOperationalEnvironment(aaiClientObjectBuilder.buildAAIOperationalEnvironment("ACTIVE", request));
+
+ // Call client to publish to DMaap
+ try {
+ msoLogger.debug("1" + request.getOperationalEnvironmentId());
+ msoLogger.debug("2" + request.getRequestDetails().getRequestInfo().getInstanceName());
+ msoLogger.debug("3" + request.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString());
+ msoLogger.debug("4" + request.getRequestDetails().getRequestParameters().getTenantContext());
+ msoLogger.debug("5" + request.getRequestDetails().getRequestParameters().getWorkloadContext());
+
+
+ dmaapClient.dmaapPublishOperationalEnvRequest(request.getOperationalEnvironmentId(),
+ request.getRequestDetails().getRequestInfo().getInstanceName(),
+ request.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString(),
+ request.getRequestDetails().getRequestParameters().getTenantContext(),
+ request.getRequestDetails().getRequestParameters().getWorkloadContext(),
+ "Create");
+ }catch(Exception e){
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build();
+ ValidateException validateException = new ValidateException.Builder("Could not publish DMaap", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ requestDb.updateInfraFailureCompletion(e.getMessage(), requestId, request.getOperationalEnvironmentId());
+ throw validateException;
+ }
+ //Update request database
+ requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, request.getOperationalEnvironmentId());
+
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
index a235526887..e95db6b188 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
@@ -7,9 +7,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.
@@ -18,96 +18,116 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
+package org.onap.so.apihandlerinfra.tenantisolation.process;
import java.util.ArrayList;
import java.util.List;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RelatedInstanceList;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.client.grm.GRMClient;
-import org.openecomp.mso.client.grm.beans.OperationalInfo;
-import org.openecomp.mso.client.grm.beans.Property;
-import org.openecomp.mso.client.grm.beans.ServiceEndPoint;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointList;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointRequest;
-import org.openecomp.mso.client.grm.beans.Version;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
+import javax.ws.rs.NotFoundException;
+
import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder;
+import org.onap.so.apihandlerinfra.tenantisolationbeans.RelatedInstanceList;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
+import org.onap.so.client.grm.GRMClient;
+import org.onap.so.client.grm.beans.OperationalInfo;
+import org.onap.so.client.grm.beans.Property;
+import org.onap.so.client.grm.beans.ServiceEndPoint;
+import org.onap.so.client.grm.beans.ServiceEndPointList;
+import org.onap.so.client.grm.beans.ServiceEndPointRequest;
+import org.onap.so.client.grm.beans.Version;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.RequestsDBHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class CreateVnfOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "CreateVnfOperationalEnvironment";
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private ObjectMapper mapper = new ObjectMapper();
- private GRMClient grmClient;
-
- public CreateVnfOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- }
-
-
- @Override
- public void execute() {
- try {
- msoLogger.debug("Begin of execute method in " + SERVICE_NAME);
- //Retrieve ECOMP Managing environment info in A&AI
- AAIResultWrapper aaiResultWrapper = getAaiHelper().getAaiOperationalEnvironment(getEcompManagingEnvironmentId());
- AAIOperationalEnvironment aaiEnv = mapper.readValue(aaiResultWrapper.getJson(), AAIOperationalEnvironment.class);
+@Component
+public class CreateVnfOperationalEnvironment {
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CreateVnfOperationalEnvironment.class);
+ protected CloudOrchestrationRequest request;
+
+ @Autowired
+ private AAIClientObjectBuilder aaiClientObjectBuilder;
+ @Autowired
+ private AAIClientHelper aaiHelper;
+ @Autowired
+ private RequestsDBHelper requestDb;
+ private GRMClient grmClient;
+
+ public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{
+ try {
+ setRequest(request);
+ ObjectMapper objectMapper = new ObjectMapper();
+ AAIResultWrapper aaiResultWrapper = aaiHelper.getAaiOperationalEnvironment(getEcompManagingEnvironmentId());
+ if (aaiResultWrapper.isEmpty()) {
+ throw new NotFoundException(getEcompManagingEnvironmentId() + " not found in A&AI");
+ }
+ AAIOperationalEnvironment aaiEnv = objectMapper.readValue(aaiResultWrapper.getJson(), AAIOperationalEnvironment.class);
+
//Find ECOMP environments in GRM
msoLogger.debug(" Start of GRM findRunningServicesAsString");
String searchKey = getSearchKey(aaiEnv);
String tenantContext = getTenantContext().toUpperCase();
- String jsonResponse = getGRMClient().findRunningServicesAsString(searchKey, 1, tenantContext);
- ServiceEndPointList sel = getObjectMapper().readValue(jsonResponse, ServiceEndPointList.class);
+ String jsonResponse = getGrmClient().findRunningServicesAsString(searchKey, 1, tenantContext);
+ ServiceEndPointList sel = objectMapper.readValue(jsonResponse, ServiceEndPointList.class);
if(sel.getServiceEndPointList().size() == 0) {
throw new TenantIsolationException("GRM did not find any matches for " + searchKey + " in " + tenantContext);
}
+
//Replicate end-point for VNF Operating environment in GRM
List<ServiceEndPointRequest> serviceEndpointRequestList = buildEndPointRequestList(sel);
int ctr = 0;
int total = serviceEndpointRequestList.size();
- for(ServiceEndPointRequest request : serviceEndpointRequestList) {
- msoLogger.debug("Creating endpoint " + ++ctr + " of " + total + ": " + request.getServiceEndPoint().getName());
- getGRMClient().addServiceEndPoint(request);
+ for (ServiceEndPointRequest requestList : serviceEndpointRequestList) {
+ msoLogger.debug("Creating endpoint " + ++ctr + " of " + total + ": " + requestList.getServiceEndPoint().getName());
+ getGrmClient().addServiceEndPoint(requestList);
}
-
+
//Create VNF operating in A&AI
- getAaiHelper().createOperationalEnvironment(getAaiClientObjectBuilder().buildAAIOperationalEnvironment("INACTIVE"));
- getAaiHelper().createRelationship(getRequest().getOperationalEnvironmentId(), getEcompManagingEnvironmentId());
-
+ aaiHelper.createOperationalEnvironment(aaiClientObjectBuilder.buildAAIOperationalEnvironment("INACTIVE", request));
+ aaiHelper.createRelationship(request.getOperationalEnvironmentId(), getEcompManagingEnvironmentId());
+
//Update request database
- getRequestDb().updateInfraSuccessCompletion("SUCCESSFULLY created VNF operational environment", getRequestId(), getRequest().getOperationalEnvironmentId());
- }
- catch(Exception e) {
- msoLogger.error(MessageEnum.APIH_GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.DataError, e.getMessage());
- getRequestDb().updateInfraFailureCompletion(e.getMessage(), requestId, getRequest().getOperationalEnvironmentId());
+ requestDb.updateInfraSuccessCompletion("SUCCESSFULLY created VNF operational environment", requestId, request.getOperationalEnvironmentId());
+
+ }catch(Exception e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build();
+
+
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(),
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build();
+
+ throw validateException;
}
}
protected String getEcompManagingEnvironmentId() throws TenantIsolationException {
- RelatedInstanceList[] relatedInstances = getRequest().getRequestDetails().getRelatedInstanceList();
+ RelatedInstanceList[] relatedInstances = request.getRequestDetails().getRelatedInstanceList();
if (relatedInstances.length > 0 && relatedInstances[0].getRelatedInstance() != null) {
return relatedInstances[0].getRelatedInstance().getInstanceId();
} else {
- throw new TenantIsolationException("Unable to get Managing ECOMP Environment ID, request related instance list is empty!");
+ return null;
}
}
protected String getTenantContext() throws TenantIsolationException {
- if(!StringUtils.isEmpty(getRequest().getRequestDetails().getRequestParameters().getTenantContext())) {
- return getRequest().getRequestDetails().getRequestParameters().getTenantContext();
+ if(!StringUtils.isEmpty(request.getRequestDetails().getRequestParameters().getTenantContext())) {
+ return request.getRequestDetails().getRequestParameters().getTenantContext();
}
else {
throw new TenantIsolationException("Tenant Context is missing from request!");
@@ -135,8 +155,8 @@ public class CreateVnfOperationalEnvironment extends OperationalEnvironmentProce
ver.setPatch(serviceEndpoint.getVersion().getPatch());
ServiceEndPoint endpoint = new ServiceEndPoint();
- endpoint.setName(buildServiceNameForVnf(serviceEndpoint.getName()));
-
+ endpoint.setName(buildServiceNameForVnf(serviceEndpoint.getName()));
+
endpoint.setVersion(ver);
endpoint.setHostAddress(serviceEndpoint.getHostAddress());
endpoint.setListenPort(serviceEndpoint.getListenPort());
@@ -184,33 +204,24 @@ public class CreateVnfOperationalEnvironment extends OperationalEnvironmentProce
else {
throw new TenantIsolationException("Fully qualified service name is null.");
}
- String tenantContext = getRequest().getRequestDetails().getRequestParameters().getTenantContext();
- String workloadContext = getRequest().getRequestDetails().getRequestParameters().getWorkloadContext();
+ String tenantContext = request.getRequestDetails().getRequestParameters().getTenantContext();
+ String workloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext();
return tenantContext + "." + workloadContext + "." + serviceName;
}
-
- protected GRMClient getGRMClient() {
- if(this.grmClient == null) {
- this.grmClient = new GRMClient();
- }
- return this.grmClient;
- }
-
-
protected String getSearchKey(AAIOperationalEnvironment aaiEnv) {
return aaiEnv.getTenantContext() + "." + aaiEnv.getWorkloadContext() + ".*";
}
-
- protected ObjectMapper getObjectMapper() {
- return mapper;
- }
-
- @Override
- protected String getServiceName() {
- return CreateVnfOperationalEnvironment.SERVICE_NAME;
+ public void setRequest(CloudOrchestrationRequest request) {
+ this.request = request;
+ }
+
+ private GRMClient getGrmClient() {
+ if(grmClient == null) {
+ this.grmClient = new GRMClient();
+ }
+
+ return grmClient;
}
-
-
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
new file mode 100644
index 0000000000..2096011caa
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolation.process;
+
+import java.util.Optional;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpStatus;
+import org.onap.so.apihandler.common.ErrorNumbers;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
+import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.objects.AAIOperationalEnvironment;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.requestsdb.RequestsDBHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DeactivateVnfOperationalEnvironment {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, DeactivateVnfOperationalEnvironment.class);
+
+ @Autowired
+ private AAIClientHelper aaiHelper;
+ @Autowired
+ private RequestsDBHelper requestDb;
+
+ public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException {
+ String operationalEnvironmentId = request.getOperationalEnvironmentId();
+
+ AAIOperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId);
+ if (aaiOpEnv != null) {
+ String operationalEnvironmentStatus = aaiOpEnv.getOperationalEnvironmentStatus();
+
+ if(StringUtils.isBlank(operationalEnvironmentStatus)) {
+ String error = "OperationalEnvironmentStatus is null on OperationalEnvironmentId: " + operationalEnvironmentId;
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build();
+ throw new ValidateException.Builder(error, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo)
+ .build();
+ }
+
+ if(operationalEnvironmentStatus.equalsIgnoreCase("ACTIVE")) {
+
+ aaiOpEnv.setOperationalEnvironmentStatus("INACTIVE");
+ aaiHelper.updateAaiOperationalEnvironment(operationalEnvironmentId, aaiOpEnv);
+
+ } else if(!operationalEnvironmentStatus.equalsIgnoreCase("INACTIVE")) {
+ String error = "Invalid OperationalEnvironmentStatus on OperationalEnvironmentId: " + operationalEnvironmentId;
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build();
+ ValidateException validateException = new ValidateException.Builder(error,
+ HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
+ requestDb.updateInfraFailureCompletion(error, requestId, operationalEnvironmentId);
+ throw validateException;
+ }
+
+ requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Deactivated OperationalEnvironment", requestId, operationalEnvironmentId);
+ }
+ }
+
+ private AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
+ AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
+ Optional<AAIOperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(AAIOperationalEnvironment.class);
+ return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Action.java
index 381fed4661..3f7a5536f3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Action.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Action.java
@@ -7,9 +7,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.
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-public enum Action {
- create,
- activate,
- deactivate,
- distributionStatus
-} \ No newline at end of file
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+public enum Action {
+ create,
+ activate,
+ deactivate,
+ distributionStatus
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java
index 586843fc4d..25c8538003 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java
@@ -7,9 +7,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.
@@ -18,20 +18,20 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.util.List;
-
-public class CloudOrchestrationRequestList {
-
- private List<CloudOrchestrationResponse> requestList;
-
- public List<CloudOrchestrationResponse> getRequestList() {
- return requestList;
- }
-
- public void setRequestList(List<CloudOrchestrationResponse> requestList) {
- this.requestList = requestList;
- }
-
-}
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.util.List;
+
+public class CloudOrchestrationRequestList {
+
+ private List<CloudOrchestrationResponse> requestList;
+
+ public List<CloudOrchestrationResponse> getRequestList() {
+ return requestList;
+ }
+
+ public void setRequestList(List<CloudOrchestrationResponse> requestList) {
+ this.requestList = requestList;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java
index 8c8d4011a3..bd5167c395 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java
@@ -1,38 +1,38 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-@JsonInclude(Include.NON_DEFAULT)
-public class CloudOrchestrationResponse {
-
- protected Request request;
-
- public Request getRequest() {
- return request;
- }
-
- public void setRequest(Request request) {
- this.request = request;
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+@JsonInclude(Include.NON_DEFAULT)
+public class CloudOrchestrationResponse {
+
+ protected Request request;
+
+ public Request getRequest() {
+ return request;
+ }
+
+ public void setRequest(Request request) {
+ this.request = request;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Distribution.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Distribution.java
index 99da235154..b556178427 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Distribution.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Distribution.java
@@ -7,9 +7,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.
@@ -18,27 +18,33 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-public class Distribution {
-
- private Status status;
- private String errorReason;
-
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-
- public String getErrorReason() {
- return errorReason;
- }
-
- public void setErrorReason(String errorReason) {
- this.errorReason = errorReason;
- }
-
-}
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+public class Distribution implements Serializable{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -529289171571892371L;
+ private Status status;
+ private String errorReason;
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ public String getErrorReason() {
+ return errorReason;
+ }
+
+ public void setErrorReason(String errorReason) {
+ this.errorReason = errorReason;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/DistributionStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/DistributionStatus.java
index fbf6db0582..d54c6238ae 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/DistributionStatus.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/DistributionStatus.java
@@ -7,9 +7,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.
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-public enum DistributionStatus {
- DISTRIBUTION_COMPLETE_OK,
- DISTRIBUTION_COMPLETE_ERROR
-} \ No newline at end of file
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+public enum DistributionStatus {
+ DISTRIBUTION_COMPLETE_OK,
+ DISTRIBUTION_COMPLETE_ERROR
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/InstanceReferences.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/InstanceReferences.java
index 481e5dac2e..097660d9f3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/InstanceReferences.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/InstanceReferences.java
@@ -1,60 +1,60 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "instanceReferences")
-@JsonInclude(Include.NON_DEFAULT)
-public class InstanceReferences {
-
- private String operationalEnvironmentId;
- private String operationalEnvName;
- private String requestorId;
-
- public String getOperationalEnvironmentId() {
- return operationalEnvironmentId;
- }
-
- public void setOperationalEnvironmentId(String operationalEnvironmentId) {
- this.operationalEnvironmentId = operationalEnvironmentId;
- }
-
- public String getOperationalEnvName() {
- return operationalEnvName;
- }
-
- public void setOperationalEnvName(String operationalEnvName) {
- this.operationalEnvName = operationalEnvName;
- }
-
- public String getRequestorId() {
- return requestorId;
- }
-
- public void setRequestorId(String requestorId) {
- this.requestorId = requestorId;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "instanceReferences")
+@JsonInclude(Include.NON_DEFAULT)
+public class InstanceReferences {
+
+ private String operationalEnvironmentId;
+ private String operationalEnvName;
+ private String requestorId;
+
+ public String getOperationalEnvironmentId() {
+ return operationalEnvironmentId;
+ }
+
+ public void setOperationalEnvironmentId(String operationalEnvironmentId) {
+ this.operationalEnvironmentId = operationalEnvironmentId;
+ }
+
+ public String getOperationalEnvName() {
+ return operationalEnvName;
+ }
+
+ public void setOperationalEnvName(String operationalEnvName) {
+ this.operationalEnvName = operationalEnvName;
+ }
+
+ public String getRequestorId() {
+ return requestorId;
+ }
+
+ public void setRequestorId(String requestorId) {
+ this.requestorId = requestorId;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Manifest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Manifest.java
index 1805672101..afb9ebdff3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Manifest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Manifest.java
@@ -7,9 +7,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.
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
import java.io.Serializable;
import java.util.ArrayList;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java
index 8a377132e4..61acc9f94c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java
@@ -7,9 +7,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.
@@ -18,10 +18,10 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-public enum OperationalEnvironment {
-
- ECOMP,
- VNF
-} \ No newline at end of file
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+public enum OperationalEnvironment {
+
+ ECOMP,
+ VNF
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RecoveryAction.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RecoveryAction.java
index 5d0fca542a..f32c11f8a8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RecoveryAction.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RecoveryAction.java
@@ -7,9 +7,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.
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-public enum RecoveryAction {
-
- retry,
- abort,
- skip
-} \ No newline at end of file
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+public enum RecoveryAction {
+
+ retry,
+ abort,
+ skip
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RelatedInstance.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstance.java
index 34d879053e..78faea7b8e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RelatedInstance.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstance.java
@@ -1,68 +1,68 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "relatedInstance")
-@JsonInclude(Include.NON_DEFAULT)
-public class RelatedInstance implements Serializable {
-
- private static final long serialVersionUID = -6775477105573153067L;
- @JsonProperty("instanceName")
- protected String instanceName;
- @JsonProperty("instanceId")
- protected String instanceId;
- @JsonProperty("resourceType")
- protected ResourceType resourceType;
-
- public String getInstanceName() {
- return instanceName;
- }
- public void setInstanceName(String instanceName) {
- this.instanceName = instanceName;
- }
- public String getInstanceId() {
- return instanceId;
- }
- public void setInstanceId(String instanceId) {
- this.instanceId = instanceId;
- }
- public ResourceType getResourceType() {
- return resourceType;
- }
- public void setResourceType(ResourceType resourceType) {
- this.resourceType = resourceType;
- }
-
- @Override
- public String toString() {
- return "RelatedInstance [instanceName=" + instanceName +
- ", instanceId=" + instanceId +
- ", resourceType=" + resourceType + "]";
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "relatedInstance")
+@JsonInclude(Include.NON_DEFAULT)
+public class RelatedInstance implements Serializable {
+
+ private static final long serialVersionUID = -6775477105573153067L;
+ @JsonProperty("instanceName")
+ protected String instanceName;
+ @JsonProperty("instanceId")
+ protected String instanceId;
+ @JsonProperty("resourceType")
+ protected ResourceType resourceType;
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+ public String getInstanceId() {
+ return instanceId;
+ }
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+ public void setResourceType(ResourceType resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ @Override
+ public String toString() {
+ return "RelatedInstance [instanceName=" + instanceName +
+ ", instanceId=" + instanceId +
+ ", resourceType=" + resourceType + "]";
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java
index a9eee24b50..ee54392e9d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java
@@ -1,45 +1,45 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "relatedInstanceList")
-@JsonInclude(Include.NON_DEFAULT)
-public class RelatedInstanceList implements Serializable {
-
- private static final long serialVersionUID = 1758713583807257102L;
- @JsonProperty("relatedInstance")
- protected RelatedInstance relatedInstance;
-
- public RelatedInstance getRelatedInstance() {
- return relatedInstance;
- }
-
- public void setRelatedInstance(RelatedInstance relatedInstance) {
- this.relatedInstance = relatedInstance;
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "relatedInstanceList")
+@JsonInclude(Include.NON_DEFAULT)
+public class RelatedInstanceList implements Serializable {
+
+ private static final long serialVersionUID = 1758713583807257102L;
+ @JsonProperty("relatedInstance")
+ protected RelatedInstance relatedInstance;
+
+ public RelatedInstance getRelatedInstance() {
+ return relatedInstance;
+ }
+
+ public void setRelatedInstance(RelatedInstance relatedInstance) {
+ this.relatedInstance = relatedInstance;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Request.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Request.java
index 364080d8aa..7d927512e6 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Request.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Request.java
@@ -1,90 +1,90 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-
-@JsonRootName(value = "request")
-@JsonInclude(Include.NON_DEFAULT)
-public class Request {
-
- protected String requestId;
- protected String startTime;
- protected InstanceReferences instanceReferences;
- protected String requestScope;
- protected String requestType;
- protected RequestDetails requestDetails;
- protected RequestStatus requestStatus;
-
-
- public String getRequestId() {
- return requestId;
- }
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- public String getStartTime() {
- return startTime;
- }
- public void setStartTime(String startTime) {
- this.startTime = startTime;
- }
-
- public String getRequestScope() {
- return requestScope;
- }
- public void setRequestScope(String requestScope) {
- this.requestScope = requestScope;
- }
-
- public String getRequestType() {
- return requestType;
- }
- public void setRequestType(String requestType) {
- this.requestType = requestType;
- }
-
- public RequestStatus getRequestStatus() {
- return requestStatus;
- }
- public void setRequestStatus(RequestStatus requestStatus) {
- this.requestStatus = requestStatus;
- }
-
- public InstanceReferences getInstanceReferences() {
- return instanceReferences;
- }
- public void setInstanceReferences(InstanceReferences instanceReferences) {
- this.instanceReferences = instanceReferences;
- }
-
- public RequestDetails getRequestDetails() {
- return requestDetails;
- }
- public void setRequestDetails(RequestDetails requestDetails) {
- this.requestDetails = requestDetails;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+
+@JsonRootName(value = "request")
+@JsonInclude(Include.NON_DEFAULT)
+public class Request {
+
+ protected String requestId;
+ protected String startTime;
+ protected InstanceReferences instanceReferences;
+ protected String requestScope;
+ protected String requestType;
+ protected RequestDetails requestDetails;
+ protected RequestStatus requestStatus;
+
+
+ public String getRequestId() {
+ return requestId;
+ }
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getStartTime() {
+ return startTime;
+ }
+ public void setStartTime(String startTime) {
+ this.startTime = startTime;
+ }
+
+ public String getRequestScope() {
+ return requestScope;
+ }
+ public void setRequestScope(String requestScope) {
+ this.requestScope = requestScope;
+ }
+
+ public String getRequestType() {
+ return requestType;
+ }
+ public void setRequestType(String requestType) {
+ this.requestType = requestType;
+ }
+
+ public RequestStatus getRequestStatus() {
+ return requestStatus;
+ }
+ public void setRequestStatus(RequestStatus requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+ public InstanceReferences getInstanceReferences() {
+ return instanceReferences;
+ }
+ public void setInstanceReferences(InstanceReferences instanceReferences) {
+ this.instanceReferences = instanceReferences;
+ }
+
+ public RequestDetails getRequestDetails() {
+ return requestDetails;
+ }
+ public void setRequestDetails(RequestDetails requestDetails) {
+ this.requestDetails = requestDetails;
+ }
+
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestDetails.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestDetails.java
index 3faa53ac63..36e3bf95e7 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestDetails.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestDetails.java
@@ -1,104 +1,104 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-import java.util.Arrays;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "requestDetails")
-@JsonInclude(Include.NON_DEFAULT)
-public class RequestDetails implements Serializable {
-
- private static final long serialVersionUID = -73080684945860609L;
- @JsonProperty("requestInfo")
- protected RequestInfo requestInfo;
- @JsonProperty("relatedInstanceList")
- protected RelatedInstanceList[] relatedInstanceList;
- @JsonProperty("requestParameters")
- protected RequestParameters requestParameters;
-
- /**
- * Gets the value of the requestInfo property.
- *
- * @return
- * possible object is
- * {@link RequestInfo }
- *
- */
- public RequestInfo getRequestInfo() {
- return requestInfo;
- }
-
- /**
- * Sets the value of the requestInfo property.
- *
- * @param value
- * allowed object is
- * {@link RequestInfo }
- *
- */
- public void setRequestInfo(RequestInfo value) {
- this.requestInfo = value;
- }
-
- /**
- * Gets the value of the requestParameters property.
- *
- * @return
- * possible object is
- * {@link RequestParameters }
- *
- */
- public RequestParameters getRequestParameters() {
- return requestParameters;
- }
-
- /**
- * Sets the value of the requestParameters property.
- *
- * @param value
- * allowed object is
- * {@link RequestParameters }
- *
- */
- public void setRequestParameters(RequestParameters value) {
- this.requestParameters = value;
- }
-
- public RelatedInstanceList[] getRelatedInstanceList() {
- return relatedInstanceList;
- }
-
- public void setRelatedInstanceList(RelatedInstanceList[] relatedInstanceList) {
- this.relatedInstanceList = relatedInstanceList;
- }
- @Override
- public String toString() {
- return "RequestDetails [requestInfo=" + requestInfo +
- ", relatedInstanceList=" + Arrays.toString(relatedInstanceList) +
- ", requestParameters=" + requestParameters + "]";
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "requestDetails")
+@JsonInclude(Include.NON_DEFAULT)
+public class RequestDetails implements Serializable {
+
+ private static final long serialVersionUID = -73080684945860609L;
+ @JsonProperty("requestInfo")
+ protected RequestInfo requestInfo;
+ @JsonProperty("relatedInstanceList")
+ protected RelatedInstanceList[] relatedInstanceList;
+ @JsonProperty("requestParameters")
+ protected RequestParameters requestParameters;
+
+ /**
+ * Gets the value of the requestInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link RequestInfo }
+ *
+ */
+ public RequestInfo getRequestInfo() {
+ return requestInfo;
+ }
+
+ /**
+ * Sets the value of the requestInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link RequestInfo }
+ *
+ */
+ public void setRequestInfo(RequestInfo value) {
+ this.requestInfo = value;
+ }
+
+ /**
+ * Gets the value of the requestParameters property.
+ *
+ * @return
+ * possible object is
+ * {@link RequestParameters }
+ *
+ */
+ public RequestParameters getRequestParameters() {
+ return requestParameters;
+ }
+
+ /**
+ * Sets the value of the requestParameters property.
+ *
+ * @param value
+ * allowed object is
+ * {@link RequestParameters }
+ *
+ */
+ public void setRequestParameters(RequestParameters value) {
+ this.requestParameters = value;
+ }
+
+ public RelatedInstanceList[] getRelatedInstanceList() {
+ return relatedInstanceList;
+ }
+
+ public void setRelatedInstanceList(RelatedInstanceList[] relatedInstanceList) {
+ this.relatedInstanceList = relatedInstanceList;
+ }
+ @Override
+ public String toString() {
+ return "RequestDetails [requestInfo=" + requestInfo +
+ ", relatedInstanceList=" + Arrays.toString(relatedInstanceList) +
+ ", requestParameters=" + requestParameters + "]";
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestInfo.java
index fdb9a10845..d57d4bf366 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestInfo.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestInfo.java
@@ -1,118 +1,118 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "requestInfo")
-@JsonInclude(Include.NON_DEFAULT)
-public class RequestInfo implements Serializable {
-
- private static final long serialVersionUID = 1346372792555344857L;
- @JsonProperty("resourceType")
- protected ResourceType resourceType;
- @JsonProperty("source")
- protected String source;
- @JsonProperty("instanceName")
- protected String instanceName;
- @JsonProperty("requestorId")
- protected String requestorId;
-
- /**
- * Gets the value of the resourceType property.
- *
- * @return
- * possible object is
- * {@link ResourceType }
- *
- */
- public ResourceType getResourceType() {
- return resourceType;
- }
-
- /**
- * Sets the value of the source property.
- *
- * @param value
- * allowed object is
- * {@link ResourceType }
- *
- */
- public void setResourceType(ResourceType value) {
- this.resourceType = value;
- }
-
-
- /**
- * Gets the value of the source property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getSource() {
- return source;
- }
-
- /**
- * Sets the value of the source property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setSource(String value) {
- this.source = value;
- }
-
- public String getInstanceName() {
- return instanceName;
- }
-
- public void setInstanceName(String instanceName) {
- this.instanceName = instanceName;
- }
-
- public String getRequestorId() {
- return requestorId;
- }
-
- public void setRequestorId(String requestorId) {
- this.requestorId = requestorId;
- }
-
- @Override
- public String toString() {
- return "RequestInfo [source=" + source
- + ", instanceName=" + instanceName
- + ", requestorId=" + requestorId
- + ", resourceType=" + resourceType + "]";
- }
-
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "requestInfo")
+@JsonInclude(Include.NON_DEFAULT)
+public class RequestInfo implements Serializable {
+
+ private static final long serialVersionUID = 1346372792555344857L;
+ @JsonProperty("resourceType")
+ protected ResourceType resourceType;
+ @JsonProperty("source")
+ protected String source;
+ @JsonProperty("instanceName")
+ protected String instanceName;
+ @JsonProperty("requestorId")
+ protected String requestorId;
+
+ /**
+ * Gets the value of the resourceType property.
+ *
+ * @return
+ * possible object is
+ * {@link ResourceType }
+ *
+ */
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ /**
+ * Sets the value of the source property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ResourceType }
+ *
+ */
+ public void setResourceType(ResourceType value) {
+ this.resourceType = value;
+ }
+
+
+ /**
+ * Gets the value of the source property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSource() {
+ return source;
+ }
+
+ /**
+ * Sets the value of the source property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSource(String value) {
+ this.source = value;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+ public String getRequestorId() {
+ return requestorId;
+ }
+
+ public void setRequestorId(String requestorId) {
+ this.requestorId = requestorId;
+ }
+
+ @Override
+ public String toString() {
+ return "RequestInfo [source=" + source
+ + ", instanceName=" + instanceName
+ + ", requestorId=" + requestorId
+ + ", resourceType=" + resourceType + "]";
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestList.java
index b5a1b8a9fb..170b5e7609 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestList.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestList.java
@@ -1,96 +1,93 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-import java.util.Arrays;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "requestDetails")
-@JsonInclude(Include.NON_DEFAULT)
-public class RequestList {
-
-
- @JsonProperty("request")
- protected Request request;
- @JsonProperty("requestStatus")
- protected RequestStatus requestStatus;
-
- /**
- * Gets the value of the request property.
- *
- * @return
- * possible object is
- * {@link Request }
- *
- */
- public Request getRequest() {
- return request;
- }
-
- /**
- * Sets the value of the requestInfo property.
- *
- * @param value
- * allowed object is
- * {@link Request }
- *
- */
- public void setRequest(Request value) {
- this.request = value;
- }
-
- /**
- * Gets the value of the requestStatus property.
- *
- * @return
- * possible object is
- * {@link RequestStatus }
- *
- */
- public RequestStatus getRequestStatus() {
- return requestStatus;
- }
-
-
- /**
- * Sets the value of the requestStatus property.
- *
- * @param value
- * allowed object is
- * {@link RequestStatus }
- *
- */
- public void setRequestStatus(RequestStatus value) {
- this.requestStatus = value;
- }
-
-
- @Override
- public String toString() {
- return "RequestList [request=" + request +
- ", requestStatus=" + requestStatus + "]";
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "requestDetails")
+@JsonInclude(Include.NON_DEFAULT)
+public class RequestList {
+
+
+ @JsonProperty("request")
+ protected Request request;
+ @JsonProperty("requestStatus")
+ protected RequestStatus requestStatus;
+
+ /**
+ * Gets the value of the request property.
+ *
+ * @return
+ * possible object is
+ * {@link Request }
+ *
+ */
+ public Request getRequest() {
+ return request;
+ }
+
+ /**
+ * Sets the value of the requestInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Request }
+ *
+ */
+ public void setRequest(Request value) {
+ this.request = value;
+ }
+
+ /**
+ * Gets the value of the requestStatus property.
+ *
+ * @return
+ * possible object is
+ * {@link RequestStatus }
+ *
+ */
+ public RequestStatus getRequestStatus() {
+ return requestStatus;
+ }
+
+
+ /**
+ * Sets the value of the requestStatus property.
+ *
+ * @param value
+ * allowed object is
+ * {@link RequestStatus }
+ *
+ */
+ public void setRequestStatus(RequestStatus value) {
+ this.requestStatus = value;
+ }
+
+
+ @Override
+ public String toString() {
+ return "RequestList [request=" + request +
+ ", requestStatus=" + requestStatus + "]";
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestParameters.java
index 8164fc5d25..1a12c47d7d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestParameters.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestParameters.java
@@ -1,84 +1,84 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "requestParameters")
-@JsonInclude(Include.NON_DEFAULT)
-public class RequestParameters implements Serializable {
-
- private static final long serialVersionUID = 8530327178156183693L;
- @JsonProperty("operationalEnvironmentType")
- private OperationalEnvironment operationalEnvironmentType;
- @JsonProperty("tenantContext")
- private String tenantContext;
- @JsonProperty("workloadContext")
- private String workloadContext;
- @JsonProperty("manifest")
- private Manifest manifest;
-
- public OperationalEnvironment getOperationalEnvironmentType() {
- return operationalEnvironmentType;
- }
-
- public void setOperationalEnvironmentType(OperationalEnvironment operationalEnvironmentType) {
- this.operationalEnvironmentType = operationalEnvironmentType;
- }
-
- public String getTenantContext() {
- return tenantContext;
- }
-
- public void setTenantContext(String tenantContext) {
- this.tenantContext = tenantContext;
- }
-
- public String getWorkloadContext() {
- return workloadContext;
- }
-
- public void setWorkloadContext(String workloadContext) {
- this.workloadContext = workloadContext;
- }
-
- public Manifest getManifest() {
- return manifest;
- }
-
- public void setManifest(Manifest manifest) {
- this.manifest = manifest;
- }
-
-
- @Override
- public String toString() {
- return "RequestParameters [operationalEnvironmentType=" + operationalEnvironmentType
- + ", tenantContext=" + tenantContext
- + ", workloadContext=" + workloadContext
- + ", manifes=" + manifest +"]";
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "requestParameters")
+@JsonInclude(Include.NON_DEFAULT)
+public class RequestParameters implements Serializable {
+
+ private static final long serialVersionUID = 8530327178156183693L;
+ @JsonProperty("operationalEnvironmentType")
+ private OperationalEnvironment operationalEnvironmentType;
+ @JsonProperty("tenantContext")
+ private String tenantContext;
+ @JsonProperty("workloadContext")
+ private String workloadContext;
+ @JsonProperty("manifest")
+ private Manifest manifest;
+
+ public OperationalEnvironment getOperationalEnvironmentType() {
+ return operationalEnvironmentType;
+ }
+
+ public void setOperationalEnvironmentType(OperationalEnvironment operationalEnvironmentType) {
+ this.operationalEnvironmentType = operationalEnvironmentType;
+ }
+
+ public String getTenantContext() {
+ return tenantContext;
+ }
+
+ public void setTenantContext(String tenantContext) {
+ this.tenantContext = tenantContext;
+ }
+
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ public Manifest getManifest() {
+ return manifest;
+ }
+
+ public void setManifest(Manifest manifest) {
+ this.manifest = manifest;
+ }
+
+
+ @Override
+ public String toString() {
+ return "RequestParameters [operationalEnvironmentType=" + operationalEnvironmentType
+ + ", tenantContext=" + tenantContext
+ + ", workloadContext=" + workloadContext
+ + ", manifes=" + manifest +"]";
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestReferences.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestReferences.java
index 191337cef0..337de3c51d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestReferences.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestReferences.java
@@ -1,96 +1,96 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "requestReferences")
-@JsonInclude(Include.NON_DEFAULT)
-public class RequestReferences implements Serializable {
-
- private static final long serialVersionUID = 5873356773819905368L;
-
- @JsonProperty("requestId")
- protected String requestId;
-
- @JsonProperty("instanceId")
- String instanceId;
-
- /**
- * Gets the value of the requestId property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getRequestId() {
- return requestId;
- }
-
- /**
- * Sets the value of the requestId property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- /**
- * Gets the value of the instanceId property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getInstanceId() {
- return instanceId;
- }
-
- /**
- * Sets the value of the instanceId property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setInstanceId(String instanceId) {
- this.instanceId = instanceId;
- }
-
- @Override
- public String toString() {
- return "RequestReferences [requestId=" + requestId +
- ", instanceId=" + instanceId + "]";
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "requestReferences")
+@JsonInclude(Include.NON_DEFAULT)
+public class RequestReferences implements Serializable {
+
+ private static final long serialVersionUID = 5873356773819905368L;
+
+ @JsonProperty("requestId")
+ protected String requestId;
+
+ @JsonProperty("instanceId")
+ String instanceId;
+
+ /**
+ * Gets the value of the requestId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getRequestId() {
+ return requestId;
+ }
+
+ /**
+ * Sets the value of the requestId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ /**
+ * Gets the value of the instanceId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ /**
+ * Sets the value of the instanceId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ @Override
+ public String toString() {
+ return "RequestReferences [requestId=" + requestId +
+ ", instanceId=" + instanceId + "]";
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java
index 4514b41734..7ef712e124 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/RequestStatus.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java
@@ -1,69 +1,69 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-
-@JsonRootName(value = "requestStatus")
-@JsonInclude(Include.NON_DEFAULT)
-public class RequestStatus implements Serializable {
-
- private static final long serialVersionUID = -1835437975187313144L;
- @JsonProperty("requestState")
- protected String requestState;
- @JsonProperty("statusMessage")
- protected String statusMessage;
- @JsonProperty("percentProgress")
- protected String percentProgress;
- @JsonProperty("timeStamp")
- protected String timeStamp;
-
-
- public String getRequestState() {
- return requestState;
- }
- public void setRequestState(String requestState) {
- this.requestState = requestState;
- }
- public String getStatusMessage() {
- return statusMessage;
- }
- public void setStatusMessage(String statusMessage) {
- this.statusMessage = statusMessage;
- }
- public String getPercentProgress() {
- return percentProgress;
- }
- public void setPercentProgress(String percentProgress) {
- this.percentProgress = percentProgress;
- }
- public String getTimeStamp() {
- return timeStamp;
- }
- public void setTimeStamp(String timeStamp) {
- this.timeStamp = timeStamp;
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "requestStatus")
+@JsonInclude(Include.NON_DEFAULT)
+public class RequestStatus implements Serializable {
+
+ private static final long serialVersionUID = -1835437975187313144L;
+ @JsonProperty("requestState")
+ protected String requestState;
+ @JsonProperty("statusMessage")
+ protected String statusMessage;
+ @JsonProperty("percentProgress")
+ protected String percentProgress;
+ @JsonProperty("timeStamp")
+ protected String timeStamp;
+
+
+ public String getRequestState() {
+ return requestState;
+ }
+ public void setRequestState(String requestState) {
+ this.requestState = requestState;
+ }
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+ public void setStatusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ }
+ public String getPercentProgress() {
+ return percentProgress;
+ }
+ public void setPercentProgress(String percentProgress) {
+ this.percentProgress = percentProgress;
+ }
+ public String getTimeStamp() {
+ return timeStamp;
+ }
+ public void setTimeStamp(String timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/ResourceType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ResourceType.java
index aac0e18641..835c2657d1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/ResourceType.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ResourceType.java
@@ -7,9 +7,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.
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-public enum ResourceType {
-
- operationalEnvironment
-} \ No newline at end of file
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+public enum ResourceType {
+
+ operationalEnvironment
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/ServiceModelList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ServiceModelList.java
index 3ef0779476..4dea3149ad 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/ServiceModelList.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ServiceModelList.java
@@ -1,59 +1,59 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "serviceModelList")
-@JsonInclude(Include.NON_DEFAULT)
-public class ServiceModelList implements Serializable {
-
- private static final long serialVersionUID = 1758713583807257102L;
-
- @JsonProperty("serviceModelVersionId")
- protected String serviceModelVersionId;
- @JsonProperty("recoveryAction")
- protected RecoveryAction recoveryAction;
-
- public String getServiceModelVersionId() {
- return serviceModelVersionId;
- }
- public void setServiceModelVersionId(String serviceModelVersionId) {
- this.serviceModelVersionId = serviceModelVersionId;
- }
- public RecoveryAction getRecoveryAction() {
- return recoveryAction;
- }
- public void setRecoveryAction(RecoveryAction recoveryAction) {
- this.recoveryAction = recoveryAction;
- }
-
- @Override
- public String toString() {
- return "ServiceModelList [serviceModelVersionId=" + serviceModelVersionId + ","
- + "recoveryAction=" + recoveryAction +"]";
- }
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "serviceModelList")
+@JsonInclude(Include.NON_DEFAULT)
+public class ServiceModelList implements Serializable {
+
+ private static final long serialVersionUID = 1758713583807257102L;
+
+ @JsonProperty("serviceModelVersionId")
+ protected String serviceModelVersionId;
+ @JsonProperty("recoveryAction")
+ protected RecoveryAction recoveryAction;
+
+ public String getServiceModelVersionId() {
+ return serviceModelVersionId;
+ }
+ public void setServiceModelVersionId(String serviceModelVersionId) {
+ this.serviceModelVersionId = serviceModelVersionId;
+ }
+ public RecoveryAction getRecoveryAction() {
+ return recoveryAction;
+ }
+ public void setRecoveryAction(RecoveryAction recoveryAction) {
+ this.recoveryAction = recoveryAction;
+ }
+
+ @Override
+ public String toString() {
+ return "ServiceModelList [serviceModelVersionId=" + serviceModelVersionId + ","
+ + "recoveryAction=" + recoveryAction +"]";
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Status.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Status.java
index c7693f5913..a7c6c67395 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/Status.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Status.java
@@ -7,9 +7,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.
@@ -18,9 +18,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-public enum Status {
- DISTRIBUTION_COMPLETE_OK,
- DISTRIBUTION_COMPLETE_ERROR
-}
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+public enum Status {
+ DISTRIBUTION_COMPLETE_OK,
+ DISTRIBUTION_COMPLETE_ERROR
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java
index 10ba3aa9d7..003cb0815a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java
@@ -1,95 +1,95 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "tenantIsolationRequest")
-@JsonInclude(Include.NON_DEFAULT)
-public class TenantIsolationRequest implements Serializable {
-
- private static final long serialVersionUID = -210322298981798607L;
- @JsonProperty("requestId")
- protected String requestId;
- @JsonProperty("startTime")
- protected String startTime;
- @JsonProperty("requestScope")
- protected String requestScope;
- @JsonProperty("requestType")
- protected String requestType;
- @JsonProperty("requestDetails")
- protected RequestDetails requestDetails;
- @JsonProperty("requestStatus")
- protected RequestStatus requestStatus;
-
- public String getRequestId() {
- return requestId;
- }
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
- public String getStartTime() {
- return startTime;
- }
- public void setStartTime(String startTime) {
- this.startTime = startTime;
- }
- public String getRequestScope() {
- return requestScope;
- }
- public void setRequestScope(String requestScope) {
- this.requestScope = requestScope;
- }
- public String getRequestType() {
- return requestType;
- }
- public void setRequestType(String requestType) {
- this.requestType = requestType;
- }
- public RequestStatus getRequestStatus() {
- return requestStatus;
- }
- public void setRequestStatus(RequestStatus requestStatus) {
- this.requestStatus = requestStatus;
- }
-
- public RequestDetails getRequestDetails() {
- return requestDetails;
- }
- public void setRequestDetails(RequestDetails requestDetails) {
- this.requestDetails = requestDetails;
- }
-
- @Override
- public String toString() {
- return "Request [requestId=" + requestId +
- ", startTime=" + startTime +
- ", requestType=" + requestType +
- ", requestDetails=" + requestDetails.toString() +
- ", requestStatus=" + requestStatus.toString() + "]";
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "tenantIsolationRequest")
+@JsonInclude(Include.NON_DEFAULT)
+public class TenantIsolationRequest implements Serializable {
+
+ private static final long serialVersionUID = -210322298981798607L;
+ @JsonProperty("requestId")
+ protected String requestId;
+ @JsonProperty("startTime")
+ protected String startTime;
+ @JsonProperty("requestScope")
+ protected String requestScope;
+ @JsonProperty("requestType")
+ protected String requestType;
+ @JsonProperty("requestDetails")
+ protected RequestDetails requestDetails;
+ @JsonProperty("requestStatus")
+ protected RequestStatus requestStatus;
+
+ public String getRequestId() {
+ return requestId;
+ }
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+ public String getStartTime() {
+ return startTime;
+ }
+ public void setStartTime(String startTime) {
+ this.startTime = startTime;
+ }
+ public String getRequestScope() {
+ return requestScope;
+ }
+ public void setRequestScope(String requestScope) {
+ this.requestScope = requestScope;
+ }
+ public String getRequestType() {
+ return requestType;
+ }
+ public void setRequestType(String requestType) {
+ this.requestType = requestType;
+ }
+ public RequestStatus getRequestStatus() {
+ return requestStatus;
+ }
+ public void setRequestStatus(RequestStatus requestStatus) {
+ this.requestStatus = requestStatus;
+ }
+
+ public RequestDetails getRequestDetails() {
+ return requestDetails;
+ }
+ public void setRequestDetails(RequestDetails requestDetails) {
+ this.requestDetails = requestDetails;
+ }
+
+ @Override
+ public String toString() {
+ return "Request [requestId=" + requestId +
+ ", startTime=" + startTime +
+ ", requestType=" + requestType +
+ ", requestDetails=" + requestDetails.toString() +
+ ", requestStatus=" + requestStatus.toString() + "]";
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java
index 4b1a4541e0..15a0ab840c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java
@@ -1,115 +1,115 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-import java.io.Serializable;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-@JsonRootName(value = "tenantIsolationResponse")
-@JsonInclude(Include.NON_DEFAULT)
-public class TenantIsolationResponse implements Serializable {
-
- private static final long serialVersionUID = 756749312745898666L;
- @JsonProperty("requestId")
- protected String requestId;
- @JsonProperty("status")
- String status;
- @JsonProperty("message")
- String message;
-
- /**
- * Gets the value of the requestId property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getRequestId() {
- return requestId;
- }
-
- /**
- * Sets the value of the requestId property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- /**
- * Gets the value of the status property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getStatus() {
- return status;
- }
-
- /**
- * Sets the value of the status property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setStatus(String status) {
- this.status = status;
- }
-
- /**
- * Gets the value of the message property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the value of the message property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setMessage(String message) {
- this.message = message;
- }
-
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+
+@JsonRootName(value = "tenantIsolationResponse")
+@JsonInclude(Include.NON_DEFAULT)
+public class TenantIsolationResponse implements Serializable {
+
+ private static final long serialVersionUID = 756749312745898666L;
+ @JsonProperty("requestId")
+ protected String requestId;
+ @JsonProperty("status")
+ String status;
+ @JsonProperty("message")
+ String message;
+
+ /**
+ * Gets the value of the requestId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getRequestId() {
+ return requestId;
+ }
+
+ /**
+ * Sets the value of the requestId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ /**
+ * Gets the value of the status property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * Sets the value of the status property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ * Gets the value of the message property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Sets the value of the message property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java
index 45676c5e68..7281e1c708 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java
@@ -7,9 +7,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.
@@ -18,18 +18,18 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
-public class TenantSyncResponse {
-
- private RequestReferences requestReferences;
-
- public RequestReferences getRequestReferences() {
- return requestReferences;
- }
-
- public void setRequestReferences(RequestReferences requestReferences) {
- this.requestReferences = requestReferences;
- }
-
-} \ No newline at end of file
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
+public class TenantSyncResponse {
+
+ private RequestReferences requestReferences;
+
+ public RequestReferences getRequestReferences() {
+ return requestReferences;
+ }
+
+ public void setRequestReferences(RequestReferences requestReferences) {
+ this.requestReferences = requestReferences;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/package-info.java
index 92d203abdd..713a763321 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolationbeans/package-info.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/package-info.java
@@ -1,29 +1,29 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2015.09.03 at 02:02:13 PM EDT
-//
-
-package org.openecomp.mso.apihandlerinfra.tenantisolationbeans;
-
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.09.03 at 02:02:13 PM EDT
+//
+
+package org.onap.so.apihandlerinfra.tenantisolationbeans;
+
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ApplyUpdatedConfigValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ApplyUpdatedConfigValidation.java
new file mode 100644
index 0000000000..243bbf1474
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ApplyUpdatedConfigValidation.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+
+public class ApplyUpdatedConfigValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters();
+ RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo();
+
+ if(requestInfo == null){
+ throw new ValidationException("requestInfo");
+ }else if(empty(requestInfo.getRequestorId())) {
+ throw new ValidationException ("requestorId");
+ }else if (empty (requestInfo.getSource ())) {
+ throw new ValidationException ("source");
+ }
+ if(requestParameters == null){
+ throw new ValidationException("requestParameters");
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
new file mode 100644
index 0000000000..4c7365b187
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.ModelType;
+
+public class CloudConfigurationValidation implements ValidationRule{
+ public boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration();
+ String requestScope = info.getRequestScope();
+ int reqVersion = info.getReqVersion();
+ Actions action = info.getAction();
+ Boolean aLaCarteFlag = info.getALaCarteFlag();
+
+
+ if(cloudConfiguration == null && reqVersion >= 5 && (aLaCarteFlag != null && aLaCarteFlag)){
+ if((!requestScope.equalsIgnoreCase(ModelType.service.name()) && !requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
+ (action == Action.createInstance || action == Action.deleteInstance || action == Action.updateInstance)){
+ throw new ValidationException ("cloudConfiguration");
+ }
+ if((requestScope.equalsIgnoreCase(ModelType.vnf.name()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name())) &&
+ action == Action.replaceInstance){
+ throw new ValidationException ("cloudConfiguration");
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.configuration.name()) &&
+ (action == Action.enablePort || action == Action.disablePort || action == Action.activateInstance || action == Action.deactivateInstance)){
+ throw new ValidationException ("cloudConfiguration");
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.deactivateAndCloudDelete){
+ throw new ValidationException("cloudConfiguration");
+ }
+ }
+
+ if (cloudConfiguration == null && ((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase (ModelType.service.name ()) && reqVersion < 5)) {
+ throw new ValidationException ("cloudConfiguration");
+ }
+
+ if (cloudConfiguration != null) {
+ if (empty (cloudConfiguration.getLcpCloudRegionId ())) {
+ throw new ValidationException ("lcpCloudRegionId");
+ }
+ if (empty (cloudConfiguration.getTenantId ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name()))) {
+ throw new ValidationException ("tenantId");
+ }
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java
new file mode 100644
index 0000000000..afbacb465d
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.CloudConfiguration;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+
+public class InPlaceSoftwareUpdateValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters();
+ CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails ().getCloudConfiguration();
+ RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo();
+
+ if (cloudConfiguration == null) {
+ throw new ValidationException ("cloudConfiguration");
+ }else if (empty (cloudConfiguration.getLcpCloudRegionId ())) {
+ throw new ValidationException ("lcpCloudRegionId");
+ }else if (empty (cloudConfiguration.getTenantId ())) {
+ throw new ValidationException ("tenantId");
+ }
+ if(requestInfo == null){
+ throw new ValidationException("requestInfo");
+ }else if(empty(requestInfo.getRequestorId())) {
+ throw new ValidationException ("requestorId");
+ }else if (empty (requestInfo.getSource ())) {
+ throw new ValidationException ("source");
+ }
+ if(requestParameters == null){
+ throw new ValidationException("requestParameters");
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
new file mode 100644
index 0000000000..a42a13c676
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import java.util.HashMap;
+
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.utils.UUIDChecker;
+
+public class InstanceIdMapValidation implements ValidationRule{
+
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ HashMap<String, String> instanceIdMap = info.getInstanceIdMap();
+ ServiceInstancesRequest sir = info.getSir();
+ if(instanceIdMap != null){
+ if(instanceIdMap.get("serviceInstanceId") != null){
+ if (!UUIDChecker.isValidUUID (instanceIdMap.get ("serviceInstanceId"))) {
+ throw new ValidationException ("serviceInstanceId");
+ }
+ sir.setServiceInstanceId(instanceIdMap.get("serviceInstanceId"));
+ }
+
+ if(instanceIdMap.get("vnfInstanceId") != null){
+ if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vnfInstanceId"))) {
+ throw new ValidationException ("vnfInstanceId");
+ }
+ sir.setVnfInstanceId(instanceIdMap.get("vnfInstanceId"));
+ }
+
+ if(instanceIdMap.get("vfModuleInstanceId") != null){
+ if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vfModuleInstanceId"))) {
+ throw new ValidationException ("vfModuleInstanceId");
+ }
+ sir.setVfModuleInstanceId(instanceIdMap.get("vfModuleInstanceId"));
+ }
+
+ if(instanceIdMap.get("volumeGroupInstanceId") != null){
+ if (!UUIDChecker.isValidUUID (instanceIdMap.get ("volumeGroupInstanceId"))) {
+ throw new ValidationException ("volumeGroupInstanceId");
+ }
+ sir.setVolumeGroupInstanceId(instanceIdMap.get("volumeGroupInstanceId"));
+ }
+
+ if(instanceIdMap.get("networkInstanceId") != null){
+ if (!UUIDChecker.isValidUUID (instanceIdMap.get ("networkInstanceId"))) {
+ throw new ValidationException ("networkInstanceId");
+ }
+ sir.setNetworkInstanceId(instanceIdMap.get("networkInstanceId"));
+ }
+
+ if(instanceIdMap.get("configurationInstanceId") != null){
+ if (!UUIDChecker.isValidUUID (instanceIdMap.get ("configurationInstanceId"))) {
+ throw new ValidationException ("configurationInstanceId");
+ }
+ sir.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
+ }
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
new file mode 100644
index 0000000000..8ab7fccdff
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.utils.UUIDChecker;
+public class ModelInfoValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo();
+ RequestParameters requestParameters = info.getReqParameters();
+ String requestScope = info.getRequestScope();
+ Actions action = info.getAction();
+ int reqVersion = info.getReqVersion();
+ Boolean aLaCarteFlag = info.getALaCarteFlag();
+
+ if(!empty(modelInfo.getModelNameVersionId())){
+ modelInfo.setModelVersionId(modelInfo.getModelNameVersionId());
+ }
+ // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create
+ if(requestParameters != null && reqVersion >= 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.createInstance && !requestParameters.isUsePreload()) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
+ throw new ValidationException("modelCustomizationId");
+ }
+ }
+
+ // modelCustomizationId is required for v5 and higher for VF Module Replace
+ if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.replaceInstance) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
+ throw new ValidationException("modelCustomizationId");
+ }
+ }
+
+ // modelCustomizationId or modelCustomizationName are required for VNF Replace
+ if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) {
+ throw new ValidationException("modelCustomizationId or modelCustomizationName");
+ }
+ }
+
+ //is required for serviceInstance delete macro when aLaCarte=false (v3)
+ //create and updates except for network (except v4)
+ if (empty (modelInfo.getModelInvariantId ()) && ((reqVersion >2 && (aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
+ !(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) &&
+ (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
+ (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
+ throw new ValidationException ("modelInvariantId");
+ }
+
+ if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) {
+ throw new ValidationException ("modelInvariantId format");
+ }
+
+ if(reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance ||
+ action == Action.addRelationships || action == Action.removeRelationships || (action == Action.deleteInstance && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){
+ throw new ValidationException ("modelName");
+ }
+
+ if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
+ (!(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ()))
+ && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships))) {
+ throw new ValidationException ("modelVersion");
+ }
+
+ // is required for serviceInstance delete macro when aLaCarte=false in v4
+ if (reqVersion >= 4 && empty (modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
+ (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
+ (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
+ throw new ValidationException ("modelVersionId");
+ }
+
+ if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) {
+ if (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) {
+ throw new ValidationException ("modelCustomizationId or modelCustomizationName");
+ }
+ }
+
+ if(reqVersion >= 4 && (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) && (requestScope.equalsIgnoreCase (ModelType.network.name ()) || requestScope.equalsIgnoreCase(ModelType.configuration.name()))
+ && (action == Action.updateInstance || action == Action.createInstance)){
+ throw new ValidationException ("modelCustomizationId");
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java
new file mode 100644
index 0000000000..7c51f3e5ce
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.apihandlerinfra.ModelType;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.LineOfBusiness;
+import org.onap.so.serviceinstancebeans.Platform;
+
+public class PlatformLOBValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ int reqVersion = info.getReqVersion();
+ Platform platform;
+ LineOfBusiness lineOfBusiness;
+ String requestScope = info.getRequestScope();
+ Actions action = info.getAction();
+
+ platform = info.getSir().getRequestDetails().getPlatform();
+ lineOfBusiness = info.getSir().getRequestDetails().getLineOfBusiness();
+ if(reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.createInstance){
+ if(reqVersion > 5 && platform == null) {
+ throw new ValidationException("platform");
+ }
+ if(platform != null && empty(platform.getPlatformName())){
+ throw new ValidationException("platformName");
+ }
+ if(lineOfBusiness != null && empty(lineOfBusiness.getLineOfBusinessName())){
+ throw new ValidationException("lineOfBusinessName");
+ }
+ }
+ info.setPlatform(platform);
+ info.setLOB(lineOfBusiness);
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java
new file mode 100644
index 0000000000..f6a3c03555
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.apihandlerinfra.ModelType;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.OwningEntity;
+import org.onap.so.serviceinstancebeans.Project;
+
+public class ProjectOwningEntityValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ int reqVersion = info.getReqVersion();
+ Project project;
+ OwningEntity owningEntity;
+ String requestScope = info.getRequestScope();
+ Actions action = info.getAction();
+
+ project = info.getSir().getRequestDetails().getProject();
+ owningEntity = info.getSir().getRequestDetails().getOwningEntity();
+ if(reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance || action == Action.assignInstance){
+ if(reqVersion > 5 && owningEntity == null) {
+ throw new ValidationException("owningEntity");
+ }
+ if(owningEntity != null && empty(owningEntity.getOwningEntityId())){
+ throw new ValidationException("owningEntityId");
+ }
+ if(project != null && empty(project.getProjectName())){
+ throw new ValidationException("projectName");
+ }
+ }
+ info.setProject(project);
+ info.setOE(owningEntity);
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
new file mode 100644
index 0000000000..096b30939b
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java
@@ -0,0 +1,232 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.logger.MsoLogger;
+import org.onap.so.serviceinstancebeans.InstanceDirection;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.RelatedInstanceList;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.onap.so.utils.UUIDChecker;
+
+public class RelatedInstancesValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ ServiceInstancesRequest sir = info.getSir();
+ Actions action = info.getAction();
+ int reqVersion = info.getReqVersion();
+ String requestScope = info.getRequestScope();
+ String serviceInstanceType = null;
+ String networkType = null;
+ String vnfType = null;
+ String vfModuleType = null;
+ String vfModuleModelName = null;
+ ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo();
+ MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, RelatedInstancesValidation.class);
+ RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
+ String serviceModelName = null;
+ String vnfModelName = null;
+ String asdcServiceModelVersion = null;
+ String volumeGroupId = null;
+ boolean isRelatedServiceInstancePresent = false;
+ boolean isRelatedVnfInstancePresent = false;
+ boolean isSourceVnfPresent = false;
+ boolean isDestinationVnfPresent = false;
+ boolean isConnectionPointPresent = false;
+
+ if(requestScope.equalsIgnoreCase(ModelType.service.name())){
+ serviceInstanceType = modelInfo.getModelName();
+ info.setServiceInstanceType(serviceInstanceType);
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.network.name())){
+ networkType = modelInfo.getModelName();
+ info.setNetworkType(networkType);
+ }
+ if (instanceList != null) {
+ for(RelatedInstanceList relatedInstanceList : instanceList){
+ RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
+
+ ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo ();
+ if (relatedInstanceModelInfo == null) {
+ throw new ValidationException ("modelInfo in relatedInstance");
+ }
+
+ if (relatedInstanceModelInfo.getModelType () == null) {
+ throw new ValidationException ("modelType in relatedInstance");
+ }
+
+ if(empty(relatedInstance.getInstanceName ()) && ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) {
+ throw new ValidationException ("instanceName in relatedInstance for pnf modelType");
+ }
+
+ if (!empty (relatedInstance.getInstanceName ())) {
+ if (!relatedInstance.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) {
+ throw new ValidationException ("instanceName format in relatedInstance");
+ }
+ }
+
+ if (empty (relatedInstance.getInstanceId ()) && !ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) {
+ throw new ValidationException ("instanceId in relatedInstance");
+ }
+
+ if (!empty(relatedInstance.getInstanceId ()) && !UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) {
+ throw new ValidationException ("instanceId format in relatedInstance");
+ }
+
+
+ if (action != Action.deleteInstance) {
+ if(!( relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup) ||
+ relatedInstanceModelInfo.getModelType().equals(ModelType.connectionPoint) ||
+ relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) ||
+ relatedInstanceModelInfo.getModelType().equals(ModelType.networkCollection))) {
+
+ if(empty (relatedInstanceModelInfo.getModelInvariantId ())) {
+ throw new ValidationException ("modelInvariantId in relatedInstance");
+ } else if(reqVersion >= 4 && empty(relatedInstanceModelInfo.getModelVersionId ())) {
+ throw new ValidationException("modelVersionId in relatedInstance");
+ } else if(empty(relatedInstanceModelInfo.getModelName ())) {
+ throw new ValidationException ("modelName in relatedInstance");
+ } else if (empty (relatedInstanceModelInfo.getModelVersion ())) {
+ throw new ValidationException ("modelVersion in relatedInstance");
+ }
+ }
+
+ if (!empty (relatedInstanceModelInfo.getModelInvariantId ()) &&
+ !UUIDChecker.isValidUUID (relatedInstanceModelInfo.getModelInvariantId ())) {
+ throw new ValidationException ("modelInvariantId format in relatedInstance");
+ }
+
+ if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) {
+ isSourceVnfPresent = true;
+ } else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) &&
+ (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) && reqVersion == 6))) {
+ isDestinationVnfPresent = true;
+ }
+ }
+
+ if(ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ isConnectionPointPresent = true;
+ }
+ }
+
+ if (empty (relatedInstanceModelInfo.getModelCustomizationName ()) && relatedInstanceModelInfo.getModelType ().equals (ModelType.vnf) ) {
+ if(reqVersion >=4 && empty (relatedInstanceModelInfo.getModelCustomizationId()) && action != Action.deleteInstance) {
+ throw new ValidationException ("modelCustomizationName or modelCustomizationId in relatedInstance of vnf");
+ }
+ }
+
+ if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
+ isRelatedServiceInstancePresent = true;
+ if (!relatedInstance.getInstanceId ().equals (sir.getServiceInstanceId ())) {
+ throw new ValidationException ("serviceInstanceId matching the serviceInstanceId in request URI");
+ }
+ serviceModelName = relatedInstanceModelInfo.getModelName ();
+ asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion ();
+ } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) {
+ isRelatedVnfInstancePresent = true;
+ if (!relatedInstance.getInstanceId ().equals (sir.getVnfInstanceId ())) {
+ throw new ValidationException ("vnfInstanceId matching the vnfInstanceId in request URI");
+ }
+ vnfModelName = relatedInstanceModelInfo.getModelCustomizationName();
+ } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) {
+ volumeGroupId = relatedInstance.getInstanceId ();
+ }
+ }
+
+ if(action == Action.createInstance && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ if(!isSourceVnfPresent) {
+ throw new ValidationException ("source vnf relatedInstance for Port Configuration");
+ }
+
+ if(!isDestinationVnfPresent) {
+ throw new ValidationException ("destination vnf relatedInstance for Port Configuration");
+ }
+ }
+
+ if((action == Action.enablePort || action == Action.disablePort) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
+ if(!isConnectionPointPresent) {
+ throw new ValidationException ("connectionPoint relatedInstance for Port Configuration");
+ }
+ }
+
+ if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) {
+ if (!isRelatedServiceInstancePresent) {
+ throw new ValidationException ("related service instance for volumeGroup request");
+ }
+ if (!isRelatedVnfInstancePresent) {
+ throw new ValidationException ("related vnf instance for volumeGroup request");
+ }
+ serviceInstanceType = serviceModelName;
+ vnfType = serviceModelName + "/" + vnfModelName;
+ info.setServiceInstanceType(serviceInstanceType);
+ info.setVnfType(vnfType);
+ }
+ else if(requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) {
+ if (!isRelatedServiceInstancePresent) {
+ throw new ValidationException ("related service instance for vfModule request");
+ }
+ if (!isRelatedVnfInstancePresent) {
+ throw new ValidationException ("related vnf instance for vfModule request");
+ }
+ vfModuleModelName = modelInfo.getModelName ();
+ serviceInstanceType = serviceModelName;
+ vnfType = serviceModelName + "/" + vnfModelName;
+ vfModuleType = vnfType + "::" + vfModuleModelName;
+ sir.setVolumeGroupInstanceId (volumeGroupId);
+ info.setVfModuleModelName(vfModuleModelName);
+ info.setVnfType(vnfType);
+ info.setServiceInstanceType(serviceInstanceType);
+ info.setVfModuleType(vfModuleType);
+ }
+ else if (requestScope.equalsIgnoreCase (ModelType.vnf.name ())) {
+ if (!isRelatedServiceInstancePresent) {
+ throw new ValidationException ("related service instance for vnf request");
+ }
+ vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName();
+ info.setVnfType(vnfType);
+ }
+ }
+ else if ((( requestScope.equalsIgnoreCase(ModelType.vnf.name ()) || requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())
+ || requestScope.equalsIgnoreCase(ModelType.configuration.name())) && (action == Action.createInstance || action == Action.enablePort || action == Action.disablePort)) ||
+ (reqVersion >= 4 && (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) && action == Action.updateInstance) ||
+ (requestScope.equalsIgnoreCase(ModelType.service.name()) && (action.equals(Action.addRelationships) || action.equals(Action.removeRelationships)))){
+ msoLogger.debug ("related instance exception");
+ throw new ValidationException ("related instances");
+ }
+ info.setVfModuleModelName(vfModuleModelName);
+ info.setServiceInstanceType(serviceInstanceType);
+ info.setVnfType(vnfType);
+ info.setAsdcServiceModelVersion(asdcServiceModelVersion);
+ info.setVfModuleType(vfModuleType);
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestInfoValidation.java
new file mode 100644
index 0000000000..bdc9649ecc
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestInfoValidation.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.apihandlerinfra.Constants;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+
+public class RequestInfoValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo();
+ int reqVersion = info.getReqVersion();
+ String requestScope = info.getRequestScope();
+ Actions action = info.getAction();
+ Boolean aLaCarteFlag = info.getALaCarteFlag();
+
+ //required for all operations in V4
+ if(empty(requestInfo.getRequestorId()) && reqVersion >= 4) {
+ throw new ValidationException ("requestorId");
+ }
+
+ if (empty (requestInfo.getSource ())) {
+ throw new ValidationException ("source");
+ }
+ if (!empty (requestInfo.getInstanceName ())) {
+ if (!requestInfo.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) {
+ throw new ValidationException ("instanceName format");
+ }
+ }
+ if (empty (requestInfo.getProductFamilyId ())) {
+ // Mandatory for vnf Create(aLaCarte=true), Network Create(aLaCarte=true) and network update
+ //Mandatory for macro request create service instance
+ if((requestScope.equalsIgnoreCase (ModelType.vnf.name ()) && action == Action.createInstance) ||
+ (requestScope.equalsIgnoreCase (ModelType.network.name ()) && (action == Action.createInstance || action == Action.updateInstance)) ||
+ (reqVersion > 3 && (aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance)) {
+ throw new ValidationException ("productFamilyId");
+ }
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java
new file mode 100644
index 0000000000..c717999fbd
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import java.util.Map;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+
+public class RequestParametersValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ int reqVersion = info.getReqVersion();
+ String requestScope = info.getRequestScope();
+ Actions action = info.getAction();
+ RequestParameters requestParameters = info.getReqParameters();
+
+ if (requestScope.equalsIgnoreCase(ModelType.service.name()) && (action == Action.createInstance || action == Action.assignInstance)) {
+ if (requestParameters == null) {
+ throw new ValidationException ("requestParameters");
+ }
+ if (empty (requestParameters.getSubscriptionServiceType())) {
+ throw new ValidationException ("subscriptionServiceType");
+ }
+ }
+ if(reqVersion >= 4){
+ if(Action.addRelationships.equals(action) || Action.removeRelationships.equals(action)) {
+ if(requestParameters == null || requestParameters.getALaCarte() == null) {
+ throw new ValidationException ("aLaCarte in requestParameters");
+ }
+ }
+ }
+ if(requestParameters == null && !requestScope.equalsIgnoreCase(ModelType.service.name())){
+ info.setALaCarteFlag(true);
+ }
+ if(requestParameters != null){
+ if(requestScope.equalsIgnoreCase(ModelType.vnf.name())){
+ if(action == Action.updateInstance){
+ if(requestParameters.isUsePreload() == null){
+ requestParameters.setUsePreload(true);
+ }
+ }
+ if(action == Action.replaceInstance){
+ if(requestParameters.getRebuildVolumeGroups() == null){
+ requestParameters.setRebuildVolumeGroups(false);
+ }
+ }
+ }
+ if(requestScope.equalsIgnoreCase(ModelType.vfModule.name())){
+ if(action == Action.createInstance || action == Action.updateInstance){
+ if(requestParameters.isUsePreload() == null){
+ requestParameters.setUsePreload(true);
+ }
+ }
+ }
+ if(reqVersion >= 4){
+ if(requestParameters.getALaCarte() != null){
+ info.setALaCarteFlag(requestParameters.getALaCarte());
+ }else if(requestScope.equalsIgnoreCase(ModelType.service.name())){
+ if(action == Action.createInstance || action == Action.deleteInstance || action == Action.activateInstance || action == Action.deactivateInstance){
+ if(requestParameters.getALaCarte() == null){
+ requestParameters.setaLaCarte(false);
+ info.setALaCarteFlag(requestParameters.getALaCarte());
+ }
+ }
+ }else{
+ info.setALaCarteFlag(true);
+ }
+ }else{
+ info.setALaCarteFlag(true);
+ }
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestScopeValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestScopeValidation.java
new file mode 100644
index 0000000000..51a9afe200
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestScopeValidation.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+
+public class RequestScopeValidation implements ValidationRule{
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo();
+ RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo();
+ String requestScope;
+
+ if (modelInfo == null) {
+ throw new ValidationException ("model-info");
+ }
+ if (requestInfo == null) {
+ throw new ValidationException ("requestInfo");
+ }
+ info.setRequestInfo(requestInfo);
+ if (modelInfo.getModelType () == null) {
+ throw new ValidationException ("modelType");
+ }
+ requestScope = info.getSir().getRequestDetails().getModelInfo().getModelType().name();
+ info.setRequestScope(requestScope);
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/SubscriberInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/SubscriberInfoValidation.java
new file mode 100644
index 0000000000..d9298f5f4e
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/SubscriberInfoValidation.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.ModelType;
+import org.onap.so.serviceinstancebeans.SubscriberInfo;
+
+public class SubscriberInfoValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ String requestScope = info.getRequestScope();
+ int reqVersion = info.getReqVersion();
+ Actions action = info.getAction();
+
+ if (reqVersion > 4 && requestScope.equalsIgnoreCase (ModelType.service.name ()) && action == Action.createInstance || action == Action.assignInstance) {
+ SubscriberInfo subscriberInfo = info.getSir().getRequestDetails ().getSubscriberInfo();
+ if (subscriberInfo == null) {
+ throw new ValidationException ("subscriberInfo");
+ }
+ if (empty (subscriberInfo.getGlobalSubscriberId ())) {
+ throw new ValidationException ("globalSubscriberId");
+ }
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java
new file mode 100644
index 0000000000..da1f1f6e90
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.Networks;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.VfModules;
+import org.onap.so.serviceinstancebeans.Vnfs;
+
+public class UserParamsValidation implements ValidationRule{
+ private static boolean empty(String s) {
+ return (s == null || s.trim().isEmpty());
+ }
+ @Override
+ public ValidationInformation validate(ValidationInformation info) throws ValidationException{
+ Service validate = info.getUserParams();
+ Actions action = info.getAction();
+
+ if(validate.getModelInfo() == null){
+ throw new ValidationException ("model-info in userParams");
+ }else if(validate.getModelInfo().getModelVersionId() == null){
+ throw new ValidationException("modelVersionId in userParams");
+ }
+ for(Vnfs vnf : validate.getResources().getVnfs()){
+ if(vnf.getModelInfo() == null){
+ throw new ValidationException ("model-info in userParams vnf resources");
+ }else if(vnf.getModelInfo().getModelCustomizationId() == null){
+ throw new ValidationException ("modelCustomizationId in userParams vnf resources");
+ }else if(vnf.getModelInfo().getModelVersionId() == null){
+ throw new ValidationException("modelVersionId in userParams vnf resources");
+ }
+ if(vnf.getCloudConfiguration() == null){
+ throw new ValidationException ("cloudConfiguration in userParams vnf resources");
+ }
+ if(action == Action.createInstance || action == Action.assignInstance){
+ if(vnf.getPlatform() == null){
+ throw new ValidationException ("platform in userParams vnf resources");
+ }if(vnf.getProductFamilyId() == null){
+ throw new ValidationException ("productFamilyId in userParams vnf resources");
+ }
+ }
+ if (vnf.getPlatform() != null && vnf.getPlatform().getPlatformName() == null){
+ throw new ValidationException ("platformName in userParams vnf resources");
+ }
+ if(vnf.getVfModules().isEmpty()){
+ throw new ValidationException ("vfModules in userParams vnf resources");
+ }
+ for(VfModules vfModules : vnf.getVfModules()){
+ if(vfModules.getModelInfo() == null){
+ throw new ValidationException ("model-info in userParams vfModules resources");
+ }else if(vfModules.getModelInfo().getModelCustomizationId() == null){
+ throw new ValidationException ("modelCustomizationId in userParams vfModule resources");
+ }else if(vfModules.getModelInfo().getModelVersionId() == null){
+ throw new ValidationException("modelVersionId in userParams vfModule resources");
+ }
+ }
+ }
+
+ List<Networks> validateNetworks = new ArrayList<>();
+ validateNetworks = validate.getResources().getNetworks();
+ if(validateNetworks != null){
+ for(Networks networks : validateNetworks){
+ if(networks.getModelInfo() == null){
+ throw new ValidationException ("model-info in userParams network resources");
+ }else if(networks.getModelInfo().getModelCustomizationId() == null){
+ throw new ValidationException ("modelCustomizationId in userParams network resources");
+ }else if(networks.getModelInfo().getModelVersionId() == null){
+ throw new ValidationException("modelVersionId in userParams network resources");
+ }
+ if(networks.getCloudConfiguration() == null){
+ throw new ValidationException ("cloudConfiguration in userParams network resources");
+ }
+ }
+ }
+ return info;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java
new file mode 100644
index 0000000000..7fc9567123
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java
@@ -0,0 +1,180 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import java.util.HashMap;
+
+import org.onap.so.apihandlerinfra.Actions;
+import org.onap.so.serviceinstancebeans.LineOfBusiness;
+import org.onap.so.serviceinstancebeans.OwningEntity;
+import org.onap.so.serviceinstancebeans.Platform;
+import org.onap.so.serviceinstancebeans.Project;
+import org.onap.so.serviceinstancebeans.RequestInfo;
+import org.onap.so.serviceinstancebeans.RequestParameters;
+import org.onap.so.serviceinstancebeans.Service;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+
+public class ValidationInformation{
+ ServiceInstancesRequest sir;
+ HashMap<String,String> instanceIdMap;
+ Actions action;
+ int reqVersion;
+ String requestScope;
+ Boolean aLaCarteFlag;
+ RequestParameters requestParameters;
+ RequestInfo requestInfo;
+ String serviceInstanceType;
+ String vfModuleModelName;
+ String vnfType;
+ String asdcServiceModelVersion;
+ String vfModuleType;
+ String networkType;
+ Platform platform;
+ LineOfBusiness lob;
+ Project project;
+ OwningEntity owningEntity;
+ Service userParams;
+
+ public ValidationInformation(ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap,
+ Actions action, int reqVersion, Boolean aLaCarteFlag, RequestParameters requestParameters){
+ this.sir = sir;
+ this.instanceIdMap = instanceIdMap;
+ this.action = action;
+ this.reqVersion = reqVersion;
+ this.aLaCarteFlag = aLaCarteFlag;
+ this.requestParameters = requestParameters;
+ }
+ public ServiceInstancesRequest getSir(){
+ return this.sir;
+ }
+ public void setSir(ServiceInstancesRequest value){
+ this.sir = value;
+ }
+ public HashMap<String, String> getInstanceIdMap(){
+ return this.instanceIdMap;
+ }
+ public void setInstanceIdMap(HashMap<String, String> value){
+ this.instanceIdMap = value;
+ }
+ public Actions getAction(){
+ return this.action;
+ }
+ public void setAction(Actions value){
+ this.action = value;
+ }
+ public RequestInfo getRequestInfo(){
+ return this.requestInfo;
+ }
+ public void setRequestInfo(RequestInfo value){
+ this.requestInfo = value;
+ }
+ public int getReqVersion(){
+ return this.reqVersion;
+ }
+ public void setReqVersion(int value){
+ this.reqVersion = value;
+ }
+ public String getRequestScope(){
+ return this.requestScope;
+ }
+ public void setRequestScope(String value){
+ this.requestScope = value;
+ }
+ public Boolean getALaCarteFlag(){
+ return this.aLaCarteFlag;
+ }
+ public void setALaCarteFlag(Boolean value){
+ this.aLaCarteFlag = value;
+ }
+ public RequestParameters getReqParameters(){
+ return this.requestParameters;
+ }
+ public void setReqParameters(RequestParameters value){
+ this.requestParameters = value;
+ }
+ public String getServiceInstanceType(){
+ return this.serviceInstanceType;
+ }
+ public void setServiceInstanceType(String value){
+ this.serviceInstanceType = value;
+ }
+ public String getVfModuleModelName(){
+ return this.vfModuleModelName;
+ }
+ public void setVfModuleModelName(String value){
+ this.vfModuleModelName = value;
+ }
+ public String getVnfType(){
+ return this.vnfType;
+ }
+ public void setVnfType(String value){
+ this.vnfType = value;
+ }
+ public String getAsdcServiceModelVersion(){
+ return this.asdcServiceModelVersion;
+ }
+ public void setAsdcServiceModelVersion(String value){
+ this.asdcServiceModelVersion = value;
+ }
+ public String getVfModuleType(){
+ return this.vfModuleType;
+ }
+ public void setVfModuleType(String value){
+ this.vfModuleType = value;
+ }
+ public String getNetworkType(){
+ return this.networkType;
+ }
+ public void setNetworkType(String value){
+ this.networkType = value;
+ }
+ public Platform getPlatform(){
+ return this.platform;
+ }
+ public void setPlatform(Platform value){
+ this.platform = value;
+ }
+ public LineOfBusiness getLOB(){
+ return this.lob;
+ }
+ public void setLOB(LineOfBusiness value){
+ this.lob = value;
+ }
+ public Project getProject(){
+ return this.project;
+ }
+ public void setProject(Project value){
+ this.project = value;
+ }
+ public OwningEntity getOE(){
+ return this.owningEntity;
+ }
+ public void setOE(OwningEntity value){
+ this.owningEntity = value;
+ }
+ public Service getUserParams(){
+ return this.userParams;
+ }
+ public void setUserParams(Service value){
+ this.userParams = value;
+ }
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationRule.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationRule.java
new file mode 100644
index 0000000000..a5d85f6533
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationRule.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.validation;
+
+import org.onap.so.exceptions.ValidationException;
+
+public interface ValidationRule{
+ ValidationInformation validate(ValidationInformation info)throws ValidationException;
+} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ActionType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ActionType.java
index 2a43658a65..15fe0a5be3 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ActionType.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ActionType.java
@@ -26,7 +26,7 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import javax.xml.bind.annotation.XmlEnum;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ModelType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java
index e3830b0c13..3f708c49d5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ModelType.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java
@@ -1,32 +1,32 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
-
-/*
- * Enum for Status values returned by API Handler to Tail-F
-*/
-public enum ModelType {
- service,
- vnf,
- vfModule,
- volumeGroup,
- network
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.apihandlerinfra.vnfbeans;
+
+/*
+ * Enum for Status values returned by API Handler to Tail-F
+*/
+public enum ModelType {
+ service,
+ vnf,
+ vfModule,
+ volumeGroup,
+ network
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ObjectFactory.java
index e77257c596..72be61105b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ObjectFactory.java
@@ -26,7 +26,7 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import javax.xml.bind.JAXBElement;
@@ -38,7 +38,7 @@ import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
- * generated in the org.openecomp.mso.apihandlerinfra.vnfbeans1 package.
+ * generated in the org.onap.so.apihandlerinfra.vnfbeans1 package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
@@ -52,11 +52,11 @@ import javax.xml.namespace.QName;
@XmlRegistry
public class ObjectFactory {
- private final static QName _VnfParams_QNAME = new QName("http://org.openecomp/mso/infra/vnf-request/v1", "vnf-params");
- private final static QName _NetworkParams_QNAME = new QName("http://org.openecomp/mso/infra/vnf-request/v1", "network-params");
+ private final static QName _VnfParams_QNAME = new QName("http://org.onap/so/infra/vnf-request/v1", "vnf-params");
+ private final static QName _NetworkParams_QNAME = new QName("http://org.onap/so/infra/vnf-request/v1", "network-params");
/**
- * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.apihandlerinfra.vnfbeans1
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.onap.so.apihandlerinfra.vnfbeans1
*
*/
public ObjectFactory() {
@@ -142,7 +142,7 @@ public class ObjectFactory {
* Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}}
*
*/
- @XmlElementDecl(namespace = "http://org.openecomp/mso/infra/vnf-request/v1", name = "vnf-params")
+ @XmlElementDecl(namespace = "http://org.onap/so/infra/vnf-request/v1", name = "vnf-params")
public JAXBElement<Object> createVnfParams(Object value) {
return new JAXBElement<>(_VnfParams_QNAME, Object.class, null, value);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestInfo.java
index b80ea85dc8..dc8457c6a4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestInfo.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestInfo.java
@@ -7,9 +7,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.
@@ -26,7 +26,7 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import javax.xml.bind.annotation.XmlAccessType;
@@ -47,8 +47,8 @@ import javax.xml.bind.annotation.XmlType;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="request-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
- * &lt;element name="action" type="{http://org.openecomp/mso/infra/vnf-request/v1}action-type"/>
- * &lt;element name="request-status" type="{http://org.openecomp/mso/infra/vnf-request/v1}request-status-type" minOccurs="0"/>
+ * &lt;element name="action" type="{http://org.onap/so/infra/vnf-request/v1}action-type"/>
+ * &lt;element name="request-status" type="{http://org.onap/so/infra/vnf-request/v1}request-status-type" minOccurs="0"/>
* &lt;element name="status-message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="progress" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
* &lt;element name="start-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
@@ -84,7 +84,7 @@ public class RequestInfo {
protected RequestStatusType requestStatus;
@XmlElement(name = "status-message")
protected String statusMessage;
- protected Integer progress;
+ protected String progress;
@XmlElement(name = "start-time")
protected String startTime;
@XmlElement(name = "end-time")
@@ -195,7 +195,7 @@ public class RequestInfo {
* {@link Integer }
*
*/
- public Integer getProgress() {
+ public String getProgress() {
return progress;
}
@@ -207,7 +207,7 @@ public class RequestInfo {
* {@link Integer }
*
*/
- public void setProgress(Integer value) {
+ public void setProgress(String value) {
this.progress = value;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestStatusType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestStatusType.java
index 1e4cdddc4a..8c98b9f801 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestStatusType.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestStatusType.java
@@ -7,9 +7,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.
@@ -26,7 +26,7 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import javax.xml.bind.annotation.XmlEnum;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelName.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelName.java
index a18ef86b58..74065482f8 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelName.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelName.java
@@ -26,7 +26,7 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelNames.java
index 0a841e99a1..9904884620 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelNames.java
@@ -26,11 +26,12 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import java.util.ArrayList;
import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@@ -48,7 +49,7 @@ import javax.xml.bind.annotation.XmlType;
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
- * &lt;element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vf-module-model-name" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element ref="{http://org.onap/so/infra/vnf-request/v1}vf-module-model-name" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
@@ -97,7 +98,7 @@ public class VfModuleModelNames {
}
public void setVfModuleModelName(List<VfModuleModelName> vfModuleModelName) {
- this.vfModuleModelName=vfModuleModelName;
+ this.vfModuleModelName=vfModuleModelName;
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfInputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfInputs.java
index 58f8a5341e..8816d0d4fc 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfInputs.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfInputs.java
@@ -26,7 +26,7 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import javax.xml.bind.annotation.XmlAccessType;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfOutputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfOutputs.java
index 3cd5474182..114a3ae137 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfOutputs.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfOutputs.java
@@ -26,7 +26,7 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import javax.xml.bind.annotation.XmlAccessType;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequest.java
index e989ad257c..07b186e149 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequest.java
@@ -26,7 +26,7 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import javax.xml.bind.annotation.XmlAccessType;
@@ -46,11 +46,11 @@ import javax.xml.bind.annotation.XmlType;
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
- * &lt;element ref="{http://org.openecomp/mso/infra/vnf-request/v1}request-info"/>
+ * &lt;element ref="{http://org.onap/so/infra/vnf-request/v1}request-info"/>
* &lt;sequence>
- * &lt;element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-inputs"/>
- * &lt;element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-params" minOccurs="0"/>
- * &lt;element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-outputs" minOccurs="0"/>
+ * &lt;element ref="{http://org.onap/so/infra/vnf-request/v1}vnf-inputs"/>
+ * &lt;element ref="{http://org.onap/so/infra/vnf-request/v1}vnf-params" minOccurs="0"/>
+ * &lt;element ref="{http://org.onap/so/infra/vnf-request/v1}vnf-outputs" minOccurs="0"/>
* &lt;/sequence>
* &lt;/sequence>
* &lt;/restriction>
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequests.java
index 41ebc7d556..caa0cae84d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequests.java
@@ -26,11 +26,12 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import java.util.ArrayList;
import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@@ -48,7 +49,7 @@ import javax.xml.bind.annotation.XmlType;
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
- * &lt;element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-request" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element ref="{http://org.onap/so/infra/vnf-request/v1}vnf-request" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
@@ -95,9 +96,8 @@ public class VnfRequests {
}
return this.vnfRequest;
}
-
+
public void setVnfRequest(List<VnfRequest> vnfRequest) {
this.vnfRequest=vnfRequest;
}
-
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfType.java
index e303c4e081..dd556a7c34 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfType.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfType.java
@@ -26,7 +26,7 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import javax.xml.bind.annotation.XmlAccessType;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfTypes.java
index 46054e9e65..6728c69172 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfTypes.java
@@ -26,11 +26,12 @@
//
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+package org.onap.so.apihandlerinfra.vnfbeans;
import java.util.ArrayList;
import java.util.List;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@@ -48,7 +49,7 @@ import javax.xml.bind.annotation.XmlType;
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
- * &lt;element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-type" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element ref="{http://org.onap/so/infra/vnf-request/v1}vnf-type" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
@@ -96,8 +97,8 @@ public class VnfTypes {
return this.vnfType;
}
- public void setVnfType(List<VnfType> vnfType) {
- this.vnfType = vnfType;
+ public void setVnfType( List<VnfType> vnfType) {
+ this.vnfType=vnfType;
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/package-info.java
index eb073e2fd0..3eb84299f4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/package-info.java
@@ -25,6 +25,6 @@
// Generated on: 2015.09.03 at 02:02:13 PM EDT
//
-@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/mso/infra/vnf-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
-package org.openecomp.mso.apihandlerinfra.vnfbeans;
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap/so/infra/vnf-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package org.onap.so.apihandlerinfra.vnfbeans;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java
deleted file mode 100644
index 86604b392a..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
-
-import org.openecomp.mso.HealthCheckUtils;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/healthcheck")
-@Api(value="/healthcheck",description="API Handler Infra Health Check")
-public class HealthcheckHandler {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
-
- @HEAD
- @GET
- @Produces("text/html")
- @ApiOperation(value="Perform Health Check",response=Response.class)
- public Response healthcheck (@QueryParam("requestId") String requestId) {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName ("Healthcheck");
- UUIDChecker.verifyOldUUID(requestId, msoLogger);
- HealthCheckUtils healthCheck = new HealthCheckUtils ();
- if (!healthCheck.siteStatusCheck(msoLogger)) {
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
-
- if (!healthCheck.configFileCheck(msoLogger, startTime, Constants.MSO_PROP_APIHANDLER_INFRA)) {
- return HealthCheckUtils.NOT_STARTED_RESPONSE;
- }
-
- if (!healthCheck.requestDBCheck (msoLogger, startTime)) {
- return HealthCheckUtils.NOT_STARTED_RESPONSE;
- }
- msoLogger.debug("healthcheck - Successful");
- return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java
deleted file mode 100644
index e268c65263..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.apihandlerinfra;
-
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoAlarmLogger;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.ApiOperation;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandler.common.RequestClient;
-import org.openecomp.mso.apihandler.common.RequestClientFactory;
-import org.openecomp.mso.apihandler.common.ResponseHandler;
-import org.openecomp.mso.apihandlerinfra.tasksbeans.*;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
-
-@Path("/tasks")
-public class ManualTasks {
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
-
- @POST
- @Path("/{version:[vV]1}/{taskId}/complete")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Complete specified task",response=Response.class)
- public Response completeTask(String request, @PathParam("version") String version, @PathParam("taskId") String taskId) {
-
- String requestId = UUIDChecker.generateUUID(msoLogger);
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("requestId is: " + requestId);
- TasksRequest tr = null;
-
- MsoRequest msoRequest = new MsoRequest (requestId);
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- tr= mapper.readValue(request, TasksRequest.class);
-
- if (tr.getRequestDetails() == null) {
- throw new ValidationException("requestDetails");
- }
- if (tr.getRequestDetails().getRequestInfo() == null) {
- throw new ValidationException("requestInfo");
- }
- if (empty(tr.getRequestDetails().getRequestInfo().getSource())) {
- throw new ValidationException("source");
- }
- if (empty(tr.getRequestDetails().getRequestInfo().getRequestorId())) {
- throw new ValidationException("requestorId");
- }
-
- } catch(Exception e){
- msoLogger.debug ("Mapping of request to JSON object failed : ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
-
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, request, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- // Transform the request to Camunda-style Complete request
- Variables variablesForComplete = new Variables();
- Value sourceValue = new Value();
- sourceValue.setValue(tr.getRequestDetails().getRequestInfo().getSource());
- Value responseValue = new Value();
- responseValue.setValue(tr.getRequestDetails().getRequestInfo().getResponseValue().name());
- Value requestorIdValue = new Value();
- requestorIdValue.setValue(tr.getRequestDetails().getRequestInfo().getRequestorId());
- variablesForComplete.setSource(sourceValue);
- variablesForComplete.setResponseValue(responseValue);
- variablesForComplete.setRequestorId(requestorIdValue);
-
- String camundaJsonReq = null;
- try {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- camundaJsonReq = mapper.writeValueAsString(variablesForComplete);
- msoLogger.debug("Camunda Json Request: " + camundaJsonReq);
- } catch(Exception e){
- msoLogger.debug ("Mapping of JSON object to Camunda request failed : ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
- "Mapping of JSON object to Camunda Request failed. " + e.getMessage(),
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
-
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, request, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Mapping of JSON object to Camunda request failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- RequestClient requestClient = null;
- HttpResponse response = null;
- long subStartTime = System.currentTimeMillis();
- String requestUrl = "/mso/task/" + taskId + "/complete";
- try {
- requestClient = RequestClientFactory.getRequestClient (requestUrl, MsoPropertiesUtils.loadMsoProperties ());
- // Capture audit event
- msoLogger.debug ("MSO API Handler Posting call to Camunda engine for url: " + requestClient.getUrl ());
-
- System.out.println("URL : " + requestClient.getUrl ());
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Mapping of JSON object to Camunda request failed");
-
- response = requestClient.post(camundaJsonReq);
-
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null);
- } catch (Exception e) {
- msoLogger.debug ("Exception:", e);
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException,
- "Failed calling bpmn " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- alarmLogger.sendAlarm ("MsoConfigurationError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
- if (response == null) {
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException,
- "bpelResponse is null",
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
- ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
- int bpelStatus = respHandler.getStatus ();
-
- // BPEL accepted the request, the request is in progress
- if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) {
- msoLogger.debug ("Received good response from Camunda");
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.IN_PROGRESS);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN completed the request");
- TaskRequestReference trr = new TaskRequestReference();
- trr.setTaskId(taskId);
- String completeResp = null;
- try {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- completeResp = mapper.writeValueAsString(trr);
- }
- catch (Exception e) {
- msoLogger.debug("Unable to format response",e);
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
- MsoException.ServiceException,
- "Request Failed due to bad response format" ,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Bad response format");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Bad response format");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
- msoLogger.debug("Response to the caller: " + completeResp);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) completeResp);
- return Response.status (HttpStatus.SC_ACCEPTED).entity (completeResp).build ();
- } else {
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
- MsoException.ServiceException,
- "Request Failed due to BPEL error with HTTP Status= %1" ,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
- }
-
- private static boolean empty(String s) {
- return (s == null || s.trim().isEmpty());
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoPropertiesUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoPropertiesUtils.java
deleted file mode 100644
index 28076b17fe..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoPropertiesUtils.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.apihandlerinfra;
-
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class MsoPropertiesUtils {
-
- private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory ();
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
-
- private static boolean noProperties = true;
-
- public synchronized static MsoJavaProperties loadMsoProperties () {
- MsoJavaProperties msoProperties;
- try {
- msoProperties = msoPropertiesFactory.getMsoJavaProperties (Constants.MSO_PROP_APIHANDLER_INFRA);
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_LOAD_PROPERTIES_FAIL, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Exception when loading MSO Properties", e);
- return null;
- }
-
- if (msoProperties != null && msoProperties.size () > 0) {
- noProperties = false;
- msoLogger.info (MessageEnum.APIH_PROPERTY_LOAD_SUC, "", "");
- return msoProperties;
- } else {
- msoLogger.error (MessageEnum.APIH_NO_PROPERTIES, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "No MSO APIH_INFRA Properties found");
- return null;
- }
- }
-
- public synchronized static final boolean getNoPropertiesState() {
- return noProperties;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
deleted file mode 100644
index 3f6cc35432..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
+++ /dev/null
@@ -1,1186 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.StringTokenizer;
-
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.hibernate.Session;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType;
-import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs;
-import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
-import org.openecomp.mso.serviceinstancebeans.CloudConfiguration;
-import org.openecomp.mso.serviceinstancebeans.InstanceDirection;
-import org.openecomp.mso.serviceinstancebeans.LineOfBusiness;
-import org.openecomp.mso.serviceinstancebeans.ModelInfo;
-import org.openecomp.mso.serviceinstancebeans.ModelType;
-import org.openecomp.mso.serviceinstancebeans.OwningEntity;
-import org.openecomp.mso.serviceinstancebeans.Platform;
-import org.openecomp.mso.serviceinstancebeans.PolicyException;
-import org.openecomp.mso.serviceinstancebeans.Project;
-import org.openecomp.mso.serviceinstancebeans.RelatedInstance;
-import org.openecomp.mso.serviceinstancebeans.RelatedInstanceList;
-import org.openecomp.mso.serviceinstancebeans.RequestError;
-import org.openecomp.mso.serviceinstancebeans.RequestInfo;
-import org.openecomp.mso.serviceinstancebeans.RequestParameters;
-import org.openecomp.mso.serviceinstancebeans.ServiceException;
-import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest;
-import org.openecomp.mso.serviceinstancebeans.SubscriberInfo;
-import org.openecomp.mso.utils.UUIDChecker;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class MsoRequest {
-
- private String requestId;
- private String requestXML;
- private String requestUri;
- private VnfRequest vnfReq;
- private RequestInfo requestInfo;
- private ModelInfo modelInfo;
- private CloudConfiguration cloudConfiguration ;
- private VnfInputs vnfInputs;
- private String vnfParams;
- private Action action;
- private String errorMessage;
- private String errorCode;
- private String httpResponse;
- private String responseBody;
- private String originalRequestJSON;
- private RequestStatusType status;
- private ServiceInstancesRequest sir;
- private long startTime;
- private long progress = Constants.PROGRESS_REQUEST_RECEIVED;
- private String serviceInstanceType;
- private String vnfType;
- private String vfModuleType;
- private String vfModuleModelName;
- private String networkType;
- private String asdcServiceModelVersion;
- private String requestScope;
- private int reqVersion;
- private boolean aLaCarteFlag;
- private Platform platform;
- private LineOfBusiness lineOfBusiness;
- private Project project;
- private OwningEntity owningEntity;
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager ();
-
- MsoRequest (String requestId) {
- this.requestId = requestId;
- this.startTime = System.currentTimeMillis();
- MsoLogger.setLogContext (requestId, null);
-
- }
-
- MsoRequest () {
-
- this.startTime = System.currentTimeMillis();
- MsoLogger.setLogContext (requestId, null);
-
- }
-
-
- public Response buildServiceErrorResponse (int httpResponseCode,
- MsoException exceptionType,
- String text,
- String messageId,
- List<String> variables) {
-
- this.errorCode = messageId;
-
- if (text != null) {
- this.errorMessage = text;
- }
- else {
- this.errorMessage = "";
- }
- this.httpResponse = Integer.toString(httpResponseCode);
- if(errorMessage.length() > 1999){
- errorMessage = errorMessage.substring(0, 1999);
- }
-
- RequestError re = new RequestError();
-
- if("PolicyException".equals(exceptionType.name())){
-
- PolicyException pe = new PolicyException();
- pe.setMessageId(messageId);
- pe.setText(text);
- if(variables != null){
- for(String variable: variables){
- pe.getVariables().add(variable);
- }
- }
- re.setPolicyException(pe);
-
- } else {
-
- ServiceException se = new ServiceException();
- se.setMessageId(messageId);
- se.setText(text);
- if(variables != null){
- for(String variable: variables){
- se.getVariables().add(variable);
- }
- }
- re.setServiceException(se);
- }
-
- String requestErrorStr = null;
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_DEFAULT);
- requestErrorStr = mapper.writeValueAsString(re);
- }catch(Exception e){
- msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in buildServiceErrorResponse writing exceptionType to string ", e);
- }
-
-
- return Response.status (httpResponseCode).entity(requestErrorStr).build ();
-
- }
-
- private int reqVersionToInt(String version){
- if(version!=null){
- return Integer.parseInt(version.substring(1));
- }else{
- return 0;
- }
- }
-
- // Parse request JSON
- void parse (ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, Action action, String version, String originalRequestJSON) throws ValidationException {
-
- msoLogger.debug ("Validating the Service Instance request");
-
- this.sir = sir;
- this.action = action;
- this.reqVersion = reqVersionToInt(version);
- this.originalRequestJSON = originalRequestJSON;
- msoLogger.debug ("Incoming version is: " + version + " coverting to int: " + this.reqVersion);
-
- if(instanceIdMap != null){
- if(instanceIdMap.get("serviceInstanceId") != null){
- if (!UUIDChecker.isValidUUID (instanceIdMap.get ("serviceInstanceId"))) {
- throw new ValidationException ("serviceInstanceId");
- }
- this.sir.setServiceInstanceId(instanceIdMap.get("serviceInstanceId"));
- }
-
- if(instanceIdMap.get("vnfInstanceId") != null){
- if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vnfInstanceId"))) {
- throw new ValidationException ("vnfInstanceId");
- }
- this.sir.setVnfInstanceId(instanceIdMap.get("vnfInstanceId"));
- }
-
- if(instanceIdMap.get("vfModuleInstanceId") != null){
- if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vfModuleInstanceId"))) {
- throw new ValidationException ("vfModuleInstanceId");
- }
- this.sir.setVfModuleInstanceId(instanceIdMap.get("vfModuleInstanceId"));
- }
-
- if(instanceIdMap.get("volumeGroupInstanceId") != null){
- if (!UUIDChecker.isValidUUID (instanceIdMap.get ("volumeGroupInstanceId"))) {
- throw new ValidationException ("volumeGroupInstanceId");
- }
- this.sir.setVolumeGroupInstanceId(instanceIdMap.get("volumeGroupInstanceId"));
- }
-
- if(instanceIdMap.get("networkInstanceId") != null){
- if (!UUIDChecker.isValidUUID (instanceIdMap.get ("networkInstanceId"))) {
- throw new ValidationException ("networkInstanceId");
- }
- this.sir.setNetworkInstanceId(instanceIdMap.get("networkInstanceId"));
- }
-
- if(instanceIdMap.get("configurationInstanceId") != null){
- if (!UUIDChecker.isValidUUID (instanceIdMap.get ("configurationInstanceId"))) {
- throw new ValidationException ("configurationInstanceId");
- }
- this.sir.setConfigurationId(instanceIdMap.get("configurationInstanceId"));
- }
- }
-
- if(reqVersion >= 6 && (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)){
- parsePayload(sir, action);
- }
- else{
-
- RequestParameters requestParameters = sir.getRequestDetails().getRequestParameters();
-
- this.modelInfo = sir.getRequestDetails().getModelInfo();
-
- if (this.modelInfo == null) {
- throw new ValidationException ("model-info");
- }
-
- this.requestInfo = sir.getRequestDetails().getRequestInfo();
-
- if (this.requestInfo == null) {
- throw new ValidationException ("requestInfo");
- }
-
- if (modelInfo.getModelType () == null) {
- throw new ValidationException ("modelType");
- }
-
- this.requestScope = modelInfo.getModelType().name();
-
- if(this.reqVersion >= 4){
- if(Action.addRelationships.equals(action) || Action.removeRelationships.equals(action)) {
- if(requestParameters == null || requestParameters.getALaCarte() == null) {
- throw new ValidationException ("aLaCarte in requestParameters");
- }
- }
- }
-
- if(requestParameters != null){
- if(requestScope.equalsIgnoreCase(ModelType.vnf.name())){
- if(action == Action.createInstance){
- if(requestParameters.getAutoBuildVfModules() == null){
- requestParameters.setAutoBuildVfModules(false);
- }
- }
- if(action == Action.deleteInstance){
- if(requestParameters.getCascadeDelete() == null){
- requestParameters.setCascadeDelete(false);
- }
- }
- if(action == Action.updateInstance){
- if(requestParameters.isUsePreload() == null){
- requestParameters.setUsePreload(true);
- }
- }
- if(action == Action.replaceInstance){
- if(requestParameters.rebuildVolumeGroups() == null){
- requestParameters.setRebuildVolumeGroups(false);
- }
- }
- }
- if(requestScope.equalsIgnoreCase(ModelType.vfModule.name())){
- if(action == Action.createInstance || action == Action.updateInstance){
- if(requestParameters.isUsePreload() == null){
- requestParameters.setUsePreload(true);
- }
- }
- }
- if(this.reqVersion >= 4){
- if(requestParameters.getALaCarte() != null){
- this.aLaCarteFlag = requestParameters.getALaCarte();
- }
- if(requestScope.equalsIgnoreCase(ModelType.service.name())){
- if(action == Action.createInstance || action == Action.deleteInstance || action == Action.activateInstance || action == Action.deactivateInstance){
- if(requestParameters.getALaCarte() == null){
- requestParameters.setaLaCarte(false);
- this.aLaCarteFlag = requestParameters.getALaCarte();
- }
- }
- }
- }else{
- this.aLaCarteFlag = true;
- }
- }
- if(reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.createInstance){
- parsePlatformAndLineOfBusiness(sir);
- }
- // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create
- if(requestParameters != null && reqVersion >= 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.createInstance && !requestParameters.isUsePreload()) {
- if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
- throw new ValidationException("modelCustomizationId");
- }
- }
-
- // modelCustomizationId is required for v5 and higher for VF Module Replace
- if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.replaceInstance) {
- if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
- throw new ValidationException("modelCustomizationId");
- }
- }
-
- // modelCustomizationId or modelCustomizationName are required for VNF Replace
- if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance) {
- if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) {
- throw new ValidationException("modelCustomizationId or modelCustomizationName");
- }
- }
-
- //is required for serviceInstance delete macro when aLaCarte=false (v3)
- //create and updates except for network (except v4)
- if (empty (modelInfo.getModelInvariantId ()) && ((this.reqVersion >2 && !this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
- !(this.reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) &&
- (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
- (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
- throw new ValidationException ("modelInvariantId");
- }
-
- if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) {
- throw new ValidationException ("modelInvariantId format");
- }
-
- if(this.reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance ||
- action == Action.addRelationships || action == Action.removeRelationships || (action == Action.deleteInstance && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){
- throw new ValidationException ("modelName");
- }
-
- if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) &&
- (!(this.reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ()))
- && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships))) {
- throw new ValidationException ("modelVersion");
- }
-
- // is required for serviceInstance delete macro when aLaCarte=false in v4
- if (this.reqVersion >= 4 && empty (modelInfo.getModelVersionId()) && ((!this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
- (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships ||
- (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) {
- throw new ValidationException ("modelVersionId");
- }
-
- if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) {
- if (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) {
- throw new ValidationException ("modelCustomizationId or modelCustomizationName");
- }
- }
-
- if(this.reqVersion >= 4 && (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) && (requestScope.equalsIgnoreCase (ModelType.network.name ()) || requestScope.equalsIgnoreCase(ModelType.configuration.name()))
- && (action == Action.updateInstance || action == Action.createInstance)){
- throw new ValidationException ("modelCustomizationId");
- }
-
- if(!empty(modelInfo.getModelNameVersionId())){
- modelInfo.setModelVersionId(modelInfo.getModelNameVersionId());
- }
-
- this.cloudConfiguration = sir.getRequestDetails ().getCloudConfiguration ();
- if ( (((!this.aLaCarteFlag && requestScope.equalsIgnoreCase (ModelType.service.name ()) && this.reqVersion < 5) ||
- (!requestScope.equalsIgnoreCase (ModelType.service.name ())) && action != Action.updateInstance))
- && cloudConfiguration == null) {
- throw new ValidationException ("cloudConfiguration");
- }
-
- if (cloudConfiguration != null) {
- if (empty (cloudConfiguration.getLcpCloudRegionId ())) {
- throw new ValidationException ("lcpCloudRegionId");
- }
- if (empty (cloudConfiguration.getTenantId ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name()))) {
- throw new ValidationException ("tenantId");
- }
- }
-
-
- if (requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance) {
- if (requestParameters == null) {
- throw new ValidationException ("requestParameters");
- }
- if (empty (requestParameters.getSubscriptionServiceType())) {
- throw new ValidationException ("subscriptionServiceType");
- }
- }
- if(this.reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance){
- parseProjectAndOwningEntity(sir);
- }
- if (this.reqVersion > 4 && requestScope.equalsIgnoreCase (ModelType.service.name ()) && action == Action.createInstance) {
- SubscriberInfo subscriberInfo = sir.getRequestDetails ().getSubscriberInfo();
- if (subscriberInfo == null) {
- throw new ValidationException ("subscriberInfo");
- }
- if (empty (subscriberInfo.getGlobalSubscriberId ())) {
- throw new ValidationException ("globalSubscriberId");
- }
- }
-
- if(requestScope.equalsIgnoreCase(ModelType.service.name())){
- this.serviceInstanceType = modelInfo.getModelName();
- }
-
- if(requestScope.equalsIgnoreCase(ModelType.network.name())){
- this.networkType = modelInfo.getModelName();
- }
-
- if (!empty (requestInfo.getInstanceName ())) {
- if (!requestInfo.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) {
- throw new ValidationException ("instanceName format");
- }
- }
-
- if (empty (requestInfo.getProductFamilyId ())) {
- // Mandatory for vnf Create(aLaCarte=true), Network Create(aLaCarte=true) and network update
- //Mandatory for macro request create service instance
- if((requestScope.equalsIgnoreCase (ModelType.vnf.name ()) && action == Action.createInstance) ||
- (requestScope.equalsIgnoreCase (ModelType.network.name ()) && (action == Action.createInstance || action == Action.updateInstance)) ||
- (this.reqVersion > 3 && !this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance)) {
- throw new ValidationException ("productFamilyId");
- }
- }
-
- //required for all operations in V4
- if(empty(requestInfo.getRequestorId()) && this.reqVersion >= 4) {
- throw new ValidationException ("requestorId");
- }
-
- if (empty (requestInfo.getSource ())) {
- throw new ValidationException ("source");
- }
-
- RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
-
- String serviceModelName = null;
- String vnfModelName = null;
- String asdcServiceModelVersion = null;
- String volumeGroupId = null;
- boolean isRelatedServiceInstancePresent = false;
- boolean isRelatedVnfInstancePresent = false;
- boolean isSourceVnfPresent = false;
- boolean isDestinationVnfPresent = false;
- boolean isConnectionPointPresent = false;
-
- if (instanceList != null) {
- for(RelatedInstanceList relatedInstanceList : instanceList){
- RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
-
- ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo ();
- if (relatedInstanceModelInfo == null) {
- throw new ValidationException ("modelInfo in relatedInstance");
- }
-
- if (relatedInstanceModelInfo.getModelType () == null) {
- throw new ValidationException ("modelType in relatedInstance");
- }
-
- if(empty(relatedInstance.getInstanceName ()) && ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) {
- throw new ValidationException ("instanceName in relatedInstance for pnf modelType");
- }
-
- if (!empty (relatedInstance.getInstanceName ())) {
- if (!relatedInstance.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) {
- throw new ValidationException ("instanceName format in relatedInstance");
- }
- }
-
- if (empty (relatedInstance.getInstanceId ()) && !ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) {
- throw new ValidationException ("instanceId in relatedInstance");
- }
-
- if (!empty(relatedInstance.getInstanceId ()) && !UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) {
- throw new ValidationException ("instanceId format in relatedInstance");
- }
-
-
- if (action != Action.deleteInstance) {
- if(!( relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup) ||
- relatedInstanceModelInfo.getModelType().equals(ModelType.connectionPoint) ||
- relatedInstanceModelInfo.getModelType().equals(ModelType.pnf))) {
-
- if(empty (relatedInstanceModelInfo.getModelInvariantId ())) {
- throw new ValidationException ("modelInvariantId in relatedInstance");
- } else if(this.reqVersion >= 4 && empty(relatedInstanceModelInfo.getModelVersionId ())) {
- throw new ValidationException("modelVersionId in relatedInstance");
- } else if(empty(relatedInstanceModelInfo.getModelName ())) {
- throw new ValidationException ("modelName in relatedInstance");
- } else if (empty (relatedInstanceModelInfo.getModelVersion ())) {
- throw new ValidationException ("modelVersion in relatedInstance");
- }
- }
-
- if (!empty (relatedInstanceModelInfo.getModelInvariantId ()) &&
- !UUIDChecker.isValidUUID (relatedInstanceModelInfo.getModelInvariantId ())) {
- throw new ValidationException ("modelInvariantId format in relatedInstance");
- }
-
- if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
- if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) {
- isSourceVnfPresent = true;
- } else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) &&
- (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) && this.reqVersion == 6))) {
- isDestinationVnfPresent = true;
- }
- }
-
- if(ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
- isConnectionPointPresent = true;
- }
- }
-
- if (empty (relatedInstanceModelInfo.getModelCustomizationName ()) && relatedInstanceModelInfo.getModelType ().equals (ModelType.vnf) ) {
- if(this.reqVersion >=4 && empty (relatedInstanceModelInfo.getModelCustomizationId()) && action != Action.deleteInstance) {
- throw new ValidationException ("modelCustomizationName or modelCustomizationId in relatedInstance of vnf");
- }
- }
-
- if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
- isRelatedServiceInstancePresent = true;
- if (!relatedInstance.getInstanceId ().equals (this.sir.getServiceInstanceId ())) {
- throw new ValidationException ("serviceInstanceId matching the serviceInstanceId in request URI");
- }
- serviceModelName = relatedInstanceModelInfo.getModelName ();
- asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion ();
- } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) {
- isRelatedVnfInstancePresent = true;
- if (!relatedInstance.getInstanceId ().equals (this.sir.getVnfInstanceId ())) {
- throw new ValidationException ("vnfInstanceId matching the vnfInstanceId in request URI");
- }
- vnfModelName = relatedInstanceModelInfo.getModelCustomizationName();
- } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) {
- volumeGroupId = relatedInstance.getInstanceId ();
- }
- }
-
- if(action == Action.createInstance && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
- if(!isSourceVnfPresent) {
- throw new ValidationException ("source vnf relatedInstance for Port Configuration");
- }
-
- if(!isDestinationVnfPresent) {
- throw new ValidationException ("destination vnf relatedInstance for Port Configuration");
- }
- }
-
- if((action == Action.enablePort || action == Action.disablePort) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
- if(!isConnectionPointPresent) {
- throw new ValidationException ("connectionPoint relatedInstance for Port Configuration");
- }
- }
-
- if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) {
- if (!isRelatedServiceInstancePresent) {
- throw new ValidationException ("related service instance for volumeGroup request");
- }
- if (!isRelatedVnfInstancePresent) {
- throw new ValidationException ("related vnf instance for volumeGroup request");
- }
- this.serviceInstanceType = serviceModelName;
- this.vnfType = serviceModelName + "/" + vnfModelName;
- this.asdcServiceModelVersion = asdcServiceModelVersion;
- }
- else if(requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) {
- if (!isRelatedServiceInstancePresent) {
- throw new ValidationException ("related service instance for vfModule request");
- }
- if (!isRelatedVnfInstancePresent) {
- throw new ValidationException ("related vnf instance for vfModule request");
- }
- String vfModuleModelName = modelInfo.getModelName ();
- this.vfModuleModelName = vfModuleModelName;
- this.serviceInstanceType = serviceModelName;
- this.vnfType = serviceModelName + "/" + vnfModelName;
- this.asdcServiceModelVersion = asdcServiceModelVersion;
- this.vfModuleType = vnfType + "::" + vfModuleModelName;
- this.sir.setVolumeGroupInstanceId (volumeGroupId);
- }
- else if (requestScope.equalsIgnoreCase (ModelType.vnf.name ())) {
- if (!isRelatedServiceInstancePresent) {
- throw new ValidationException ("related service instance for vnf request");
- }
- this.vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName();
- }
- }
- else if ((( requestScope.equalsIgnoreCase(ModelType.vnf.name ()) || requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())
- || requestScope.equalsIgnoreCase(ModelType.configuration.name())) && (action == Action.createInstance || action == Action.enablePort || action == Action.disablePort)) ||
- (this.reqVersion >= 4 && (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) && action == Action.updateInstance) ||
- (requestScope.equalsIgnoreCase(ModelType.service.name()) && (action.equals(Action.addRelationships) || action.equals(Action.removeRelationships)))){
- msoLogger.debug ("related instance exception");
- throw new ValidationException ("related instances");
- }
- }
- }
- void parsePayload(ServiceInstancesRequest sir, Action action) throws ValidationException{
- msoLogger.debug("Validating for requestParameters and payload");
- this.sir = sir;
- this.action = action;
- this.requestScope = ModelType.vnf.name();
- RequestParameters requestParameters = sir.getRequestDetails().getRequestParameters();
- this.cloudConfiguration = sir.getRequestDetails ().getCloudConfiguration();
- this.requestInfo = sir.getRequestDetails().getRequestInfo();
-
- if(action == Action.inPlaceSoftwareUpdate){
- if (cloudConfiguration == null) {
- throw new ValidationException ("cloudConfiguration");
- }else if (empty (cloudConfiguration.getLcpCloudRegionId ())) {
- throw new ValidationException ("lcpCloudRegionId");
- }else if (empty (cloudConfiguration.getTenantId ())) {
- throw new ValidationException ("tenantId");
- }
- }
- if(requestInfo == null){
- throw new ValidationException("requestInfo");
- }else if(empty(requestInfo.getRequestorId())) {
- throw new ValidationException ("requestorId");
- }else if (empty (requestInfo.getSource ())) {
- throw new ValidationException ("source");
- }
- if(requestParameters == null){
- throw new ValidationException("requestParameters");
- }
- }
- void parsePlatformAndLineOfBusiness(ServiceInstancesRequest sir) throws ValidationException {
- msoLogger.debug("Validating Platform and LineOfBusiness Objects");
- this.sir = sir;
- platform = sir.getRequestDetails().getPlatform();
- lineOfBusiness = sir.getRequestDetails().getLineOfBusiness();
-
- if(this.reqVersion > 5 && platform == null) {
- throw new ValidationException("platform");
- }
-
- if(platform != null && empty(platform.getPlatformName())){
- throw new ValidationException("platformName");
- }
-
- if(lineOfBusiness != null && empty(lineOfBusiness.getLineOfBusinessName())){
- throw new ValidationException("lineOfBusinessName");
- }
- }
-
- void parseProjectAndOwningEntity(ServiceInstancesRequest sir) throws ValidationException {
- msoLogger.debug("Validating Project and OwningEntity Objects");
- this.sir = sir;
- this.project = sir.getRequestDetails().getProject();
- this.owningEntity = sir.getRequestDetails().getOwningEntity();
-
- if(this.reqVersion > 5 && owningEntity == null) {
- throw new ValidationException("owningEntity");
- }
-
- if(owningEntity != null && empty(owningEntity.getOwningEntityId())){
- throw new ValidationException("owningEntityId");
- }
-
- if(project != null && empty(project.getProjectName())){
- throw new ValidationException("projectName");
- }
- }
-
- void parseOrchestration (ServiceInstancesRequest sir) throws ValidationException {
-
- msoLogger.debug ("Validating the Orchestration request");
-
- this.sir = sir;
- this.requestInfo = sir.getRequestDetails().getRequestInfo();
-
- if (this.requestInfo == null) {
- throw new ValidationException ("requestInfo");
- }
-
- if (empty (requestInfo.getSource ())) {
- throw new ValidationException ("source");
- }
- if (empty (requestInfo.getRequestorId ())) {
- throw new ValidationException ("requestorId");
- }
- }
-
- public Map<String, List<String>> getOrchestrationFilters (MultivaluedMap<String, String> queryParams) throws ValidationException {
-
- String queryParam = null;
- Map<String, List<String>> orchestrationFilterParams = new HashMap<>();
-
-
- for (Entry<String,List<String>> entry : queryParams.entrySet()) {
- queryParam = entry.getKey();
-
- try{
- if("filter".equalsIgnoreCase(queryParam)){
- for(String value : entry.getValue()) {
- StringTokenizer st = new StringTokenizer(value, ":");
-
- int counter=0;
- String mapKey=null;
- List<String> orchestrationList = new ArrayList<>();
- while (st.hasMoreElements()) {
- if(counter == 0){
- mapKey = st.nextElement() + "";
- } else{
- orchestrationList.add(st.nextElement() + "");
- }
- counter++;
- }
- orchestrationFilterParams.put(mapKey, orchestrationList);
- }
- }
-
- }catch(Exception e){
- //msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, e);
- throw new ValidationException ("QueryParam ServiceInfo", e);
-
- }
-
- }
-
-
- return orchestrationFilterParams;
- }
-
- public void createRequestRecord (Status status, Action action) {
-
- Session session = null;
- try {
-
- session = requestsDbSessionFactoryManager.getSessionFactory ().openSession ();
- session.beginTransaction ();
-
- if (null == sir) {
- sir = new ServiceInstancesRequest ();
- }
-
- InfraActiveRequests aq = new InfraActiveRequests ();
- aq.setRequestId (requestId);
-
- aq.setRequestAction(action.name());
- aq.setAction(action.name());
-
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
-
- aq.setStartTime (startTimeStamp);
-
- if (requestInfo != null) {
-
- if(requestInfo.getSource() != null){
- aq.setSource(requestInfo.getSource());
- }
- if(requestInfo.getCallbackUrl() != null){
- aq.setCallBackUrl(requestInfo.getCallbackUrl());
- }
- if(requestInfo.getCorrelator() != null){
- aq.setCorrelator(requestInfo.getCorrelator());
- }
-
- if(requestInfo.getRequestorId() != null) {
- aq.setRequestorId(requestInfo.getRequestorId());
- }
- }
-
- if (modelInfo != null || (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)) {
- aq.setRequestScope(requestScope);
- }
-
- if (cloudConfiguration != null) {
- if(cloudConfiguration.getLcpCloudRegionId() != null) {
- aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId());
- }
-
- if(cloudConfiguration.getTenantId() != null) {
- aq.setTenantId(cloudConfiguration.getTenantId());
- }
-
- }
-
- if(sir.getServiceInstanceId() != null){
- aq.setServiceInstanceId(sir.getServiceInstanceId());
- }
-
- if(sir.getVnfInstanceId() != null){
- aq.setVnfId(sir.getVnfInstanceId());
- }
-
-
- if(ModelType.service.name().equalsIgnoreCase(requestScope)){
- if(requestInfo.getInstanceName() != null){
- aq.setServiceInstanceName(requestInfo.getInstanceName());
- }
- }
-
- if(ModelType.network.name().equalsIgnoreCase(requestScope)){
- aq.setNetworkName(requestInfo.getInstanceName());
- aq.setNetworkType(networkType);
- aq.setNetworkId(sir.getNetworkInstanceId());
- }
-
- if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)){
- aq.setVolumeGroupId(sir.getVolumeGroupInstanceId());
- aq.setVolumeGroupName(requestInfo.getInstanceName());
- aq.setVnfType(vnfType);
-
- }
-
- if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)){
- aq.setVfModuleName(requestInfo.getInstanceName());
- aq.setVfModuleModelName(modelInfo.getModelName());
- aq.setVfModuleId(sir.getVfModuleInstanceId());
- aq.setVolumeGroupId(sir.getVolumeGroupInstanceId());
- aq.setVnfType(vnfType);
-
- }
-
- if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
- aq.setConfigurationId(sir.getConfigurationId());
- aq.setConfigurationName(requestInfo.getInstanceName());
- }
-
- if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){
- aq.setVnfName(requestInfo.getInstanceName());
- if (null != sir.getRequestDetails()) {
- RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
-
- if (instanceList != null) {
-
- for(RelatedInstanceList relatedInstanceList : instanceList){
-
- RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
- if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){
- aq.setVnfType(vnfType);
- }
- }
- }
- }
- }
-
- aq.setRequestBody (this.originalRequestJSON);
-
- aq.setRequestStatus (status.toString ());
- aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER);
-
- if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
- aq.setStatusMessage (this.errorMessage);
- aq.setResponseBody (this.responseBody);
- aq.setProgress(new Long(100));
- Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
- aq.setEndTime (endTimeStamp);
- }
-
- msoLogger.debug ("About to insert a record");
-
- session.save (aq);
- session.getTransaction ().commit ();
- session.close ();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e);
- if (session != null) {
- session.close ();
- }
- if (!status.equals (Status.FAILED)) {
- throw e;
- }
- }
- }
-
- public void updateFinalStatus (Status status) {
- try {
- (RequestsDatabase.getInstance()).updateInfraFinalStatus (requestId,
- status.toString (),
- this.errorMessage,
- this.progress,
- this.responseBody,
- Constants.MODIFIED_BY_APIHANDLER);
- } catch (Exception e) {
- msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB");
- msoLogger.debug ("Exception: ", e);
- }
- }
-
- public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) {
- return buildResponseWithError (httpResponseCode, errorCode, inProgress, null);
- }
-
- public Response buildResponseWithError (int httpResponseCode,
- String errorCode,
- InfraActiveRequests inProgress,
- String errorString) {
-
-
-
- // Log the failed request into the MSO Requests database
-
- return Response.status (httpResponseCode).entity (null).build ();
-
- }
-
- public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) {
-
-
-
- return Response.status (httpResponseCode).entity (null).build ();
- }
-
- public Platform getPlatform(){
- return platform;
- }
-
- public void setPlatform(Platform value){
- this.platform = value;
- }
-
- public LineOfBusiness getLineOfBusiness(){
- return lineOfBusiness;
- }
-
- public void setLineOfBusiness(LineOfBusiness value){
- this.lineOfBusiness = value;
- }
-
- public Project getProject(){
- return project;
- }
- public void setProject(Project value){
- this.project = value;
- }
- public OwningEntity getOwningEntity(){
- return owningEntity;
- }
- public void setOwningEntity(OwningEntity value){
- this.owningEntity = value;
- }
- public String getRequestUri () {
- return requestUri;
- }
-
- public void setRequestUri (String requestUri) {
- this.requestUri = requestUri;
- }
-
- public VnfInputs getVnfInputs () {
- return vnfInputs;
- }
-
- public RequestInfo getRequestInfo () {
- return requestInfo;
- }
-
- public String getResponseBody () {
- return responseBody;
- }
-
- public void setResponseBody (String responseBody) {
- this.responseBody = responseBody;
- }
-
- public String getHttpResponse () {
- return httpResponse;
- }
-
- public void setHttpResponse (String httpResponse) {
- this.httpResponse = httpResponse;
- }
-
- public String getRequestId () {
- return requestId;
- }
-
- public String getRequestXML () {
- return requestXML;
- }
-
- public void setRequestXML (String requestXML) {
- this.requestXML = requestXML;
- }
-
- public RequestStatusType getStatus () {
- return status;
- }
-
- public String getServiceType () {
- if (this.vnfInputs.getServiceType () != null)
- return this.vnfInputs.getServiceType ();
- if (this.vnfInputs.getServiceId () != null)
- return this.vnfInputs.getServiceId ();
- return null;
- }
-
- public void setStatus (RequestStatusType status) {
- this.status = status;
- switch (status) {
- case FAILED:
- case COMPLETE:
- this.progress = Constants.PROGRESS_REQUEST_COMPLETED;
- break;
- case IN_PROGRESS:
- this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS;
- break;
- }
- }
-
- public ModelInfo getModelInfo() {
- return modelInfo;
- }
-
- public ServiceInstancesRequest getServiceInstancesRequest() {
- return sir;
- }
-
- public String getServiceInstanceType () {
- return serviceInstanceType;
- }
-
- public String getNetworkType () {
- return networkType;
- }
-
- public String getVnfType () {
- return vnfType;
- }
-
- public String getVfModuleModelName () {
- return vfModuleModelName;
- }
-
- public String getVfModuleType () {
- return vfModuleType;
- }
-
- public String getAsdcServiceModelVersion () {
- return asdcServiceModelVersion;
- }
-
- public static String domToStr (Document doc) {
- if (doc == null) {
- return null;
- }
-
- try {
- StringWriter sw = new StringWriter ();
- StreamResult sr = new StreamResult (sw);
- TransformerFactory tf = TransformerFactory.newInstance ();
- Transformer t = tf.newTransformer ();
- t.setOutputProperty (OutputKeys.STANDALONE, "yes");
- NodeList nl = doc.getDocumentElement ().getChildNodes ();
- DOMSource source = null;
- for (int x = 0; x < nl.getLength (); x++) {
- Node e = nl.item (x);
- if (e instanceof Element) {
- source = new DOMSource (e);
- break;
- }
- }
- if (source != null) {
- t.transform (source, sr);
-
- String s = sw.toString ();
- return s;
- }
-
- return null;
-
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in domToStr", e);
- }
- return null;
- }
-
- public void addBPMNSpecificInputs(String personaModelId, String personaModelVersion, Boolean isBaseVfModule,
- String vnfPersonaModelId, String vnfPersonaModelVersion) {
- vnfInputs.setPersonaModelId(personaModelId);
- vnfInputs.setPersonaModelVersion(personaModelVersion);
- vnfInputs.setIsBaseVfModule(isBaseVfModule);
- vnfInputs.setVnfPersonaModelId(vnfPersonaModelId);
- vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion);
-
- this.vnfReq.setVnfInputs(vnfInputs);
-
- StringWriter stringWriter = new StringWriter ();
- try {
- JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class);
- Marshaller jaxbMarshaller = jaxbContext.createMarshaller ();
-
- // output pretty printed
- jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true);
-
- jaxbMarshaller.marshal (this.vnfReq, stringWriter);
-
- } catch (JAXBException e) {
- msoLogger.debug ("Exception: ", e);
- }
-
- this.requestXML = stringWriter.toString ();
- msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML);
-
-
- }
-
- private static boolean empty(String s) {
- return (s == null || s.trim().isEmpty());
- }
-
- public String getRequestJSON() throws JsonGenerationException, JsonMappingException, IOException {
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- //mapper.configure(Feature.WRAP_ROOT_VALUE, true);
- msoLogger.debug ("building sir from object " + sir);
- String requestJSON = mapper.writeValueAsString(sir);
-
- // Perform mapping from VID-style modelInfo fields to ASDC-style modelInfo fields
-
- msoLogger.debug("REQUEST JSON before mapping: " + requestJSON);
- // modelUuid = modelVersionId
- requestJSON = requestJSON.replaceAll("\"modelVersionId\":","\"modelUuid\":");
- // modelCustomizationUuid = modelCustomizationId
- requestJSON = requestJSON.replaceAll("\"modelCustomizationId\":","\"modelCustomizationUuid\":");
- // modelInstanceName = modelCustomizationName
- requestJSON = requestJSON.replaceAll("\"modelCustomizationName\":","\"modelInstanceName\":");
- // modelInvariantUuid = modelInvariantId
- requestJSON = requestJSON.replaceAll("\"modelInvariantId\":","\"modelInvariantUuid\":");
- msoLogger.debug("REQUEST JSON after mapping: " + requestJSON);
-
- return requestJSON;
- }
-
- public boolean getALaCarteFlag() {
- return aLaCarteFlag;
- }
-
- public void setaLaCarteFlag(boolean aLaCarteFlag) {
- this.aLaCarteFlag = aLaCarteFlag;
- }
-
- public int getReqVersion() {
- return reqVersion;
- }
-
- public void setReqVersion(int reqVersion) {
- this.reqVersion = reqVersion;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java
deleted file mode 100644
index 216a7ba43b..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java
+++ /dev/null
@@ -1,376 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.apihandlerinfra;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.http.HttpStatus;
-
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoAlarmLogger;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.serviceinstancebeans.GetOrchestrationListResponse;
-import org.openecomp.mso.serviceinstancebeans.GetOrchestrationResponse;
-import org.openecomp.mso.serviceinstancebeans.InstanceReferences;
-import org.openecomp.mso.serviceinstancebeans.Request;
-import org.openecomp.mso.serviceinstancebeans.RequestDetails;
-import org.openecomp.mso.serviceinstancebeans.RequestList;
-import org.openecomp.mso.serviceinstancebeans.RequestStatus;
-import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/orchestrationRequests")
-@Api(value="/orchestrationRequests",description="API Requests for Orchestration requests")
-public class OrchestrationRequests {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
-
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
-
- private RequestsDatabase requestsDB = RequestsDatabase.getInstance();
-
- /**
- *
- */
- public OrchestrationRequests() {
- // TODO Auto-generated constructor stub
- }
-
- @GET
- @Path("/{version:[vV][4-6]}/{requestId}")
- @ApiOperation(value="Find Orchestrated Requests for a given requestId",response=Response.class)
- @Produces(MediaType.APPLICATION_JSON)
- public Response getOrchestrationRequest(@PathParam("requestId") String requestId, @PathParam("version") String version) {
-
- GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse();
-
- MsoRequest msoRequest = new MsoRequest (requestId);
-
- long startTime = System.currentTimeMillis ();
-
- InfraActiveRequests requestDB = null;
-
- try {
- requestDB = requestsDB.getRequestFromInfraActive(requestId);
-
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- e.getMessage (),
- ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
-
- }
-
- if(requestDB == null) {
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NO_CONTENT,
- MsoException.ServiceException,
- "Orchestration RequestId " + requestId + " is not found in DB",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
-
- }
-
- Request request = mapInfraActiveRequestToRequest(requestDB);
-
- orchestrationResponse.setRequest(request);
-
- return Response.status(200).entity(orchestrationResponse).build();
- }
-
- @GET
- @Path("/{version:[vV][4-6]}")
- @ApiOperation(value="Find Orchestrated Requests for a URI Information",response=Response.class)
- @Produces(MediaType.APPLICATION_JSON)
- public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version) {
-
- long startTime = System.currentTimeMillis ();
-
- MsoRequest msoRequest = new MsoRequest();
-
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-
- List<InfraActiveRequests> activeRequests = null;
-
- GetOrchestrationListResponse orchestrationList = null;
-
-
- try{
-
- Map<String, List<String>> orchestrationMap = msoRequest.getOrchestrationFilters(queryParams);
-
- activeRequests = requestsDB.getOrchestrationFiltersFromInfraActive(orchestrationMap);
-
- orchestrationList = new GetOrchestrationListResponse();
-
- List<RequestList> requestLists = new ArrayList<>();
-
- for(InfraActiveRequests infraActive : activeRequests){
-
- Request request = mapInfraActiveRequestToRequest(infraActive);
- RequestList requestList = new RequestList();
- requestList.setRequest(request);
-
- requestLists.add(requestList);
-
- }
-
- orchestrationList.setRequestList(requestLists);
-
- }catch(Exception e){
- msoLogger.debug ("Get Orchestration Request with Filters Failed : ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
- "Get Orchestration Request with Filters Failed. " + e.getMessage(),
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Get Orchestration Request with Filters Failed : " + e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Get Orchestration Request with Filters Failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
-
- return Response.status(200).entity(orchestrationList).build();
- }
-
-
- @POST
- @Path("/{version: [vV][4-6]}/{requestId}/unlock")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Unlock Orchestrated Requests for a given requestId",response=Response.class)
- public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) {
-
- MsoRequest msoRequest = new MsoRequest (requestId);
-
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("requestId is: " + requestId);
-
- InfraActiveRequests requestDB = null;
- Request request = null;
-
- msoLogger.debug ("requestId is: " + requestId);
- ServiceInstancesRequest sir = null;
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
-
- } catch(Exception e){
- msoLogger.debug ("Mapping of request to JSON object failed : ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Mapping of request to JSON object failed");
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
-
- try{
- msoRequest.parseOrchestration(sir);
- } catch (Exception e) {
- msoLogger.debug ("Validation failed: ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Logging failed message to the database");
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- requestDB = requestsDB.getRequestFromInfraActive(requestId);
-
- if(requestDB == null) {
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "Orchestration RequestId " + requestId + " is not found in DB",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
-
- }else{
- request = mapInfraActiveRequestToRequest(requestDB);
- RequestStatus reqStatus = request.getRequestStatus();
- Status status = Status.valueOf(reqStatus.getRequestState());
- if(status == Status.IN_PROGRESS || status == Status.PENDING || status == Status.PENDING_MANUAL_TASK){
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.UNLOCKED);
- reqStatus.setRequestState(Status.UNLOCKED.toString ());
- requestsDB.updateInfraStatus (requestId,
- Status.UNLOCKED.toString (),
- Constants.MODIFIED_BY_APIHANDLER);
-
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "RequestId " + requestId + " has been unlocked");
-
- }else{
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
- }
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- e.getMessage (),
- ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
-
- }
-
- return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build ();
- }
-
- private Request mapInfraActiveRequestToRequest(InfraActiveRequests requestDB) {
-
-
- Request request = new Request();
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
-
- request.setRequestId(requestDB.getRequestId());
- request.setRequestScope(requestDB.getRequestScope());
- request.setRequestType(requestDB.getRequestAction());
-
- InstanceReferences ir = new InstanceReferences();
- if(requestDB.getNetworkId() != null)
- ir.setNetworkInstanceId(requestDB.getNetworkId());
- if(requestDB.getNetworkName() != null)
- ir.setNetworkInstanceName(requestDB.getNetworkName());
- if(requestDB.getServiceInstanceId() != null)
- ir.setServiceInstanceId(requestDB.getServiceInstanceId());
- if(requestDB.getServiceInstanceName() != null)
- ir.setServiceInstanceName(requestDB.getServiceInstanceName());
- if(requestDB.getVfModuleId() != null)
- ir.setVfModuleInstanceId(requestDB.getVfModuleId());
- if(requestDB.getVfModuleName() != null)
- ir.setVfModuleInstanceName(requestDB.getVfModuleName());
- if(requestDB.getVnfId() != null)
- ir.setVnfInstanceId(requestDB.getVnfId());
- if(requestDB.getVnfName() != null)
- ir.setVnfInstanceName(requestDB.getVnfName());
- if(requestDB.getVolumeGroupId() != null)
- ir.setVolumeGroupInstanceId(requestDB.getVolumeGroupId());
- if(requestDB.getVolumeGroupName() != null)
- ir.setVolumeGroupInstanceName(requestDB.getVolumeGroupName());
- if(requestDB.getRequestorId() != null)
- ir.setRequestorId(requestDB.getRequestorId());
-
-
- request.setInstanceReferences(ir);
-
- String requestBody = requestDB.getRequestBody();
-
- RequestDetails requestDetails = null;
-
- try{
- requestDetails = mapper.readValue(requestBody, RequestDetails.class);
-
- }catch(Exception e){
- msoLogger.debug("Exception caught mapping requestBody to RequestDetails",e);
- }
-
- request.setRequestDetails(requestDetails);
- String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getStartTime()) + " GMT";
- request.setStartTime(startTimeStamp);
-
- RequestStatus status = new RequestStatus();
- if(requestDB.getStatusMessage() != null){
- status.setStatusMessage(requestDB.getStatusMessage());
- }
-
- if(requestDB.getEndTime() != null){
- String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getEndTime()) + " GMT";
- status.setFinishTime(endTimeStamp);
- }
-
-
- if(requestDB.getRequestStatus() != null){
- status.setRequestState(requestDB.getRequestStatus());
- }
-
- if(requestDB.getProgress() != null){
- status.setPercentProgress(requestDB.getProgress().intValue());
- }
-
- request.setRequestStatus(status);
-
- return request;
- }
- }
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
deleted file mode 100644
index 32a016fae5..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
+++ /dev/null
@@ -1,1249 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.apihandlerinfra;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.openecomp.mso.apihandler.common.CommonConstants;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandler.common.RequestClient;
-import org.openecomp.mso.apihandler.common.RequestClientFactory;
-import org.openecomp.mso.apihandler.common.RequestClientParamater;
-import org.openecomp.mso.apihandler.common.ResponseHandler;
-import org.openecomp.mso.apihandler.common.ValidationException;
-import org.openecomp.mso.serviceinstancebeans.ModelInfo;
-import org.openecomp.mso.serviceinstancebeans.ModelType;
-import org.openecomp.mso.serviceinstancebeans.RelatedInstance;
-import org.openecomp.mso.serviceinstancebeans.RelatedInstanceList;
-import org.openecomp.mso.serviceinstancebeans.RequestParameters;
-import org.openecomp.mso.serviceinstancebeans.RequestReferences;
-import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest;
-import org.openecomp.mso.serviceinstancebeans.ServiceInstancesResponse;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.db.catalog.beans.Recipe;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VnfRecipe;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoAlarmLogger;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/serviceInstances")
-@Api(value="/serviceInstances",description="API Requests for Service Instances")
-public class ServiceInstances {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
-
- @POST
- @Path("/{version:[vV][4-6]}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Create a Service Instance on a version provided",response=Response.class)
- public Response createServiceInstance(String request, @PathParam("version") String version) {
- return serviceInstances(request, Action.createInstance, null, version);
- }
-
- @POST
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/activate")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Activate provided Service Instance",response=Response.class)
- public Response activateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.activateInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/deactivate")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Deactivate provided Service Instance",response=Response.class)
- public Response deactivateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.deactivateInstance, instanceIdMap, version);
- }
-
- @DELETE
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Delete provided Service Instance",response=Response.class)
- public Response deleteServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/configurations")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Create Port Mirroring Configuration",response=Response.class)
- public Response createPortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return configurationRecipeLookup(request, Action.createInstance, instanceIdMap, version);
- }
-
- @DELETE
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/configurations/{configurationInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Delete provided Port",response=Response.class)
- public Response deletePortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("configurationInstanceId") String configurationInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.deleteInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/configurations/{configurationInstanceId}/enablePort")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Enable Port Mirroring",response=Response.class)
- public Response enablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("configurationInstanceId") String configurationInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.enablePort, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/configurations/{configurationInstanceId}/disablePort")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Disable Port Mirroring",response=Response.class)
- public Response disablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("configurationInstanceId") String configurationInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.disablePort, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/configurations/{configurationInstanceId}/activate")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Activate Port Mirroring",response=Response.class)
- public Response activatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("configurationInstanceId") String configurationInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.activateInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/configurations/{configurationInstanceId}/deactivate")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Deactivate Port Mirroring",response=Response.class)
- public Response deactivatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("configurationInstanceId") String configurationInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("configurationInstanceId", configurationInstanceId);
- return configurationRecipeLookup(request, Action.deactivateInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][6]}/{serviceInstanceId}/addRelationships")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Add Relationships to a Service Instance",response=Response.class)
- public Response addRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- msoLogger.debug ("version is: " + version);
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return configurationRecipeLookup(request, Action.addRelationships, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][6]}/{serviceInstanceId}/removeRelationships")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Remove Relationships from Service Instance",response=Response.class)
- public Response removeRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- msoLogger.debug ("version is: " + version);
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return configurationRecipeLookup(request, Action.removeRelationships, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/vnfs")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Create VNF on a specified version and serviceInstance",response=Response.class)
- public Response createVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- msoLogger.debug ("version is: " + version);
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/replace")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Replace provided VNF instance",response=Response.class)
- public Response replaceVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
- msoLogger.debug ("version is: " + version);
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.replaceInstance, instanceIdMap, version);
- }
-
- @PUT
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Update VNF on a specified version, serviceInstance and vnfInstance",response=Response.class)
- public Response updateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/applyUpdatedConfig")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Apply updated configuration",response=Response.class)
- public Response applyUpdatedConfig(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version);
- }
-
-
- @DELETE
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Delete provided VNF instance",response=Response.class)
- public Response deleteVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Create VfModule on a specified version, serviceInstance and vnfInstance",response=Response.class)
- public Response createVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
- msoLogger.debug ("version is: " + version);
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][5-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}/replace")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Create VfModule on a specified version, serviceInstance and vnfInstance",response=Response.class)
- public Response replaceVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId,
- @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) {
- msoLogger.debug ("version is: " + version);
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- return serviceInstances(request, Action.replaceInstance, instanceIdMap, version);
- }
-
- @PUT
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Update VfModule on a specified version, serviceInstance, vnfInstance and vfModule",response=Response.class)
- public Response updateVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId,
- @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/inPlaceSoftwareUpdate")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Perform VNF software update",response=Response.class)
- public Response inPlaceSoftwareUpdate(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version);
- }
-
- @DELETE
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Delete provided VfModule instance",response=Response.class)
- public Response deleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId,
- @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version);
- }
-
-
- @POST
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Create VolumeGroup on a specified version, serviceInstance, vnfInstance",response=Response.class)
- public Response createVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version);
- }
-
- @PUT
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Update VolumeGroup on a specified version, serviceInstance, vnfInstance and volumeGroup",response=Response.class)
- public Response updateVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId,
- @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version);
- }
-
- @DELETE
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Delete provided VolumeGroup instance",response=Response.class)
- public Response deleteVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId,
- @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("vnfInstanceId", vnfInstanceId);
- instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/networks")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Create NetworkInstance on a specified version and serviceInstance ",response=Response.class)
- public Response createNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- return serviceInstances(request, Action.createInstance, instanceIdMap, version);
- }
-
- @PUT
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/networks/{networkInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Update VolumeGroup on a specified version, serviceInstance, networkInstance",response=Response.class)
- public Response updateNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("networkInstanceId") String networkInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("networkInstanceId", networkInstanceId);
- return serviceInstances(request, Action.updateInstance, instanceIdMap, version);
- }
-
- @DELETE
- @Path("/{version:[vV][4-6]}/{serviceInstanceId}/networks/{networkInstanceId}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Delete provided Network instance",response=Response.class)
- public Response deleteNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("networkInstanceId") String networkInstanceId) {
- HashMap<String, String> instanceIdMap = new HashMap<>();
- instanceIdMap.put("serviceInstanceId", serviceInstanceId);
- instanceIdMap.put("networkInstanceId", networkInstanceId);
- return serviceInstances(request, Action.deleteInstance, instanceIdMap, version);
- }
-
- private Response serviceInstances(String requestJSON, Action action, HashMap<String,String> instanceIdMap, String version) {
-
- String requestId = UUIDChecker.generateUUID(msoLogger);
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("requestId is: " + requestId);
- ServiceInstancesRequest sir = null;
-
- MsoRequest msoRequest = new MsoRequest (requestId);
-
- try {
- sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, msoRequest);
- } catch(Exception e) {
- msoLogger.debug("Exception occurred while mapping of request to JSON object ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- parseRequest(requestJSON, action, instanceIdMap, version, startTime, sir, msoRequest);
- } catch(Exception e) {
- msoLogger.debug("Exception occurred while logging ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Logging failed message to the database");
- msoRequest.createRequestRecord (Status.FAILED, action);
- }
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
- String requestScope;
- if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){
- requestScope = (ModelType.vnf.name());
- }else{
- requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
- }
- InfraActiveRequests dup = null;
-
- try {
- dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope);
- } catch(Exception e) {
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
- e.getMessage(),
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- if (dup != null) {
- return buildErrorOnDuplicateRecord(action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
- }
-
- ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
-
- RequestReferences referencesResponse = new RequestReferences();
-
- referencesResponse.setRequestId(requestId);
-
- serviceResponse.setRequestReferences(referencesResponse);
-
- CatalogDatabase db = null;
- try {
- db = CatalogDatabase.getInstance();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "No communication to catalog DB " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
- msoRequest.createRequestRecord (Status.FAILED,action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- RecipeLookupResult recipeLookupResult = null;
- try {
- recipeLookupResult = getServiceInstanceOrchestrationURI (db, msoRequest, action);
- } catch (ValidationException e) {
- msoLogger.debug ("Validation failed: ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Error validating request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Logging failed message to the database");
- msoRequest.createRequestRecord (Status.FAILED, action);
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Exception while querying Catalog DB", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "Recipe could not be retrieved from catalog DB " + e.getMessage (),
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.ERROR_FROM_CATALOG_DB));
- msoRequest.createRequestRecord (Status.FAILED,action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while querying Catalog DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- db.close();
- return response;
- }
-
- if (recipeLookupResult == null) {
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "No recipe found in DB");
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "Recipe does not exist in catalog DB",
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR,
- null);
- msoRequest.createRequestRecord (Status.FAILED, action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No recipe found in DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- db.close();
- return response;
- }
-
-
- Boolean isBaseVfModule = false;
-
- if (msoRequest.getModelInfo() != null && (action == Action.applyUpdatedConfig ||
- action == Action.inPlaceSoftwareUpdate)) {
-
- }
- ModelType modelType;
- if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
- modelType = ModelType.vnf;
- }
- else {
- modelType = msoRequest.getModelInfo().getModelType();
- }
-
- if (modelType.equals(ModelType.vfModule)) {
- String asdcServiceModelVersion = msoRequest.getAsdcServiceModelVersion ();
-
- // Get VF Module-specific base module indicator
- VfModule vfm;
-
- String modelVersionId = msoRequest.getModelInfo().getModelVersionId();
-
- if(modelVersionId != null) {
- vfm = db.getVfModuleByModelUuid(modelVersionId);
- } else {
- vfm = db.getVfModuleByModelInvariantUuidAndModelVersion(msoRequest.getModelInfo().getModelInvariantId(), msoRequest.getModelInfo().getModelVersion());
- }
-
- if (vfm != null) {
- if (vfm.getIsBase() == 1) {
- isBaseVfModule = true;
- }
- }
- else if (action == Action.createInstance || action == Action.updateInstance){
- // There is no entry for this vfModuleType with this version, if specified, in VF_MODULE table in Catalog DB.
- // This request cannot proceed
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "VF Module Type", "", MsoLogger.ErrorCode.DataError, "No VfModuleType found in DB");
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- String serviceVersionText = "";
- if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) {
- serviceVersionText = " with version " + asdcServiceModelVersion;
- }
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "VnfType " + msoRequest.getVnfType () + " and VF Module Model Name " + msoRequest.getVfModuleModelName() + serviceVersionText + " not found in MSO Catalog DB",
- ErrorNumbers.SVC_BAD_PARAMETER,
- null);
- msoRequest.createRequestRecord (Status.FAILED, action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No matching vfModuleType found in DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- db.close();
- return response;
- }
- }
-
- db.close();
- msoLogger.debug ("requestId is: " + msoRequest.getRequestId());
- msoLogger.debug ("About to insert a record");
-
- try {
- createRequestRecord(action, startTime, msoRequest);
- } catch(Exception e) {
- msoLogger.debug("Exception occurred while creating record in DB", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- "Exception while creating record in DB " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER,
- null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- return postBPELRequest(action, startTime, msoRequest, recipeLookupResult.getOrchestrationURI(),
- recipeLookupResult.getRecipeTimeout(), isBaseVfModule);
- }
-
- private RequestClientParamater buildRequestClientParameter(MsoRequest msoRequest, boolean isBaseVfModule,
- int timeOut, String requestAction) throws IOException {
- return new RequestClientParamater.Builder().
- setRequestId(msoRequest.getRequestId()).
- setBaseVfModule(isBaseVfModule).setRecipeTimeout(timeOut).
- setRequestAction(requestAction).
- setServiceInstanceId(msoRequest.getServiceInstancesRequest().getServiceInstanceId()).
- setCorrelationId(msoRequest.getServiceInstancesRequest().getCorrelationId()).
- setVnfId(msoRequest.getServiceInstancesRequest().getVnfInstanceId()).
- setVfModuleId(msoRequest.getServiceInstancesRequest().getVfModuleInstanceId()).
- setVolumeGroupId(msoRequest.getServiceInstancesRequest().getVolumeGroupInstanceId()).
- setNetworkId(msoRequest.getServiceInstancesRequest().getNetworkInstanceId()).
- setConfigurationId(msoRequest.getServiceInstancesRequest().getConfigurationId()).
- setServiceType(msoRequest.getServiceInstanceType()).
- setVnfType(msoRequest.getVnfType()).
- setVfModuleType(msoRequest.getVfModuleType()).
- setNetworkType(msoRequest.getNetworkType()).
- setRequestDetails(msoRequest.getRequestJSON()).build();
- }
-
- private Response postBPELRequest(Action action, long startTime, MsoRequest msoRequest,
- String orchestrationUri, int timeOut, Boolean isBaseVfModule) {
- RequestClient requestClient = null;
- HttpResponse response = null;
- long subStartTime = System.currentTimeMillis();
- try {
- requestClient = RequestClientFactory.getRequestClient (orchestrationUri, MsoPropertiesUtils.loadMsoProperties ());
- msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ());
-
- System.out.println("URL : " + requestClient.getUrl ());
-
- response = requestClient.post(buildRequestClientParameter(msoRequest, isBaseVfModule, timeOut, action.name()));
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationUri, null);
- } catch (Exception e) {
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationUri, null);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException,
- "Failed calling bpmn " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- alarmLogger.sendAlarm ("MsoConfigurationError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity (),e);
- return resp;
- }
-
- if (response == null) {
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException,
- "bpelResponse is null",
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
- ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
- int bpelStatus = respHandler.getStatus ();
-
- // BPEL accepted the request, the request is in progress
- if (bpelStatus == HttpStatus.SC_ACCEPTED) {
- String camundaJSONResponseBody = respHandler.getContent();
- msoLogger.debug ("Received from Camunda: " + camundaJSONResponseBody);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.IN_PROGRESS);
- (RequestsDatabase.getInstance()).updateInfraStatus (msoRequest.getRequestId (),
- Status.IN_PROGRESS.toString (),
- Constants.PROGRESS_REQUEST_IN_PROGRESS,
- Constants.MODIFIED_BY_APIHANDLER);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) camundaJSONResponseBody);
- return Response.status (HttpStatus.SC_ACCEPTED).entity (camundaJSONResponseBody).build ();
- } else {
- List<String> variables = new ArrayList<>();
- variables.add(bpelStatus + "");
- String camundaJSONResponseBody = respHandler.getContent();
- if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) {
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
- MsoException.ServiceException,
- "Request Failed due to BPEL error with HTTP Status= %1 " + '\n' + camundaJSONResponseBody,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- variables);
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- } else {
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
- MsoException.ServiceException,
- "Request Failed due to BPEL error with HTTP Status= %1" ,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- variables);
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
- }
- }
-
- private void createRequestRecord(Action action, long startTime, MsoRequest msoRequest) throws Exception {
- try {
- msoRequest.createRequestRecord (Status.PENDING, action);
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB");
- throw new Exception(e);
- }
- }
-
- private Response buildErrorOnDuplicateRecord(Action action, HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest,
- String instanceName, String requestScope, InfraActiveRequests dup) {
-
- // Found the duplicate record. Return the appropriate error.
- String instance = null;
- if(instanceName != null){
- instance = instanceName;
- }else{
- instance = instanceIdMap.get(requestScope + "InstanceId");
- }
- String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") " + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - " + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
- //List<String> variables = new ArrayList<String>();
- //variables.add(dup.getRequestStatus());
-
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException,
- dupMessage,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
-
-
- msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError, "Duplicate request - Subscriber already has a request for this service");
- msoRequest.createRequestRecord (Status.FAILED, action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- private InfraActiveRequests duplicateCheck(Action action, HashMap<String, String> instanceIdMap, long startTime,
- MsoRequest msoRequest, String instanceName, String requestScope) throws Exception {
- InfraActiveRequests dup = null;
- try {
- if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance))){
- dup = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
- }
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Error during duplicate check");
- throw new Exception(e);
- }
- return dup;
- }
-
- private void parseRequest(String originalRequestJSON, Action action, HashMap<String, String> instanceIdMap, String version,
- long startTime, ServiceInstancesRequest sir, MsoRequest msoRequest) throws Exception {
- try{
- msoRequest.parse(sir, instanceIdMap, action, version, originalRequestJSON);
- } catch (Exception e) {
- msoLogger.debug ("Validation failed: ", e);
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, originalRequestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
- throw new Exception(e);
- }
- }
-
- private ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Action action, long startTime,
- MsoRequest msoRequest) throws Exception {
- try{
- ObjectMapper mapper = new ObjectMapper();
- return mapper.readValue(requestJSON, ServiceInstancesRequest.class);
- } catch(Exception e){
- msoLogger.debug ("Mapping of request to JSON object failed : ", e);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Mapping of request to JSON object failed");
- msoRequest.createRequestRecord (Status.FAILED, action);
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- throw new Exception(e);
- }
- }
-
- private RecipeLookupResult getServiceInstanceOrchestrationURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
- RecipeLookupResult recipeLookupResult = null;
- //if the aLaCarte flag is set to TRUE, the API-H should choose the “VID_DEFAULT” recipe for the requested action
-
- msoLogger.debug("aLaCarteFlag is " + msoRequest.getALaCarteFlag());
- // Query MSO Catalog DB
-
- if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
- recipeLookupResult = getDefaultVnfUri(db, msoRequest, action);
- }
- else if (msoRequest.getModelInfo().getModelType().equals(ModelType.service)) {
- recipeLookupResult = getServiceURI(db, msoRequest, action);
- }
- else if (msoRequest.getModelInfo().getModelType().equals(ModelType.vfModule) ||
- msoRequest.getModelInfo().getModelType().equals(ModelType.volumeGroup) || msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) {
-
- recipeLookupResult = getVnfOrVfModuleUri(db, msoRequest, action);
-
- }else if (msoRequest.getModelInfo().getModelType().equals(ModelType.network)) {
-
- recipeLookupResult = getNetworkUri(db, msoRequest, action);
- }
-
- if (recipeLookupResult != null) {
- msoLogger.debug ("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout ()));
- }
- else {
- msoLogger.debug("No matching recipe record found");
- }
- return recipeLookupResult;
- }
-
-
- private RecipeLookupResult getServiceURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
- // SERVICE REQUEST
- // Construct the default service name
- // TODO need to make this a configurable property
- String defaultServiceModelName = "*";
- String defaultSourceServiceModelName = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
-
- Service serviceRecord;
- ModelInfo modelInfo = msoRequest.getModelInfo();
- if(msoRequest.getALaCarteFlag()){
- serviceRecord = db.getServiceByModelName(defaultSourceServiceModelName);
- if (serviceRecord == null) {
- serviceRecord = db.getServiceByModelName(defaultServiceModelName);
- }
- }else{
- serviceRecord = db.getServiceByModelUUID(modelInfo.getModelVersionId()); // ModelVersionId is not required in v3
- if(serviceRecord == null) {
- serviceRecord = db.getServiceByVersionAndInvariantId(modelInfo.getModelInvariantId(), modelInfo.getModelVersion());
- }
- }
-
- ServiceRecipe recipe = null;
- if(serviceRecord !=null){
- recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
- }
- //if an aLaCarte flag was sent in the request, throw an error if the recipe was not found
- RequestParameters reqParam = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters();
- if(reqParam!=null && reqParam.isaLaCarte()!=null && reqParam.isaLaCarte() && recipe==null){
- return null;
- } else if (recipe==null) {
- //aLaCarte wasn't sent, so we'll try the default
- serviceRecord = db.getServiceByModelName(defaultSourceServiceModelName);
- if (serviceRecord == null) {
- serviceRecord = db.getServiceByModelName(defaultServiceModelName);
- }
- recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
- }
-
- if(modelInfo.getModelVersionId() == null) {
- modelInfo.setModelVersionId(serviceRecord.getModelUUID());
- }
- if(recipe==null){
- return null;
- }
- return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
- }
-
-
- private RecipeLookupResult getVnfOrVfModuleUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
-
- ModelInfo modelInfo = msoRequest.getModelInfo();
- String vnfComponentType = modelInfo.getModelType().name();
-
- RelatedInstanceList[] instanceList = null;
- if (msoRequest.getServiceInstancesRequest().getRequestDetails() != null) {
- instanceList = msoRequest.getServiceInstancesRequest().getRequestDetails().getRelatedInstanceList();
- }
-
- Recipe recipe = null;
- String defaultSource = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
- String modelCustomizationId = modelInfo.getModelCustomizationId();
- String modelCustomizationName = modelInfo.getModelCustomizationName();
- String relatedInstanceModelVersionId = null;
- String relatedInstanceModelInvariantId = null;
- String relatedInstanceVersion = null;
- String relatedInstanceModelCustomizationName = null;
-
- if (instanceList != null) {
-
- for(RelatedInstanceList relatedInstanceList : instanceList){
-
- RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
- ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo();
- if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)){
- relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId();
- relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion();
- }
-
- if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)){
- relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId();
- relatedInstanceModelInvariantId = relatedInstanceModelInfo.getModelInvariantId();
- relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion();
- relatedInstanceModelCustomizationName = relatedInstanceModelInfo.getModelCustomizationName();
- }
- }
-
- if(modelInfo.getModelType().equals(ModelType.vnf)) {
- // a. For a vnf request (only create, no update currently):
- // i. (v3-v4) If modelInfo.modelCustomizationId is provided, use it to validate catalog DB has record in vnf_resource_customization.model_customization_uuid.
- // ii. (v2-v4) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or pre-v3), then modelInfo.modelCustomizationName must have
- // been provided (else create request should be rejected). APIH should use the relatedInstance.modelInfo[service].modelVersionId** + modelInfo[vnf].modelCustomizationName
- // to “join” service_to_resource_customizations with vnf_resource_customization to confirm a vnf_resource_customization.model_customization_uuid record exists.
- // **If relatedInstance.modelInfo[service].modelVersionId was not provided, use relatedInstance.modelInfo[service].modelInvariantId + modelVersion instead to lookup modelVersionId
- // (MODEL_UUID) in SERVICE table.
- // iii. Regardless of how the value was provided/obtained above, APIH must always populate vnfModelCustomizationId in bpmnRequest. It would be assumed it was MSO generated
- // during 1707 data migration if VID did not provide it originally on request.
- // iv. Note: continue to construct the “vnf-type” value and pass to BPMN (must still be populated in A&AI).
- // 1. If modelCustomizationName is NOT provided on a vnf/vfModule request, use modelCustomizationId to look it up in our catalog to construct vnf-type value to pass to BPMN.
-
- VnfResource vnfResource = null;
- VnfResourceCustomization vrc;
- // Validation for vnfResource
-
- if(modelCustomizationId!=null) {
- vnfResource = db.getVnfResourceByModelCustomizationId(modelCustomizationId);
- } else {
- Service service = db.getServiceByModelUUID(relatedInstanceModelVersionId);
- if(service == null) {
- service = db.getServiceByVersionAndInvariantId(relatedInstanceModelInvariantId, relatedInstanceVersion);
- }
-
- if(service == null) {
- throw new ValidationException("service in relatedInstance");
- }
-
- vrc = db.getVnfResourceCustomizationByModelCustomizationName(modelCustomizationName, service.getModelUUID());
- if(vrc != null) {
- vnfResource = vrc.getVnfResource();
- modelInfo.setModelCustomizationId(vrc.getModelCustomizationUuid());
- modelInfo.setModelCustomizationUuid(vrc.getModelCustomizationUuid());
- }
- }
-
- if(vnfResource==null){
- throw new ValidationException("catalog entry");
- } else {
- if(modelInfo.getModelVersionId() == null) {
- modelInfo.setModelVersionId(vnfResource.getModelUuid());
- }
- }
-
- VnfRecipe vnfRecipe = db.getVnfRecipe(defaultSource, action.name());
-
- if (vnfRecipe == null) {
- return null;
- }
-
- return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout());
- } else {
- // ii. (v2-v4) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or pre-v3), then modelInfo.modelCustomizationName must have
- // been provided (else create request should be rejected). APIH should use the relatedInstance.modelInfo[vnf].modelVersionId** + modelInfo[vnf].modelCustomizationName
- // to “join” vnf_to_resource_customizations with vf_resource_customization to confirm a vf_resource_customization.model_customization_uuid record exists.
- // **If relatedInstance.modelInfo[vnf].modelVersionId was not provided, use relatedInstance.modelInfo[vnf].modelInvariantId + modelVersion instead
- // to lookup modelVersionId (MODEL_UUID) in vnf_resource table. Once the vnf’s model_customization_uuid has been obtained, use it to find all vfModule customizations
- // for that vnf customization in the vnf_res_custom_to_vf_module_custom join table. For each vf_module_cust_model_customization_uuid value returned,
- // use that UUID to query vf_module_customization table along with modelInfo[vfModule|volumeGroup].modelVersionId** to confirm record matches request data
- // (and to identify the modelCustomizationId associated with the vfModule in the request). **If modelInfo[vfModule|volumeGroup].modelVersionId was not
- // provided (potentially in v2/v3), use modelInfo[vfModule|volumeGroup].modelInvariantId + modelVersion instead. This means taking each record found
- // in vf_module_customization and looking up in vf_module (using vf_module_customization’s FK into vf_module) to find a match on MODEL_INVARIANT_UUID (modelInvariantId)
- // and MODEL_VERSION (modelVersion).
-
- VfModuleCustomization vfmc = null;
- VnfResourceCustomization vnfrc;
- VfModule vfModule = null;
-
- if( modelInfo.getModelCustomizationId() != null) {
- vfmc = db.getVfModuleCustomizationByModelCustomizationId(modelInfo.getModelCustomizationId());
- } else {
- vnfrc =db.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId(relatedInstanceModelCustomizationName, relatedInstanceModelVersionId);
- if(vnfrc == null) {
- vnfrc = db.getVnfResourceCustomizationByModelInvariantId(relatedInstanceModelInvariantId, relatedInstanceVersion, relatedInstanceModelCustomizationName);
- }
-
- List<VfModuleCustomization> list = db.getVfModuleCustomizationByVnfModuleCustomizationUuid(vnfrc.getModelCustomizationUuid());
-
- String vfModuleModelUUID = modelInfo.getModelVersionId();
- for(VfModuleCustomization vf : list) {
- if(vfModuleModelUUID != null) {
- vfModule = db.getVfModuleByModelCustomizationIdAndVersion(vf.getModelCustomizationUuid(), vfModuleModelUUID);
- } else {
- vfModule = db.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId(vf.getModelCustomizationUuid(), modelInfo.getModelVersion(), modelInfo.getModelInvariantId());
- }
-
- if(vfModule != null) {
- modelInfo.setModelCustomizationId(vf.getModelCustomizationUuid());
- modelInfo.setModelCustomizationUuid(vf.getModelCustomizationUuid());
- break;
- }
- }
- }
-
- if(vfmc == null && vfModule == null) {
- throw new ValidationException("no catalog entry found");
- } else if (vfModule == null && vfmc != null) {
- vfModule = vfmc.getVfModule(); // can't be null as vfModuleModelUUID is not-null property in VfModuleCustomization table
- }
-
- if(modelInfo.getModelVersionId() == null) {
- modelInfo.setModelVersionId(vfModule.getModelUUID());
- }
- recipe = db.getVnfComponentsRecipeByVfModuleModelUUId(vfModule.getModelUUID(), vnfComponentType, action.name());
-
- if(recipe == null) {
- recipe = db.getVnfComponentsRecipeByVfModuleModelUUId(defaultSource, vnfComponentType, action.name());
- if (recipe == null) {
- recipe = db.getVnfComponentsRecipeByVfModuleModelUUId("*", vnfComponentType, action.name());
- }
-
- if(recipe == null) {
- return null;
- }
- }
- }
- } else {
- msoLogger.debug("recipe is null, getting default");
-
- if(modelInfo.getModelType().equals(ModelType.vnf)) {
- recipe = db.getVnfRecipe(defaultSource, action.name());
- if (recipe == null) {
- return null;
- }
- } else {
- recipe = db.getVnfComponentsRecipeByVfModuleModelUUId(defaultSource, vnfComponentType, action.name());
-
- if (recipe == null) {
- return null;
- }
- }
- }
-
- return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
- }
-
- private RecipeLookupResult getDefaultVnfUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
-
- String defaultSource = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
-
- VnfRecipe vnfRecipe = db.getVnfRecipe(defaultSource, action.name());
-
- if (vnfRecipe == null) {
- return null;
- }
-
- return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout());
- }
-
- private RecipeLookupResult getNetworkUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
-
- String defaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
-
- ModelInfo modelInfo = msoRequest.getModelInfo();
- String modelName = modelInfo.getModelName();
- Recipe recipe = null;
-
- if(modelInfo.getModelCustomizationId()!=null){
- NetworkResource networkResource = db.getNetworkResourceByModelCustUuid(modelInfo.getModelCustomizationId());
- if(networkResource!=null){
- if(modelInfo.getModelVersionId() == null) {
- modelInfo.setModelVersionId(networkResource.getModelUUID());
- }
- recipe = db.getNetworkRecipe(networkResource.getModelName(), action.name());
- }else{
- throw new ValidationException("no catalog entry found");
- }
- }else{
- //ok for version < 3 and action delete
- recipe = db.getNetworkRecipe(modelName, action.name());
- }
-
- if(recipe == null){
- recipe = db.getNetworkRecipe(defaultNetworkType, action.name());
- }
-
- return recipe !=null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null;
- }
-
- private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String,String> instanceIdMap, String version) {
- String requestId = UUIDChecker.generateUUID(msoLogger);
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("requestId is: " + requestId);
- ServiceInstancesRequest sir = null;
- MsoRequest msoRequest = new MsoRequest (requestId);
-
- try {
- sir = convertJsonToServiceInstanceRequest(requestJSON, action, startTime, msoRequest);
- } catch(Exception e) {
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- parseRequest(requestJSON, action, instanceIdMap, version, startTime, sir, msoRequest);
- } catch(Exception e) {
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
- String requestScope;
- if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){
- requestScope = (ModelType.vnf.name());
- }else{
- requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
- }
- InfraActiveRequests dup = null;
-
- try {
- dup = duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope);
- } catch(Exception e) {
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
- e.getMessage(),
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- if (dup != null) {
- return buildErrorOnDuplicateRecord(action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup);
- }
-
- ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
- RequestReferences referencesResponse = new RequestReferences();
- referencesResponse.setRequestId(requestId);
- serviceResponse.setRequestReferences(referencesResponse);
-
- MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties ();
- String orchestrationUri = props.getProperty(CommonConstants.ALACARTE_ORCHESTRATION, null);
- String timeOut = props.getProperty(CommonConstants.ALACARTE_RECIPE_TIMEOUT, null);
-
- if (StringUtils.isBlank(orchestrationUri) || StringUtils.isBlank(timeOut)) {
- String error = StringUtils.isBlank(orchestrationUri) ? "ALaCarte Orchestration URI not found in properties" : "ALaCarte Recipe Timeout not found in properties";
-
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.DataError, error);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- error,
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR,
- null);
- msoRequest.createRequestRecord (Status.FAILED, action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, error);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
-
- }
-
- requestId = msoRequest.getRequestId ();
- msoLogger.debug ("requestId is: " + requestId);
- msoLogger.debug ("About to insert a record");
-
- try {
- createRequestRecord(action, startTime, msoRequest);
- } catch(Exception e) {
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- "Exception while creating record in DB " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER,
- null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- return postBPELRequest(action, startTime, msoRequest, orchestrationUri, Integer.parseInt(timeOut), false);
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java
deleted file mode 100644
index 9aac16aa4c..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*-
- * #%L
- * MSO
- * %%
- * Copyright (C) 2016 ONAP - SO
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-package org.openecomp.mso.apihandlerinfra;
-
-import org.openecomp.mso.apihandlerinfra.tasksbeans.*;
-
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandler.common.RequestClient;
-import org.openecomp.mso.apihandler.common.RequestClientFactory;
-import org.openecomp.mso.apihandler.common.ResponseHandler;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoAlarmLogger;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/tasks")
-@Api(value="/tasks/{version: [vV]1}",description="Queries of Manual Tasks")
-public class TasksHandler {
-
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- public final static String requestUrl = "mso/task/";
-
- @Path("/{version:[vV]1}")
- @GET
- @ApiOperation(value="Finds Manual Tasks",response=Response.class)
- public Response queryFilters (@QueryParam("taskId") String taskId,
- @QueryParam("originalRequestId") String originalRequestId,
- @QueryParam("subscriptionServiceType") String subscriptionServiceType,
- @QueryParam("nfRole") String nfRole,
- @QueryParam("buildingBlockName") String buildingBlockName,
- @QueryParam("originalRequestDate") String originalRequestDate,
- @QueryParam("originalRequestorId") String originalRequestorId,
- @PathParam("version") String version) throws ParseException {
- Response responseBack = null;
- long startTime = System.currentTimeMillis ();
- String requestId = UUIDChecker.generateUUID(msoLogger);
- MsoLogger.setServiceName ("ManualTasksQuery");
- // Generate a Request Id
- UUIDChecker.generateUUID(msoLogger);
- msoLogger.debug ("Incoming request received for queryFilter with taskId:" + taskId
- + " originalRequestId:" + originalRequestId
- + " subscriptionServiceType:" + subscriptionServiceType
- + " nfRole:" + nfRole
- + " buildingBlockName:" + buildingBlockName
- + " originalRequestDate:" + originalRequestDate
- + " originalRequestorId: " + originalRequestorId);
-
- // Prepare the query string to /task interface
- TaskVariables tv = new TaskVariables();
-
- List<TaskVariableValue> tvvList = new ArrayList<>();
-
- if (originalRequestId != null) {
- TaskVariableValue tvv = new TaskVariableValue();
- tvv.setName("originalRequestId");
- tvv.setValue(originalRequestId);
- tvv.setOperator("eq");
- tvvList.add(tvv);
- }
- if (subscriptionServiceType != null) {
- TaskVariableValue tvv = new TaskVariableValue();
- tvv.setName("subscriptionServiceType");
- tvv.setValue(subscriptionServiceType);
- tvv.setOperator("eq");
- tvvList.add(tvv);
- }
- if (nfRole != null) {
- TaskVariableValue tvv = new TaskVariableValue();
- tvv.setName("nfRole");
- tvv.setValue(nfRole);
- tvv.setOperator("eq");
- tvvList.add(tvv);
- }
- if (buildingBlockName != null) {
- TaskVariableValue tvv = new TaskVariableValue();
- tvv.setName("buildingBlockName");
- tvv.setValue(buildingBlockName);
- tvv.setOperator("eq");
- tvvList.add(tvv);
- }
- if (originalRequestDate != null) {
- TaskVariableValue tvv = new TaskVariableValue();
- tvv.setName("originalRequestDate");
- tvv.setValue(originalRequestDate);
- tvv.setOperator("eq");
- tvvList.add(tvv);
- }
- if (originalRequestorId != null) {
- TaskVariableValue tvv = new TaskVariableValue();
- tvv.setName("originalRequestorId");
- tvv.setValue(originalRequestorId);
- tvv.setOperator("eq");
- tvvList.add(tvv);
- }
-
- tv.setTaskVariables(tvvList);
-
- RequestClient requestClient = null;
- MsoRequest msoRequest = new MsoRequest(requestId);
- HttpResponse response = null;
- long subStartTime = System.currentTimeMillis();
-
- try {
- requestClient = RequestClientFactory.getRequestClient (requestUrl, MsoPropertiesUtils.loadMsoProperties ());
- // Capture audit event
- msoLogger.debug ("MSO API Handler Post call to Camunda engine for url: " + requestClient.getUrl ());
-
- System.out.println("URL : " + requestClient.getUrl ());
- ObjectMapper mapper = new ObjectMapper();
- String camundaJsonReq = mapper.writeValueAsString(tv);
- msoLogger.debug("Camunda Json Request: " + camundaJsonReq);
- response = requestClient.post(camundaJsonReq);
-
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null);
- } catch (Exception e) {
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException,
- "Failed calling bpmn " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- alarmLogger.sendAlarm ("MsoConfigurationError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity (),e);
- return resp;
- }
- TasksGetResponse trr = new TasksGetResponse();
- List<TaskList> taskList = new ArrayList<>();
-
- ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
- int bpelStatus = respHandler.getStatus ();
- if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) {
- msoLogger.debug ("Received good response from Camunda");
-
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN completed the request");
- String respBody = respHandler.getContent();
- if (respBody != null) {
- JSONArray data = new JSONArray(respBody);
-
- for (int i=0; i<data.length();i++) {
- JSONObject taskEntry = data.getJSONObject(i);
- String id = taskEntry.getString("id");
- msoLogger.debug("taskId is: " + id);
- if (taskId != null && !taskId.equals(id)) {
- continue;
- }
- // Get variables info for each task ID
- TaskList taskListEntry = null;
- try {
- taskListEntry = getTaskInfo(id);
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null);
- } catch (Exception e) {
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException,
- "Failed calling bpmn " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- alarmLogger.sendAlarm ("MsoConfigurationError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
-
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity (),e);
- return resp;
- }
- taskList.add(taskListEntry);
-
- }
- trr.setTaskList(taskList);
- }
-
- } else {
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
- MsoException.ServiceException,
- "Request Failed due to BPEL error with HTTP Status= %1" ,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
-
- String jsonResponse = null;
- try {
- ObjectMapper mapper = new ObjectMapper();
- jsonResponse = mapper.writeValueAsString(trr);
- }
- catch (Exception e) {
- msoLogger.debug("Unable to format response",e);
- Response resp = msoRequest.buildServiceErrorResponse(500,
- MsoException.ServiceException,
- "Request Failed due to bad response format" ,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Bad response format");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Bad response format");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
-
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
- responseBack = Response.status (HttpStatus.SC_ACCEPTED).entity (jsonResponse).build ();
- return responseBack;
-
- }
-
- protected MsoLogger getMsoLogger () {
- return msoLogger;
- }
-
- // Makes a GET call to Camunda to get variables for this task
- private TaskList getTaskInfo(String taskId) throws Exception {
- TaskList taskList;
- String getRequestUrl = requestUrl + taskId + "/variables";
- HttpResponse getResponse;
- long subStartTime = System.currentTimeMillis();
-
- RequestClient requestClient = RequestClientFactory.getRequestClient (getRequestUrl, MsoPropertiesUtils.loadMsoProperties ());
- // Capture audit event
- msoLogger.debug ("MSO API Handler Get call to Camunda engine for url: " + requestClient.getUrl ());
- getResponse = requestClient.get();
-
- ResponseHandler respHandler = new ResponseHandler (getResponse, requestClient.getType ());
- int bpelStatus = respHandler.getStatus ();
- if (bpelStatus == HttpStatus.SC_ACCEPTED) {
- msoLogger.debug ("Received good response from Camunda");
-
- msoLogger.recordAuditEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN completed the request");
- String respBody = respHandler.getContent();
- if (respBody != null) {
- taskList = buildTaskList(taskId, respBody);
- }
- else {
- throw new Exception("Null task info from Camunda");
- }
-
- }
- else {
- throw new Exception ("Bad GET response from Camunda. Status is " + bpelStatus);
- }
-
- return taskList;
-
- }
-
- private TaskList buildTaskList(String taskId, String respBody) throws ParseException {
- TaskList taskList = new TaskList();
- JSONObject variables = new JSONObject(respBody);
-
- taskList.setTaskId(taskId);
- taskList.setType(getOptVariableValue(variables, "type"));
- taskList.setNfRole(getOptVariableValue(variables, "nfRole"));
- taskList.setSubscriptionServiceType(getOptVariableValue(variables, "subscriptionServiceType"));
- taskList.setOriginalRequestId(getOptVariableValue(variables, "originalRequestId"));
- taskList.setOriginalRequestorId(getOptVariableValue(variables, "originalRequestorId"));
- taskList.setErrorSource(getOptVariableValue(variables, "errorSource"));
- taskList.setErrorCode(getOptVariableValue(variables, "errorCode"));
- taskList.setErrorMessage(getOptVariableValue(variables, "errorMessage"));
- taskList.setBuildingBlockName(getOptVariableValue(variables, "buildingBlockName"));
- taskList.setBuildingBlockStep(getOptVariableValue(variables, "buildingBlockStep"));
- taskList.setValidResponses(new JSONArray("[" + getOptVariableValue(variables, "validResponses").toLowerCase() + "]"));
-
- return taskList;
- }
-
- private String getOptVariableValue(JSONObject variables, String name) throws ParseException {
- String variableEntry = variables.optString(name);
- String value = "";
- if (!variableEntry.isEmpty()) {
- JSONObject variableEntryJson = new JSONObject(variableEntry);
- value = variableEntryJson.optString("value");
- }
- return value;
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestration.java
deleted file mode 100644
index ecbe97c637..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudOrchestration.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
-
-
-import java.util.HashMap;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpStatus;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.MsoException;
-import org.openecomp.mso.apihandlerinfra.Status;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestReferences;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.TenantSyncResponse;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/cloudResources")
-@Api(value="/cloudResources",description="API Requests for cloud resources - Tenant Isolation")
-public class CloudOrchestration {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private TenantIsolationRunnable tenantIsolation = null;
- private TenantIsolationRequest tenantIsolationRequest = null;
- private RequestsDatabase requestsDatabase = null;
-
- @POST
- @Path("/{version:[vV][1]}/operationalEnvironments")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Create an Operational Environment",response=Response.class)
- public Response createOperationEnvironment(String request, @PathParam("version") String version) {
- msoLogger.debug("Received request to Create Operational Environment");
- return cloudOrchestration(request, Action.create, null, version);
- }
-
- @POST
- @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/activate")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Activate an Operational Environment",response=Response.class)
- public Response activateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId) {
- msoLogger.debug("Received request to Activate an Operational Environment");
- HashMap<String, String> instanceIdMap = new HashMap<String,String>();
- instanceIdMap.put("operationalEnvironmentId", operationalEnvironmentId);
- return cloudOrchestration(request, Action.activate, instanceIdMap, version);
- }
-
- @POST
- @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/deactivate")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Deactivate an Operational Environment",response=Response.class)
- public Response deactivateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId) {
- msoLogger.debug("Received request to Deactivate an Operational Environment");
- HashMap<String, String> instanceIdMap = new HashMap<String,String>();
- instanceIdMap.put("operationalEnvironmentId", operationalEnvironmentId);
- return cloudOrchestration(request, Action.deactivate, instanceIdMap, version);
- }
-
-
- private Response cloudOrchestration(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version) {
- String requestId = UUIDChecker.generateUUID(msoLogger);
- long startTime = System.currentTimeMillis ();
- CloudOrchestrationRequest cor = null;
- Response response = null;
- getTenantIsolationRequest().setRequestId(requestId);
-
- try {
- cor = convertJsonToCloudOrchestrationRequest(requestJSON, action, startTime, cor);
- } catch(Exception e) {
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER,
- null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- getTenantIsolationRequest().parse(cor, instanceIdMap, action);
- } catch(Exception e) {
- msoLogger.debug ("Validation failed: ", e);
- if (getTenantIsolationRequest().getRequestId () != null) {
- msoLogger.debug ("Logging failed message to the database");
- getTenantIsolationRequest().createRequestRecord (Status.FAILED, action);
- }
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- String instanceName = cor.getRequestDetails().getRequestInfo().getInstanceName();
- String resourceType = cor.getRequestDetails().getRequestInfo().getResourceType().name();
- InfraActiveRequests dup = null;
- String messageAppend = null;
- try {
- dup = duplicateCheck(action, instanceIdMap, startTime, instanceName, resourceType);
-
- if(dup != null) {
- messageAppend = "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - " + dup.getRequestId() + ").";
- }
- } catch(Exception e) {
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- e.getMessage(),
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- if(dup == null && (Action.activate.equals(action) || Action.deactivate.equals(action))) {
- dup = getRequestsDatabase().checkVnfIdStatus(cor.getOperationalEnvironmentId());
- if(dup != null) {
- messageAppend = "OperationalEnvironmentId is not COMPLETED.";
- }
- }
- } catch(Exception e) {
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- e.getMessage(),
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- if(dup != null) {
- String instance = null;
- if(instanceName != null){
- instance = instanceName;
- }else{
- instance = instanceIdMap.get(resourceType + "InstanceId");
- }
- String dupMessage = "Error: Locked instance - This " + resourceType + " (" + instance + ") " + messageAppend + " The existing request must finish or be cleaned up before proceeding.";
-
- response = getTenantIsolationRequest().buildServiceErrorResponse(HttpStatus.SC_CONFLICT,
- MsoException.ServiceException,
- dupMessage,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
-
- msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError, dupMessage);
- getTenantIsolationRequest().createRequestRecord (Status.FAILED, action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- String instanceId = null;
- try {
- if(instanceIdMap != null && instanceIdMap.get("operationalEnvironmentId") != null) {
- instanceId = instanceIdMap.get("operationalEnvironmentId");
- } else {
- instanceId = UUIDChecker.generateUUID(msoLogger);
- getTenantIsolationRequest().setOperationalEnvironmentId(instanceId);
- cor.setOperationalEnvironmentId(instanceId);
- }
-
- msoLogger.debug("Creating record in Request DB");
- getTenantIsolationRequest().createRequestRecord(Status.IN_PROGRESS, action);
- } catch(Exception e) {
- response = getTenantIsolationRequest().buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- "Exception while creating record in DB " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER,
- null);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- OperationalEnvironment opEnv = cor.getRequestDetails().getRequestParameters().getOperationalEnvironmentType();
- String operationalEnvType = opEnv != null ? opEnv.name() : null;
-
- TenantIsolationRunnable runnable = getThread();
- runnable.setAction(action);
- runnable.setCor(cor);
- runnable.setOperationalEnvType(operationalEnvType);
- runnable.setRequestId(requestId);
-
- Thread thread = new Thread(runnable);
- thread.start();
- } catch(Exception e) {
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while creating a new Thread", "APIH", null, null);
- response = getTenantIsolationRequest().buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- "Failed creating a Thread " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- getTenantIsolationRequest().updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, "Exception while creating a new Thread");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, "Exception while creating a new Thread");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- String encodedValue = new String(instanceId.getBytes("UTF-8"));
- msoLogger.debug ("InstanceId: " + instanceId + " encoded to " + encodedValue);
-
- TenantSyncResponse tenantResponse = new TenantSyncResponse();
- RequestReferences reqReference = new RequestReferences();
- reqReference.setInstanceId(encodedValue);
- reqReference.setRequestId(requestId);
- tenantResponse.setRequestReferences(reqReference);
-
- response = Response.ok(tenantResponse).build();
-
- msoLogger.debug ("Successful Sync response " + response.getEntity() + " with status code " + response.getStatus());
-
- return response;
- } catch(Exception e) {
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while building sync response", "APIH", null, null);
- response = getTenantIsolationRequest().buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- "Failed sending Sync Response " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- getTenantIsolationRequest().updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, "Exception while sending sync Response");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, "Exception while sending sync Response");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
- }
-
- private InfraActiveRequests duplicateCheck(Action action, HashMap<String, String> instanceIdMap, long startTime,
- String instanceName, String requestScope) throws Exception {
- InfraActiveRequests dup = null;
- try {
- dup = getRequestsDatabase().checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Error during duplicate check");
- throw new Exception(e);
- }
- return dup;
- }
-
- private CloudOrchestrationRequest convertJsonToCloudOrchestrationRequest(String requestJSON, Action action, long startTime,
- CloudOrchestrationRequest cor) throws Exception {
- CloudOrchestrationRequest new_cor = null;
- try{
- msoLogger.debug("Converting incoming JSON request to Object");
- ObjectMapper mapper = new ObjectMapper();
- new_cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
- } catch(Exception e){
- msoLogger.debug ("Mapping of request to JSON object failed : ", e);
- if (getTenantIsolationRequest().getRequestId () != null) {
- msoLogger.debug ("Mapping of request to JSON object failed");
- getTenantIsolationRequest().createRequestRecord (Status.FAILED, action);
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- throw new Exception(e);
- }
- return new_cor;
- }
-
- public TenantIsolationRequest getTenantIsolationRequest() {
- if(tenantIsolationRequest == null) {
- tenantIsolationRequest = new TenantIsolationRequest();
- }
- return tenantIsolationRequest;
- }
-
- public void setTenantIsolationRequest(TenantIsolationRequest tenantIsolationRequest) {
- this.tenantIsolationRequest = tenantIsolationRequest;
- }
-
- public RequestsDatabase getRequestsDatabase() {
- if(requestsDatabase == null) {
- requestsDatabase = RequestsDatabase.getInstance();
- }
- return requestsDatabase;
- }
-
- public void setRequestsDatabase(RequestsDatabase requestsDatabase) {
- this.requestsDatabase = requestsDatabase;
- }
-
- public TenantIsolationRunnable getThread() {
- if(tenantIsolation == null) {
- tenantIsolation = new TenantIsolationRunnable();
- }
- return tenantIsolation;
- }
-
- public void setThread(TenantIsolationRunnable thread) {
- this.tenantIsolation = thread;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
deleted file mode 100644
index a580a483c2..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.http.HttpStatus;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.Messages;
-import org.openecomp.mso.apihandlerinfra.MsoException;
-import org.openecomp.mso.apihandlerinfra.Status;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.CloudOrchestrationRequestList;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.InstanceReferences;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Request;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestDetails;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.RequestStatus;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoAlarmLogger;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
-import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.utils.UUIDChecker;
-
-import com.wordnik.swagger.annotations.Api;
-import com.wordnik.swagger.annotations.ApiOperation;
-
-@Path("/cloudResourcesRequests")
-@Api(value="/cloudResourcesRequests",description="API GET Requests for cloud resources - Tenant Isolation")
-public class CloudResourcesOrchestration {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
- private RequestsDatabase requestsDB = null;
-
- @POST
- @Path("/{version: [vV][1]}/{requestId}/unlock")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Unlock CloudOrchestration requests for a specified requestId")
- public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) {
- TenantIsolationRequest msoRequest = new TenantIsolationRequest(requestId);
- InfraActiveRequests requestDB = null;
- Request request = null;
- CloudOrchestrationRequest cor = null;
-
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("requestId is: " + requestId);
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class);
- } catch(Exception e){
- msoLogger.debug ("Mapping of request to JSON object failed : ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Mapping of request to JSON object failed");
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try{
- msoRequest.parseOrchestration(cor);
- } catch (Exception e) {
- msoLogger.debug ("Validation failed: ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Logging failed message to the database");
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- try {
- requestDB = getRequestsDB().getRequestFromInfraActive(requestId);
-
- if(requestDB == null) {
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "Orchestration RequestId " + requestId + " is not found in DB",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
-
- }else{
- request = mapInfraActiveRequestToRequest(requestDB);
- RequestStatus reqStatus = request.getRequestStatus();
- Status status = Status.valueOf(reqStatus.getRequestState());
- if(status == Status.IN_PROGRESS || status == Status.PENDING || status == Status.PENDING_MANUAL_TASK){
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.UNLOCKED);
- reqStatus.setRequestState(Status.UNLOCKED.toString ());
- getRequestsDB().updateInfraStatus (requestId,
- Status.UNLOCKED.toString (),
- Constants.MODIFIED_BY_APIHANDLER);
-
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "RequestId " + requestId + " has been unlocked");
-
- }else{
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException,
- "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
- }
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- e.getMessage (),
- ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.getErrors().get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
-
- }
-
- return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build ();
- }
-
- @GET
- @Path("/{version:[vV][1]}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @ApiOperation(value="Get status of an Operational Environment based on filter criteria",response=Response.class)
- public Response getOperationEnvironmentStatusFilter(@Context UriInfo ui, @PathParam("version") String version ) {
- MsoLogger.setServiceName ("getOperationEnvironmentStatusFilter");
- UUIDChecker.generateUUID(msoLogger);
- long startTime = System.currentTimeMillis ();
-
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- List<String> requestIdKey = queryParams.get("requestId");
-
- if(queryParams.size() == 1 && requestIdKey != null) {
- msoLogger.debug ("Entered requestId GET OperationalEnvironment Request");
- String requestId = requestIdKey.get(0);
-
- CloudOrchestrationResponse cloudOrchestrationGetResponse = new CloudOrchestrationResponse();
- TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest (requestId);
- InfraActiveRequests requestDB = null;
-
- try {
- requestDB = getRequestsDB().getRequestFromInfraActive(requestId);
-
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e);
- // TODO Will need to set Status for tenantIsolationRequest
- // tenantIsolationRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = tenantIsolationRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- e.getMessage (),
- ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.getErrors().get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- if(requestDB == null) {
- Response resp = tenantIsolationRequest.buildServiceErrorResponse (HttpStatus.SC_NO_CONTENT,
- MsoException.ServiceException,
- "Orchestration RequestId " + requestId + " is not found in DB",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
- Request request = mapInfraActiveRequestToRequest(requestDB);
- cloudOrchestrationGetResponse.setRequest(request);
- return Response.status(200).entity(cloudOrchestrationGetResponse).build();
-
- } else {
- msoLogger.debug ("Entered GET OperationalEnvironment filter Request");
- TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest ();
- List<InfraActiveRequests> activeRequests = null;
- CloudOrchestrationRequestList orchestrationList = null;
-
- try{
- Map<String, String> orchestrationMap = tenantIsolationRequest.getOrchestrationFilters(queryParams);
- activeRequests = getRequestsDB().getCloudOrchestrationFiltersFromInfraActive(orchestrationMap);
- orchestrationList = new CloudOrchestrationRequestList();
- List<CloudOrchestrationResponse> requestLists = new ArrayList<CloudOrchestrationResponse>();
-
- for(InfraActiveRequests infraActive : activeRequests){
-
- Request request = mapInfraActiveRequestToRequest(infraActive);
- CloudOrchestrationResponse requestList = new CloudOrchestrationResponse();
- requestList.setRequest(request);
- requestLists.add(requestList);
- }
- orchestrationList.setRequestList(requestLists);
-
- }catch(Exception e){
- msoLogger.debug ("Get Orchestration Request with Filters Failed : ", e);
- Response response = tenantIsolationRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
- "Get CloudOrchestration Request with Filters Failed. " + e.getMessage(),
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Get Orchestration Request with Filters Failed : " + e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Get CloudOrchestration Request with Filters Failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
- return Response.status(200).entity(orchestrationList).build();
- }
- }
-
- private Request mapInfraActiveRequestToRequest(InfraActiveRequests requestDB) {
- Request request = new Request();
- request.setRequestId(requestDB.getRequestId());
- request.setRequestScope(requestDB.getRequestScope());
- request.setRequestType(requestDB.getRequestAction());
-
- InstanceReferences ir = new InstanceReferences();
-
- if(requestDB.getOperationalEnvId() != null)
- ir.setOperationalEnvironmentId(requestDB.getOperationalEnvId());
- if(requestDB.getOperationalEnvName() != null)
- ir.setOperationalEnvName(requestDB.getOperationalEnvName());
- if(requestDB.getRequestorId() != null)
- ir.setRequestorId(requestDB.getRequestorId());
-
- request.setInstanceReferences(ir);
- String requestBody = requestDB.getRequestBody();
- RequestDetails requestDetails = null;
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- requestDetails = mapper.readValue(requestBody, RequestDetails.class);
-
- }catch(Exception e){
- msoLogger.debug("Exception caught mapping requestBody to RequestDetails");
- }
-
- request.setRequestDetails(requestDetails);
- String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getStartTime()) + " GMT";
- request.setStartTime(startTimeStamp);
-
- RequestStatus status = new RequestStatus();
- if(requestDB.getStatusMessage() != null){
- status.setStatusMessage(requestDB.getStatusMessage());
- }
-
- if(requestDB.getEndTime() != null){
- String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getEndTime()) + " GMT";
- status.setTimeStamp(endTimeStamp);
- }
-
- if(requestDB.getRequestStatus() != null){
- status.setRequestState(requestDB.getRequestStatus());
- }
-
- if(requestDB.getProgress() != null){
- status.setPercentProgress(requestDB.getProgress().toString());
- }
-
- request.setRequestStatus(status);
-
- return request;
- }
-
- public RequestsDatabase getRequestsDB() {
- if(requestsDB == null) {
- requestsDB = RequestsDatabase.getInstance();
- }
- return requestsDB;
- }
-
- public void setRequestsDB(RequestsDatabase requestsDB) {
- this.requestsDB = requestsDB;
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/OperationalEnvironmentProcessFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/OperationalEnvironmentProcessFactory.java
deleted file mode 100644
index e39c1d7ef1..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/OperationalEnvironmentProcessFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.ActivateVnfOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.ActivateVnfStatusOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.CreateEcompOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.CreateVnfOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.DeactivateVnfOperationalEnvironment;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.OperationalEnvironmentProcess;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
-
-public class OperationalEnvironmentProcessFactory {
-
- public OperationalEnvironmentProcess getOperationalEnvironmentProcess(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws Exception{
-
- if(Action.create.equals(action)) {
- if(OperationalEnvironment.ECOMP.name().equalsIgnoreCase(operationalEnvType)) {
- return new CreateEcompOperationalEnvironment(cor, requestId);
- } else if(OperationalEnvironment.VNF.name().equalsIgnoreCase(operationalEnvType)) {
- return new CreateVnfOperationalEnvironment(cor, requestId);
- } else {
- throw new Exception("Invalid OperationalEnvironment Type specified for Create Action");
- }
- } else if(Action.activate.equals(action)) {
- return new ActivateVnfOperationalEnvironment(cor, requestId);
- } else if(Action.deactivate.equals(action)) {
- return new DeactivateVnfOperationalEnvironment(cor, requestId);
- } else if(Action.distributionStatus.equals(action)) {
- return new ActivateVnfStatusOperationalEnvironment(cor, requestId);
- } else {
- throw new Exception("Invalid Action specified: " + action);
- }
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
deleted file mode 100644
index 167b88fbc8..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation;
-
-import org.openecomp.mso.apihandlerinfra.Constants;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.process.OperationalEnvironmentProcess;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Action;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-
-public class TenantIsolationRunnable implements Runnable {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
- private OperationalEnvironmentProcessFactory factory = null;
- private Action action;
- private String operationalEnvType;
- private CloudOrchestrationRequest cor;
- private String requestId;
- protected RequestsDBHelper requestDb;
-
- @Override
- public void run() {
- msoLogger.debug ("Starting threadExecution in TenantIsolationRunnable for Action " + action.name() + " and OperationalEnvType: " + operationalEnvType);
- try {
- OperationalEnvironmentProcess isolation = getFactory().getOperationalEnvironmentProcess(action, operationalEnvType, cor, requestId);
- isolation.execute();
- } catch(Exception e) {
- msoLogger.debug ("Exception during Thread initiation: ", e);
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, null, e);
- getRequestDb().updateInfraFailureCompletion(e.getMessage(), requestId, cor.getOperationalEnvironmentId());
- }
- }
-
- public Action getAction() {
- return action;
- }
-
- public void setAction(Action action) {
- this.action = action;
- }
-
- public String getOperationalEnvType() {
- return operationalEnvType;
- }
-
- public void setOperationalEnvType(String operationalEnvType) {
- this.operationalEnvType = operationalEnvType;
- }
-
- public CloudOrchestrationRequest getCor() {
- return cor;
- }
-
- public void setCor(CloudOrchestrationRequest cor) {
- this.cor = cor;
- }
-
- public String getRequestId() {
- return requestId;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- public OperationalEnvironmentProcessFactory getFactory() {
- if(factory == null) {
- factory = new OperationalEnvironmentProcessFactory();
- }
- return factory;
- }
-
- public void setFactory(OperationalEnvironmentProcessFactory factory) {
- this.factory = factory;
- }
-
- protected RequestsDBHelper getRequestDb() {
- if(requestDb == null) {
- requestDb = new RequestsDBHelper();
- }
- return requestDb;
- }
-
- protected void setRequestsDBHelper(RequestsDBHelper helper) {
- this.requestDb = helper;
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java
deleted file mode 100644
index 1f3457e6e0..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap;
-
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
-"operationalEnvironmentId",
-"operationalEnvironmentName",
-"operationalEnvironmentType",
-"tenantContext",
-"workloadContext"
-})
-
-public class CreateEcompOperationEnvironmentBean {
-
-@JsonProperty("operationalEnvironmentId")
-private String operationalEnvironmentId;
-@JsonProperty("operationalEnvironmentName")
-private String operationalEnvironmentName;
-@JsonProperty("operationalEnvironmentType")
-private String operationalEnvironmentType;
-@JsonProperty("tenantContext")
-private String tenantContext;
-@JsonProperty("workloadContext")
-private String workloadContext;
-@JsonProperty("action")
-private String action;
-
-
-/**
-* No args constructor for use in serialization
-*
-*/
-public CreateEcompOperationEnvironmentBean() {
- }
-
-/**
-*
-* @param operationalEnvironmentId
-* @param operationalEnvironmentName
-* @param operationalEnvironmentType
-* @param tenantContext
-* @param workloadContext
-*/
-public CreateEcompOperationEnvironmentBean(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String tenantContext, String workloadContext, String action) {
-super();
-this.operationalEnvironmentId = operationalEnvironmentId;
-this.operationalEnvironmentName = operationalEnvironmentName;
-this.operationalEnvironmentType = operationalEnvironmentType;
-this.tenantContext = tenantContext;
-this.workloadContext = workloadContext;
-this.action = action;
- }
-
-@JsonProperty("operationalEnvironmentId")
-public String getOperationalEnvironmentId() {
-return operationalEnvironmentId;
- }
-
-@JsonProperty("operationalEnvironmentId")
-public void setOperationalEnvironmentId(String operationalEnvironmentId) {
-this.operationalEnvironmentId = operationalEnvironmentId;
- }
-
-public CreateEcompOperationEnvironmentBean withOperationalEnvironmentId(String operationalEnvironmentId) {
-this.operationalEnvironmentId = operationalEnvironmentId;
-return this;
- }
-
-
-@JsonProperty("operationalEnvironmentName")
-public String getoperationalEnvironmentName() {
-return operationalEnvironmentName;
- }
-
-@JsonProperty("operationalEnvironmentName")
-public void setoperationalEnvironmentName(String operationalEnvironmentName) {
-this.operationalEnvironmentName = operationalEnvironmentName;
- }
-
-public CreateEcompOperationEnvironmentBean withOperationalEnvironmentName(String operationalEnvironmentName) {
-this.operationalEnvironmentName = operationalEnvironmentName;
-return this;
- }
-
-@JsonProperty("operationalEnvironmentType")
-public String getoperationalEnvironmentType() {
-return operationalEnvironmentType;
- }
-
-@JsonProperty("operationalEnvironmentType")
-public void setoperationalEnvironmentType(String operationalEnvironmentType) {
-this.operationalEnvironmentType = operationalEnvironmentType;
- }
-
-public CreateEcompOperationEnvironmentBean withOperationalEnvironmentType(String operationalEnvironmentType) {
-this.operationalEnvironmentType = operationalEnvironmentType;
-return this;
- }
-
-@JsonProperty("tenantContext")
-public String gettenantContext() {
-return tenantContext;
- }
-
-@JsonProperty("tenantContext")
-public void settenantContext(String tenantContext) {
-this.tenantContext = tenantContext;
- }
-
-public CreateEcompOperationEnvironmentBean withTenantContext(String tenantContext) {
-this.tenantContext = tenantContext;
-return this;
- }
-
-@JsonProperty("workloadContext")
-public String getworkloadContext() {
-return workloadContext;
- }
-
-@JsonProperty("workloadContext")
-public void setworkloadContext(String workloadContext) {
-this.workloadContext = workloadContext;
- }
-
-public CreateEcompOperationEnvironmentBean withWorkloadContext(String workloadContext) {
-this.workloadContext = workloadContext;
-return this;
- }
-
-
-@JsonProperty("action")
-public String getaction() {
-return action;
- }
-
-@JsonProperty("action")
-public void setaction(String action) {
-this.action = action;
- }
-
-public CreateEcompOperationEnvironmentBean withaction(String action) {
-this.action = action;
-return this;
- }
-
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
deleted file mode 100644
index c431da66ee..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.helpers;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Map;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed;
-import org.openecomp.mso.client.aai.AAIObjectType;
-import org.openecomp.mso.client.aai.AAIResourcesClient;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
-import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
-import org.openecomp.mso.client.aai.entities.uri.Depth;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class AAIClientHelper {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
-
- public AAIClientHelper() {
- super();
- }
-
- public AAIClientHelper(String serviceName, String requestId) {
- super();
- MsoLogger.setServiceName (serviceName);
- MsoLogger.setLogContext(requestId, "");
- }
-
- /**
- * Get managing ECOMP Environment Info from A&AI
- * @param id = operationalEnvironmentId
- * @return AAIResultWrapper object
- */
- public AAIResultWrapper getAaiOperationalEnvironment(String id) throws Exception {
- try {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
- uri.depth(Depth.ZERO); //Do not return relationships if any
- AAIResourcesClient aaiClient = this.getClient();
- AAIResultWrapper result = aaiClient.get(uri);
- return result;
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
-
- /**
- * Update managing ECOMP Environment Info from A&AI
- * @param id = operationalEnvironmentId
- * @param AAIOperationalEnvironment object
- */
- public void updateAaiOperationalEnvironment(String id, AAIOperationalEnvironment aaiRequest) throws Exception {
- try {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id);
- AAIResourcesClient aaiClient = this.getClient();
- aaiClient.update(uri, aaiRequest);
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
-
- public void updateAaiOperationalEnvironment(String operationalEnvironmentId, Map<String, String> payload) throws Exception {
- try {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironmentId);
- AAIResourcesClient aaiClient = this.getClient();
- aaiClient.update(uri, payload);
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
- /**
- * Create an Operational Environment object in A&AI
- * @param AAIOperationalEnvironment object
- */
- public void createOperationalEnvironment(AAIOperationalEnvironment operationalEnvironment) throws Exception {
- try {
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironment.getOperationalEnvironmentId());
- AAIResourcesClient aaiClient = this.getClient();
- aaiClient.create(uri, operationalEnvironment);
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
- /**
- * Create a relationship between ECOMP managing and VNF Operational Environments
- * @param managingEcompOperationalEnvironmentId
- * @param vnfOperationalEnvironmentId
- * @throws Exception
- */
- public void createRelationship(String managingEcompOperationalEnvironmentId, String vnfOperationalEnvironmentId) throws Exception {
- try {
- AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, managingEcompOperationalEnvironmentId);
- AAIResourceUri vnfEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, vnfOperationalEnvironmentId);
- AAIResourcesClient aaiClient = this.getClient();
- aaiClient.connect(vnfEnvUri, ecompEnvUri);
- }
- catch(Exception ex) {
- logStackTrace(ex);
- throw new AAIClientCallFailed("Call to A&AI failed!", ex);
- }
- }
-
- private void logStackTrace(Exception e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- msoLogger.debug(sw.toString());
- }
-
- protected AAIResourcesClient getClient() {
- return new AAIResourcesClient();
- }
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java
deleted file mode 100644
index 58b78d7e8b..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.helpers;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-
-public class AAIClientObjectBuilder {
-
- private CloudOrchestrationRequest cloudOrchestrationRequest;
-
- public AAIClientObjectBuilder(CloudOrchestrationRequest request) {
- this.cloudOrchestrationRequest = request;
- }
-
- /**
- * Create an AAIOperationalEnvironment object.
- * @param environmentId
- * @param environmentName
- * @param environmentType
- * @param envrionmentStatus
- * @param tenantContext
- * @param workloadContext
- * @return
- * @throws JsonProcessingException
- */
- @Deprecated
- public static AAIOperationalEnvironment createAAIOperationalEnvironment(
- String environmentId,
- String environmentName,
- String environmentType,
- String envrionmentStatus,
- String tenantContext,
- String workloadContext) {
-
- AAIOperationalEnvironment oe = new AAIOperationalEnvironment();
- oe.setOperationalEnvironmentId(environmentId);
- oe.setOperationalEnvironmentName(environmentName);
- oe.setOperationalEnvironmentType(environmentType);
- oe.setOperationalEnvironmentStatus(envrionmentStatus);
- oe.setTenantContext(tenantContext);
- oe.setWorkloadContext(workloadContext);
-
- return oe;
- }
-
-
- public AAIOperationalEnvironment buildAAIOperationalEnvironment(String status) {
- AAIOperationalEnvironment env = new AAIOperationalEnvironment();
- env.setOperationalEnvironmentId(this.cloudOrchestrationRequest.getOperationalEnvironmentId());
- env.setOperationalEnvironmentName(this.cloudOrchestrationRequest.getRequestDetails().getRequestInfo().getInstanceName());
- env.setOperationalEnvironmentType(this.cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString());
- env.setOperationalEnvironmentStatus(status);
- env.setTenantContext(this.cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getTenantContext());
- env.setWorkloadContext(this.cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getWorkloadContext());
- return env;
- }
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelper.java
deleted file mode 100644
index 2575013609..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/helpers/AsdcClientHelper.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.helpers;
-
-import java.util.UUID;
-
-import javax.ws.rs.core.UriBuilder;
-
-import org.json.JSONObject;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.AsdcClientCallFailed;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient;
-import org.openecomp.mso.rest.RESTConfig;
-
-public class AsdcClientHelper {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
- private String className = this.getClass().getSimpleName();
- private String methodName = "";
- private String classMethodMessage = "";
-
- private JSONObject asdcResponseJsonObj;
-
- protected MsoJavaProperties properties;
-
- public static final String ASDC_CONTENT_TYPE = "application/json";
- public static final String ASDC_ACCEPT_TYPE = "application/json";
-
- protected String instanceid;
- protected String userid;
- protected String asdcEndpoint;
- protected String basicAuthCred;
- protected String uri;
-
- public static String PARTIAL_ASDC_URI = "/sdc/v1/catalog/services/";
-
- public AsdcClientHelper(MsoJavaProperties properties) {
- this.properties = properties;
- setAsdcProperties();
-
- };
-
- /**
- * properties should be set during instantiation of this object
- */
- private void setAsdcProperties() {
- String asdcClientAuth = this.properties.getProperty("mso.asdc.client.auth", null);
- String msoKey = this.properties.getProperty("mso.msoKey", null);
- this.basicAuthCred = this.properties.decrypt(asdcClientAuth, msoKey);
- this.asdcEndpoint = this.properties.getProperty("asdc.endpoint", null);
- this.userid = this.properties.getProperty("asdc.activate.userid", null);
- this.instanceid = this.properties.getProperty("asdc.activate.instanceid", null);
-
- }
-
- /**
- * Send POST request to ASDC for operational activation
- * @param uri - /sdc/v1/catalog/services/{serviceUUID}/distribution/{opEnvId}/activate
- * @param jsonPayload - json string value of 'workloadContext'.
- * @return JSONObject
- */
- public JSONObject postActivateOperationalEnvironment(String serviceModelVersionId, String operationalEnvironmentId, String workloadContext) {
-
- try {
-
- String url = this.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId);
- msoLogger.debug(" ASDC url : " + url);
- String jsonPayload = this.buildJsonWorkloadContext(workloadContext);
- msoLogger.debug(" ASDC jsonPayload : " + jsonPayload);
- asdcResponseJsonObj = new JSONObject();
-
- if ( basicAuthCred == null || "".equals(basicAuthCred) ) {
- String errorMessage = " ** ERROR: ASDC credentials 'mso.asdc.client.auth' not setup in properties file!";
- throw new AsdcClientCallFailed(errorMessage);
- }
-
- RESTConfig config = new RESTConfig(url);
- RESTClient client = setRestClient(config);
- client.addAuthorizationHeader(basicAuthCred);
-
- APIResponse apiResponse = setHttpPostResponse(client, jsonPayload);
- int statusCode = apiResponse.getStatusCode();
- msoLogger.debug(" ASDC return code : " + statusCode);
- String responseData = apiResponse.getResponseBodyAsString();
- msoLogger.debug(" ASDC responseData : " + responseData);
- asdcResponseJsonObj = enhanceJsonResponse(new JSONObject(responseData), statusCode);
-
- } catch (Exception ex) {
- msoLogger.debug("calling ASDC Exception message: " + ex.getMessage());
- String errorMessage = " Encountered Error while calling ASDC POST Activate. " + ex.getMessage();
- msoLogger.debug(errorMessage);
- asdcResponseJsonObj.put("statusCode", "500");
- asdcResponseJsonObj.put("messageId", "");
- asdcResponseJsonObj.put("message", errorMessage);
-
- }
- return asdcResponseJsonObj;
-
- }
-
- /**
- * set RESTClient
- * @return RestClient object
- */
- public RESTClient setRestClient(RESTConfig config) throws Exception {
-
- RESTClient client = new RESTClient(config).addHeader("X-ECOMP-InstanceID", instanceid)
- .addHeader("X-ECOMP-RequestID", UUID.randomUUID().toString())
- .addHeader("Content-Type", AsdcClientHelper.ASDC_CONTENT_TYPE)
- .addHeader("Accept", AsdcClientHelper.ASDC_ACCEPT_TYPE)
- .addHeader("USER_ID", userid);
- return client;
-
- }
-
- public APIResponse setHttpPostResponse(RESTClient client, String jsonPayload) throws Exception {
- return client.httpPost(jsonPayload);
-
- }
-
-
- public JSONObject enhanceJsonResponse(JSONObject asdcResponseJsonObj, int statusCode) {
-
- if (statusCode == 202) { // Accepted
- asdcResponseJsonObj.put("statusCode", Integer.toString(statusCode));
- asdcResponseJsonObj.put("messageId", "");
- asdcResponseJsonObj.put("message", "Success");
-
- } else { // error
- String message = "Undefined Error Message!";
- String messageId = "";
- if (asdcResponseJsonObj.has("requestError") ) {
- JSONObject requestErrorObj = asdcResponseJsonObj.getJSONObject("requestError");
- if (asdcResponseJsonObj.getJSONObject("requestError").has("serviceException") ) {
- message = requestErrorObj.getJSONObject("serviceException").getString("text");
- messageId = requestErrorObj.getJSONObject("serviceException").getString("messageId");
- }
- if (asdcResponseJsonObj.getJSONObject("requestError").has("policyException") ) {
- message = requestErrorObj.getJSONObject("policyException").getString("text");
- messageId = requestErrorObj.getJSONObject("policyException").getString("messageId");
- }
-
- }
- asdcResponseJsonObj.put("statusCode", Integer.toString(statusCode));
- asdcResponseJsonObj.put("messageId", messageId);
- asdcResponseJsonObj.put("message", message);
- }
-
- return asdcResponseJsonObj;
-
- }
-
- /**
- * Build Uri
- * @return String uri
- */
- public String buildUriBuilder(String serviceModelVersionId, String operationalEnvironmentId) {
- String path = serviceModelVersionId + "/distribution/" + operationalEnvironmentId +"/activate";
- UriBuilder uriBuilder = UriBuilder.fromPath(asdcEndpoint + AsdcClientHelper.PARTIAL_ASDC_URI)
- .path(path);
- return uriBuilder.build().toString();
- }
-
- /**
- * Build JSON context
- * @return String json
- */
- public String buildJsonWorkloadContext(String workloadContext) {
- return new JSONObject().put("workloadContext", workloadContext).toString();
-
- }
-
- /**
- * get asdc instanceId of this object
- */
- public String getAsdcInstanceId() {
- return this.instanceid;
- }
-
- /**
- * get asdc asdcEndpoint of this object
- */
- public String getAsdcEndpoint() {
- return this.asdcEndpoint;
- }
-
- /**
- * get asdc asdcUserId of this object
- */
- public String getAsdcUserId() {
- return this.userid;
- }
-
-
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
deleted file mode 100644
index 1bfe979f4f..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.json.JSONObject;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.AsdcClientCallFailed;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AsdcClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.ServiceModelList;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatusDb;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatusDb;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
-
-public class ActivateVnfOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "ActivateVnfOperationalEnvironment";
- private AsdcClientHelper asdcClientHelper = null;
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
- private String className = this.getClass().getSimpleName();
- private String methodName = "";
- private String classMethodMessage = "";
- private String errorMessage = "";
-
- private String operationalEnvironmentId = "";
- private int DEFAULT_ACTIVATE_RETRY_COUNT = 3;
- private boolean successIndicator = false;
-
- MsoJavaProperties properties;
- OperationalEnvDistributionStatusDb activateDistributionDb = null;
- OperationalEnvDistributionStatus queryDistributionDbResponse = null;
- OperationalEnvServiceModelStatusDb activateServiceModelDb = null;
- OperationalEnvServiceModelStatus queryServiceModelResponse = null;
-
- /**
- * The class constructor with loadProperties()
- * @param CloudOrchestrationRequest - object
- * @param requestId - string
- */
- public ActivateVnfOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- this.properties = MsoPropertiesUtils.loadMsoProperties();
- asdcClientHelper = new AsdcClientHelper(properties);
- }
-
- @Override
- protected String getServiceName() {
- return ActivateVnfOperationalEnvironment.SERVICE_NAME;
- }
-
- /**
- * The Point-Of-Entry from APIH with VID request to send activate request
- * @return void - nothing
- */
- @Override
- public void execute() {
-
- methodName = "execute() method. ";
- classMethodMessage = className + " " + methodName;
- msoLogger.debug("Begin of " + classMethodMessage);
-
- activateDistributionDb = getOperationalEnvDistributionStatusDb();
- activateServiceModelDb = getOperationalEnvServiceModelStatusDb();
-
- try {
-
- msoLogger.debug("Start of extracting variables from Input.");
- msoLogger.debug(" requestId: " + requestId);
- msoLogger.debug(" cloudOrchestrationRequest: " + request.toString());
- String operationalEnvironmentId = request.getOperationalEnvironmentId();
- this.operationalEnvironmentId = operationalEnvironmentId;
- msoLogger.debug(" operationalEnvironmentId: " + this.operationalEnvironmentId);
- String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext();
- List<ServiceModelList> serviceModelVersionIdList = request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList();
- msoLogger.debug(" serviceModelVersionIdList size(): " + serviceModelVersionIdList.size());
- msoLogger.debug("End of extracting variables from Input.");
-
- msoLogger.debug("Start of getting AAIOperationalEnvironment Object.");
- AAIOperationalEnvironment operationalEnv = getAAIOperationalEnvironment(operationalEnvironmentId);
- String workloadContext = operationalEnv.getWorkloadContext();
- msoLogger.debug(" aai workloadContext: " + workloadContext);
- if (vidWorkloadContext.equals(workloadContext)) {
- msoLogger.debug(" vid workloadContext matched with aai record, continue!");
- } else {
- errorMessage = " The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext;
- msoLogger.debug(errorMessage);
- throw new TenantIsolationException(errorMessage);
- }
- msoLogger.debug("End of getting AAIOperationalEnvironment Object.");
-
- msoLogger.debug("Start of sending activation request to ASDC.");
- processActivateASDCRequest(requestId, operationalEnvironmentId, serviceModelVersionIdList, workloadContext);
- msoLogger.debug("End of sending activation request to ASDC.");
-
- msoLogger.debug("** OVERALL status of flow: Processed ALL " + serviceModelVersionIdList.size() + " activation requests are SUCCESSFUL!");
- successIndicator = true;
- msoLogger.debug("End of " + classMethodMessage);
-
- } catch (Exception ex) {
- errorMessage = "** OVERALL status of flow: " + methodName + ex.getMessage();
- msoLogger.debug(errorMessage);
- getRequestDb().updateInfraFailureCompletion(errorMessage, requestId, operationalEnvironmentId);
-
- }
-
- }
-
-
- /**
- * The Method to send the Activation Requests to ASDC
- * @param requestId - string
- * @param operationalEnvironmentId - string
- * @param List<ServiceModelList> serviceModelVersionIdList - list
- * @param workloadContext - string
- * @return void - nothing
- */
- public void processActivateASDCRequest(String requestId, String operationalEnvironmentId,
- List<ServiceModelList> serviceModelVersionIdList, String workloadContext) throws TenantIsolationException, AsdcClientCallFailed {
-
- int retryCount = 0;
- String retryCountString = properties.getProperty("mso.tenant.isolation.retry.count", null);
- try {
- retryCount = Integer.parseInt(retryCountString);
- msoLogger.debug(" ** Used Properties File retryCount: " + retryCount);
- } catch (NumberFormatException e) {
- retryCount = DEFAULT_ACTIVATE_RETRY_COUNT;
- msoLogger.debug(" ** Used Default retryCount: " + retryCount + " Exception: " + e.getMessage());
- }
-
- msoLogger.debug(" ** serviceModelVersionIdList: " + serviceModelVersionIdList.size());
-
- // loop through the serviceModelVersionId, and send request ASDC
- for(ServiceModelList serviceModelList : serviceModelVersionIdList){
- String serviceModelVersionId = serviceModelList.getServiceModelVersionId();
- String recoveryAction = serviceModelList.getRecoveryAction().toString().toUpperCase();
- msoLogger.debug(" ** serviceModelVersionId: " + serviceModelVersionId + "; recoveryAction: " + recoveryAction);
- // should insert 1 row
- activateServiceModelDb.insertOperationalEnvServiceModelStatus(requestId, operationalEnvironmentId, serviceModelVersionId, "SENT", recoveryAction, retryCount, workloadContext);
-
- JSONObject jsonResponse = null;
- String distributionId = "";
- try {
- jsonResponse = asdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
- msoLogger.debug(" JSONObject jsonResponse:" + jsonResponse.toString());
- String statusCode = jsonResponse.get("statusCode").toString();
- if (statusCode.equals("202")) {
- distributionId = jsonResponse.get("distributionId").toString();
-
- // should insert 1 row
- activateDistributionDb.insertOperationalEnvDistributionStatus(distributionId, operationalEnvironmentId, serviceModelVersionId, "SENT", requestId);
-
- } else {
- errorMessage = " Failure calling ASDC: statusCode: " + statusCode +
- "; messageId: " + jsonResponse.get("messageId") +
- "; message: " + jsonResponse.get("message");
- msoLogger.debug(errorMessage);
- throw new AsdcClientCallFailed(errorMessage);
-
- }
-
- } catch (Exception ex) {
- errorMessage = " Encountered Exception in " + methodName + " Exception: " + ex.getMessage();
- msoLogger.debug(errorMessage);
- throw new TenantIsolationException(errorMessage);
- }
-
- }
-
- }
-
- /**
- * Get AAIOperationalEnvironment object
- * @param String operationalEnvironmentId
- * @return object AAIOperationalEnvironment
- */
- public AAIOperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) {
-
- AAIOperationalEnvironment operationalEnv = null;
- getAaiHelper();
-
- try {
- AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId);
- operationalEnv = aaiResult.asBean(AAIOperationalEnvironment.class).get();
- } catch (JsonParseException e) {
- msoLogger.error(" **** JsonParseException: ", e);
- } catch (JsonMappingException e) {
- msoLogger.error(" **** JsonMappingException: ", e);
- } catch (IOException e) {
- msoLogger.error(" **** IOException: ", e);
- } catch (Exception e) {
- msoLogger.error(" **** Exception: ", e);
- }
-
- return operationalEnv;
-
- }
-
-
- /**
- * Overall Success indicator
- * @return true or false
- */
- public boolean isSuccess() {
- return successIndicator;
- }
-
- /**
- * Set to new OperationalEnvDistributionStatusDb
- * @return void
- */
- public void setOperationalEnvDistributionStatusDb (OperationalEnvDistributionStatusDb activateDistributionDb) {
- this.activateDistributionDb = activateDistributionDb;
- }
-
- /**
- * Set to new OperationalEnvServiceModelStatusDb
- * @return void
- */
- public void setOperationalEnvServiceModelStatusDb (OperationalEnvServiceModelStatusDb activateServiceModelDb) {
- this.activateServiceModelDb = activateServiceModelDb;
- }
-
- /**
- * Set to new AsdcClientHelper
- * @return void
- */
- public void setAsdcClientHelper (AsdcClientHelper asdcClientHelper) {
- this.asdcClientHelper = asdcClientHelper;
- }
-
- /**
- * get OperationalEnvDistributionStatusDb instance
- */
- public OperationalEnvDistributionStatusDb getOperationalEnvDistributionStatusDb() {
- if(this.activateDistributionDb == null) {
- this.activateDistributionDb = OperationalEnvDistributionStatusDb.getInstance();
- }
- return this.activateDistributionDb;
- }
-
- /**
- * get OperationalEnvServiceModelStatusDb instance
- */
- public OperationalEnvServiceModelStatusDb getOperationalEnvServiceModelStatusDb() {
- if(this.activateServiceModelDb == null) {
- this.activateServiceModelDb = OperationalEnvServiceModelStatusDb.getInstance();
- }
- return this.activateServiceModelDb;
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
deleted file mode 100644
index 7ef0da61f5..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.json.JSONObject;
-import org.openecomp.mso.apihandlerinfra.MsoPropertiesUtils;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.AsdcClientCallFailed;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AsdcClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.Distribution;
-import org.openecomp.mso.apihandlerinfra.tenantisolationbeans.DistributionStatus;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvDistributionStatusDb;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatus;
-import org.openecomp.mso.requestsdb.OperationalEnvServiceModelStatusDb;
-
-
-public class ActivateVnfStatusOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "ActivateVnfStatusOperationalEnvironment";
- private AsdcClientHelper asdcClientHelper = null;
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
- private String className = this.getClass().getSimpleName();
- private String methodName = "";
- private String classMethodMessage = "";
- private String errorMessage = "";
-
- private String operationalEnvironmentId = "";
- private boolean successIndicator = false;
-
- MsoJavaProperties properties;
- OperationalEnvDistributionStatusDb activateDistributionDb = null;
- OperationalEnvDistributionStatus queryDistributionDbResponse = null;
- OperationalEnvServiceModelStatusDb activateServiceModelDb = null;
- OperationalEnvServiceModelStatus queryServiceModelResponse = null;
-
- /**
- * The class constructor with loadProperties()
- * @param CloudOrchestrationRequest - object
- * @param requestId - string
- */
- public ActivateVnfStatusOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- this.properties = MsoPropertiesUtils.loadMsoProperties();
- asdcClientHelper = new AsdcClientHelper(properties);
- }
-
- @Override
- protected String getServiceName() {
- return ActivateVnfStatusOperationalEnvironment.SERVICE_NAME;
- }
-
-
- /**
- * The Point-Of-Entry from APIH with activate status from ASDC
- * @return void - nothing
- */
- @Override
- public void execute() {
-
- methodName = "execute() method. ";
- classMethodMessage = className + " " + methodName;
- msoLogger.debug("Begin of " + classMethodMessage);
-
- activateDistributionDb = getOperationalEnvDistributionStatusDb();
- activateServiceModelDb = getOperationalEnvServiceModelStatusDb();
-
- try {
-
- String asdcDistributionId = request.getDistributionId();
- Distribution distributionObject = request.getDistribution();
- msoLogger.debug(" ** asdcDistributionId: " + asdcDistributionId + ";" + " status: " + request.getDistribution().getStatus());
-
- // Distribution, Query for operationalEnvironmentId, serviceModelVersionId
- queryDistributionDbResponse = activateDistributionDb.getOperationalEnvDistributionStatus(asdcDistributionId);
-
- if(queryDistributionDbResponse == null) {
- throw new TenantIsolationException("DistributionId doesn't exist in the DB: " + asdcDistributionId);
- }
-
- String operationalEnvironmentId = queryDistributionDbResponse.getOperationalEnvId();
- this.operationalEnvironmentId = operationalEnvironmentId;
- String serviceModelVersionId = queryDistributionDbResponse.getServiceModelVersionId();
-
- // ServiceModel, Query for dbRequestId, recoveryAction, retryCountString
- queryServiceModelResponse = activateServiceModelDb.getOperationalEnvServiceModelStatus(operationalEnvironmentId, serviceModelVersionId);
- String origRequestId = queryServiceModelResponse.getRequestId();
- this.requestId = origRequestId;
-
- msoLogger.debug("Start of processing activation status.");
- processActivateASDCStatus(asdcDistributionId, distributionObject);
- msoLogger.debug("End of processing activation status.");
-
- // After EVERY status processed, need to query the status of all service modelId
- // to determine the OVERALL status if "COMPLETE" or "FAILURE":
- checkOrUpdateOverallStatus(origRequestId, operationalEnvironmentId);
-
- msoLogger.debug("End of " + classMethodMessage);
-
- } catch (Exception ex) {
- errorMessage = "** OVERALL status of flow: " + methodName + ex.getMessage();
- msoLogger.debug(errorMessage);
- getRequestDb().updateInfraFailureCompletion(errorMessage, requestId, operationalEnvironmentId);
-
- }
-
- }
-
- /**
- * The Method to process the Activation Status from ASDC
- * @param asdcDistributionId - string
- * @param Distribution - object
- * @return void - nothing
- */
- public void processActivateASDCStatus(String asdcDistributionId, Distribution asdcStatus) throws TenantIsolationException {
-
- String operationalEnvironmentId = queryDistributionDbResponse.getOperationalEnvId();
- String serviceModelVersionId = queryDistributionDbResponse.getServiceModelVersionId();
-
- String origRequestId = queryServiceModelResponse.getRequestId();
- String recoveryAction = queryServiceModelResponse.getRecoveryAction();
- int retryCount = queryServiceModelResponse.getRetryCount();
- String workloadContext = queryServiceModelResponse.getWorkloadContext();
-
- // Validate/process status
- if (asdcStatus.getStatus().toString().equals(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString())) {
- // should update 1 row, update status to "DISTRIBUTION_COMPLETE_OK"
- activateDistributionDb.updateOperationalEnvDistributionStatus(asdcStatus.getStatus().toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId);
- // should update 1 row, update status and retryCount = 0 (ie, serviceModelVersionId is DONE!)
- activateServiceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, asdcStatus.getStatus().toString(), 0);
-
- } else {
-
- // "DISTRIBUTION_COMPLETE_ERROR", Check if recoveryAction is "RETRY"
- if (recoveryAction.equals("RETRY") & retryCount > 0) {
- // RESEND / RETRY serviceModelVersionId to ASDC
- JSONObject jsonResponse = null;
- String newDistributionId = "";
- try {
- jsonResponse = asdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext);
- String statusCode = jsonResponse.get("statusCode").toString();
- if (statusCode.equals("202")) {
- newDistributionId = jsonResponse.get("distributionId").toString();
-
- // should insert 1 row, NEW distributionId for old serviceModelServiceId
- activateDistributionDb.insertOperationalEnvDistributionStatus(newDistributionId, operationalEnvironmentId, serviceModelVersionId, "SENT", origRequestId);
-
- // update retryCount (less 1) for the serviceModelServiceId
- retryCount = retryCount - 1;
- // should update 1 row, original insert
- activateServiceModelDb.updateOperationalEnvRetryCountStatusPerReqId(operationalEnvironmentId, serviceModelVersionId, asdcStatus.getStatus().toString(), retryCount, origRequestId);
-
- // should update 1 row, OLD distributionId set to status error (ie, old distributionId is DONE!).
- activateDistributionDb.updateOperationalEnvDistributionStatus(DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString(), asdcDistributionId, operationalEnvironmentId, serviceModelVersionId);
-
- } else {
- errorMessage = " Failure calling ASDC: statusCode: " + statusCode +
- "; messageId: " + jsonResponse.get("messageId") +
- "; message: " + jsonResponse.get("message");
- msoLogger.debug(errorMessage);
- throw new AsdcClientCallFailed(errorMessage);
-
- }
-
- } catch (Exception ex) {
- errorMessage = " Encountered Exception in " + methodName + " Exception: " + ex.getMessage();
- msoLogger.debug(errorMessage);
- throw new TenantIsolationException(errorMessage);
- }
-
-
- } else { // either RETRY & Count = 0, or 'ABORT', or 'SKIP'
-
- if (recoveryAction.equals("SKIP") || recoveryAction.equals("ABORT")) {
- String modifiedStatus = "";
- if (recoveryAction.equals("SKIP")) { // considered SUCCESS
- modifiedStatus = DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString();
- } else {
- if (recoveryAction.equals("ABORT")) {
- modifiedStatus = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString(); // ABORT, error
- }
- }
- // should update 1 row, modified status & retryCount set 0
- activateServiceModelDb.updateOperationalEnvRetryCountStatus(operationalEnvironmentId, serviceModelVersionId, modifiedStatus, 0);
- // should update 1 row, modified status
- activateDistributionDb.updateOperationalEnvDistributionStatus(modifiedStatus, asdcDistributionId, operationalEnvironmentId, serviceModelVersionId);
-
- } else {
- // RETRY & Count = 0 (do nothing!)
- }
- }
-
- }
-
- }
-
- /**
- * The Method to check the overall status of the Activation for an operationalEnvironmentId
- * @param origRequestId - string
- * @param operationalEnvironmentId - string
- * @return void - nothing
- * @throws Exception
- */
- public void checkOrUpdateOverallStatus(String origRequestId, String operationalEnvironmentId) throws Exception {
-
- List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = activateServiceModelDb.getOperationalEnvIdStatus(operationalEnvironmentId, origRequestId);
- msoLogger.debug(" **** queryServiceModelResponseList.size(): " + queryServiceModelResponseList.size());
-
- String status = "Waiting";
- int count = 0;
- // loop through the statuses of the service model
- for (OperationalEnvServiceModelStatus queryServiceModelResponse : queryServiceModelResponseList) {
- status = queryServiceModelResponse.getServiceModelVersionDistrStatus();
- // all should be OK to be completed.
- if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString()) &&
- (queryServiceModelResponse.getRetryCount() == 0))) {
- status = "Completed";
- count ++;
- }
- // one error with zero retry, means all are failures.
- if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString()) &&
- (queryServiceModelResponse.getRetryCount() == 0))) {
- status = "Failure";
- count = queryServiceModelResponseList.size();
- break;
- }
-
- }
-
- // "DISTRIBUTION_COMPLETE_OK" : Completed / Successful
- if (status == "Completed" && queryServiceModelResponseList.size() == count) {
- executeAAIPatch(operationalEnvironmentId);
- String messageStatus = "Overall Activation process is complete. " + status;
- successIndicator = true;
- msoLogger.debug(messageStatus);
- // Update DB to COMPLETION
- getRequestDb().updateInfraSuccessCompletion(messageStatus, origRequestId, operationalEnvironmentId);
- } else {
- // "DISTRIBUTION_COMPLETE_ERROR" : Failure
- if (status == "Failure" && queryServiceModelResponseList.size() == count) {
- errorMessage = "Overall Activation process is a Failure. " + status;
- msoLogger.debug(errorMessage);
- getRequestDb().updateInfraFailureCompletion(errorMessage, requestId, operationalEnvironmentId);
- } else {
- msoLogger.debug(" **** Still waiting for more distribution status!"); // 1+ rows
- }
- }
-
- }
-
- private void executeAAIPatch(String operationalEnvironmentId) throws Exception {
- msoLogger.debug("Start of AA&I UPDATE client call in ActivateVnfStatusOperationalEnvironment");
-
- Map<String, String> payload = new HashMap<>();
- payload.put("operational-environment-status", "ACTIVE");
- getAaiHelper().updateAaiOperationalEnvironment(operationalEnvironmentId, payload);
-
- msoLogger.debug("End of AA&I UPDATE client call in ActivateVnfStatusOperationalEnvironment");
- }
-
- /**
- * Overall Success indicator
- * @return true or false
- */
- public boolean isSuccess() {
- return successIndicator;
- }
-
- /**
- * Set to new OperationalEnvDistributionStatusDb
- * @return void
- */
- public void setOperationalEnvDistributionStatusDb (OperationalEnvDistributionStatusDb activateDistributionDb) {
- this.activateDistributionDb = activateDistributionDb;
- }
-
- /**
- * Set to new OperationalEnvServiceModelStatusDb
- * @return void
- */
- public void setOperationalEnvServiceModelStatusDb (OperationalEnvServiceModelStatusDb activateServiceModelDb) {
- this.activateServiceModelDb = activateServiceModelDb;
- }
-
-
- /**
- * Set to new AsdcClientHelper
- * @return void
- */
- public void setAsdcClientHelper (AsdcClientHelper asdcClientHelper) {
- this.asdcClientHelper = asdcClientHelper;
- }
-
- /**
- * get OperationalEnvDistributionStatusDb instance
- */
- public OperationalEnvDistributionStatusDb getOperationalEnvDistributionStatusDb() {
- if(this.activateDistributionDb == null) {
- this.activateDistributionDb = OperationalEnvDistributionStatusDb.getInstance();
- }
- return this.activateDistributionDb;
- }
-
- /**
- * get OperationalEnvServiceModelStatusDb instance
- */
- public OperationalEnvServiceModelStatusDb getOperationalEnvServiceModelStatusDb() {
- if(this.activateServiceModelDb == null) {
- this.activateServiceModelDb = OperationalEnvServiceModelStatusDb.getInstance();
- }
- return this.activateServiceModelDb;
- }
-
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java
deleted file mode 100644
index 3dd1b72ca6..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.DmaapOperationalEnvClient;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-
-public class CreateEcompOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "CreateEcompOperationalEnvironment";
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
-
-
- public CreateEcompOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- }
-
-
- protected DmaapOperationalEnvClient getDmaapClient() {
- return new DmaapOperationalEnvClient();
- }
-
-
- @Override
- public void execute() {
- try {
- msoLogger.debug("Begin of execute method in " + SERVICE_NAME);
- msoLogger.debug("CloudOrchestrationRequest: " + request.toString());
-
- //Create ECOMP Managing Environment object in A&AI
- getAaiHelper().createOperationalEnvironment(getAaiClientObjectBuilder().buildAAIOperationalEnvironment("ACTIVE"));
- msoLogger.debug("ECOMP operational environment created in A&AI.");
-
- // Call client to publish to DMaap
- getDmaapClient().dmaapPublishOperationalEnvRequest(getRequest().getOperationalEnvironmentId(),
- getRequest().getRequestDetails().getRequestInfo().getInstanceName(),
- getRequest().getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString(),
- getRequest().getRequestDetails().getRequestParameters().getTenantContext(),
- getRequest().getRequestDetails().getRequestParameters().getWorkloadContext(),
- "Create");
- msoLogger.debug("ECOMP operational environment published in Dmaap/ASDC.");
-
- //Update request database
- getRequestDb().updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", getRequestId(), getRequest().getOperationalEnvironmentId());
- }
- catch (Exception e) {
- msoLogger.error("exception while publishing operational environment", e);
- msoLogger.error(MessageEnum.APIH_GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.UnknownError, e.getMessage());
- getRequestDb().updateInfraFailureCompletion(e.getMessage(), getRequestId(), getRequest().getOperationalEnvironmentId());
- }
- }
-
-
- @Override
- protected String getServiceName() {
- return CreateEcompOperationalEnvironment.SERVICE_NAME;
- }
-
-} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
deleted file mode 100644
index b419a0ccd0..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.exceptions.TenantIsolationException;
-import org.openecomp.mso.client.aai.entities.AAIResultWrapper;
-import org.openecomp.mso.client.aai.objects.AAIOperationalEnvironment;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class DeactivateVnfOperationalEnvironment extends OperationalEnvironmentProcess {
-
- private static final String SERVICE_NAME = "DeactivateVnfOperationalEnvironment";
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
- private String className = this.getClass().getName();
-
- public DeactivateVnfOperationalEnvironment(CloudOrchestrationRequest request, String requestId) {
- super(request, requestId);
- MsoLogger.setServiceName (getRequestId());
- MsoLogger.setLogContext(getRequestId(), getRequest().getOperationalEnvironmentId());
- }
-
- @Override
- public void execute() {
- String methodName = "deactivateOperationalEnvironment() method.";
- String classMethodMessage = className + " " + methodName;
-
- msoLogger.debug("Begin of execute method in " + SERVICE_NAME);
-
- String operationalEnvironmentId = getRequest().getOperationalEnvironmentId();
- msoLogger.debug("Deactivate OperationalEnvironment on " + operationalEnvironmentId);
- try {
- msoLogger.debug("Start of AA&I Get client call in " + classMethodMessage);
-
- AAIResultWrapper aaiResult = getAaiHelper().getAaiOperationalEnvironment(operationalEnvironmentId);
- AAIOperationalEnvironment aaiOpEnv = aaiResult.asBean(AAIOperationalEnvironment.class).get();
- String operationalEnvironmentStatus = aaiOpEnv.getOperationalEnvironmentStatus();
-
- msoLogger.debug("OperationalEnvironmentStatus is :" + operationalEnvironmentStatus);
- msoLogger.debug(" End of AA&I Get client call in " + classMethodMessage);
-
- if(operationalEnvironmentStatus == null) {
- String error = "OperationalEnvironmentStatus is null on OperationalEnvironmentId: " + operationalEnvironmentId;
- throw new TenantIsolationException(error);
- }
-
- if(operationalEnvironmentStatus.equalsIgnoreCase("ACTIVE")) {
- msoLogger.debug("Start of AA&I UPDATE client call in " + classMethodMessage);
-
- aaiOpEnv.setOperationalEnvironmentStatus("INACTIVE");
- getAaiHelper().updateAaiOperationalEnvironment(operationalEnvironmentId, aaiOpEnv);
-
- msoLogger.debug(" End of AA&I UPDATE client call in " + classMethodMessage);
- } else if(!operationalEnvironmentStatus.equalsIgnoreCase("INACTIVE")) {
- String error = "Invalid OperationalEnvironmentStatus on OperationalEnvironmentId: " + operationalEnvironmentId;
- throw new TenantIsolationException(error);
- }
-
- getRequestDb().updateInfraSuccessCompletion("SUCCESSFULLY Deactivated OperationalEnvironment", requestId, operationalEnvironmentId);
-
- } catch(Exception e) {
- msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.DataError, e.getMessage());
- getRequestDb().updateInfraFailureCompletion(e.getMessage(), requestId, operationalEnvironmentId);
- }
-
- msoLogger.debug("End of " + classMethodMessage);
- }
-
- @Override
- protected String getServiceName() {
- return DeactivateVnfOperationalEnvironment.SERVICE_NAME;
- }
-} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/OperationalEnvironmentProcess.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/OperationalEnvironmentProcess.java
deleted file mode 100644
index 9c2d443215..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tenantisolation/process/OperationalEnvironmentProcess.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.apihandlerinfra.tenantisolation.process;
-
-import org.openecomp.mso.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
-import org.openecomp.mso.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder;
-import org.openecomp.mso.requestsdb.RequestsDBHelper;
-
-public abstract class OperationalEnvironmentProcess {
-
- protected String requestId;
- protected CloudOrchestrationRequest request;
- protected AAIClientObjectBuilder aaiClientObjectBuilder;
- protected AAIClientHelper aaiHelper;
- protected RequestsDBHelper requestDb;
-
- public OperationalEnvironmentProcess(CloudOrchestrationRequest request, String requestId) {
- this.requestId = requestId;
- this.request = request;
- this.aaiClientObjectBuilder = new AAIClientObjectBuilder(getRequest());
- }
-
- protected String getRequestId() {
- return this.requestId;
- }
-
- protected CloudOrchestrationRequest getRequest() {
- return this.request;
- }
-
- protected AAIClientHelper getAaiHelper() {
- if(this.aaiHelper == null) {
- this.aaiHelper = new AAIClientHelper(getServiceName(), getRequestId());
- }
- return this.aaiHelper;
- }
-
- protected void setAaiHelper(AAIClientHelper helper) {
- this.aaiHelper = helper;
- }
-
- protected AAIClientObjectBuilder getAaiClientObjectBuilder() {
- return this.aaiClientObjectBuilder;
- }
-
- protected RequestsDBHelper getRequestDb() {
- if(requestDb == null) {
- requestDb = new RequestsDBHelper();
- }
- return requestDb;
- }
-
- protected void setRequestsDBHelper(RequestsDBHelper helper) {
- this.requestDb = helper;
- }
-
- protected abstract String getServiceName();
- public abstract void execute();
-}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/resources/ManualTasks.xsd b/mso-api-handlers/mso-api-handler-infra/src/main/java/resources/ManualTasks.xsd
deleted file mode 100644
index e8c67dddd7..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/resources/ManualTasks.xsd
+++ /dev/null
@@ -1,48 +0,0 @@
-<xs:schema targetNamespace="org.openecomp.mso/humantasks" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="org.openecomp.mso/humantasks">
- <xs:element name="taskList">
- <xs:complexType>
- <xs:sequence>
- <xs:element type="xs:string" name="taskId"/>
- <xs:element type="xs:string" name="type"/>
- <xs:element type="xs:string" name="nfRole"/>
- <xs:element type="xs:string" name="subscriptionServiceType"/>
- <xs:element type="xs:string" name="originalRequestId"/>
- <xs:element type="xs:string" name="originalRequestorId"/>
- <xs:element type="xs:string" name="errorSource"/>
- <xs:element type="xs:string" name="errorCode"/>
- <xs:element type="xs:string" name="errorMessage"/>
- <xs:element type="xs:string" name="buildingBlockName"/>
- <xs:element type="xs:string" name="buildingBlockStep"/>
- <xs:element name="validResponses">
- <xs:complexType>
- <xs:sequence>
- <xs:element minOccurs="0" maxOccurs="unbounded" name="action" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="requestDetails">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="requestInfo">
- <xs:complexType>
- <xs:sequence>
- <xs:element type="xs:string" name="source"/>
- <xs:element type="xs:string" name="responseValue"/>
- <xs:element type="xs:string" name="requestorId"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name ="taskRequestReference">
- <xs:complexType>
- <xs:sequence>
- <xs:element type="xs:string" name="taskId"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-</xs:schema> \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/resources/application.properties b/mso-api-handlers/mso-api-handler-infra/src/main/java/resources/application.properties
deleted file mode 100644
index 96c9e6fa18..0000000000
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/resources/application.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ECOMP MSO
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. 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.
-# ============LICENSE_END=========================================================
-###
-
-# -- welcome --
-welcomeTitle=JSF Blank Application
-
-welcomeHeading=Welcome!
-
-welcomeMessage=This is a JSF blank application. \
- You can find the application.properties file with this message in the src/resources folder.