From 38f720752af4d4aad8c4e467a288d9048659f688 Mon Sep 17 00:00:00 2001 From: Rob Daugherty Date: Wed, 14 Mar 2018 02:07:32 -0400 Subject: AT&T 1712 and 1802 release code This is code from AT&T's 1712 and 1802 releases. Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04 Issue-ID: SO-425 Signed-off-by: Rob Daugherty --- .../mso/bpmn/common/scripts/AaiUtil.groovy | 78 +-- .../scripts/AbstractServiceTaskProcessor.groovy | 44 +- .../common/scripts/AllottedResourceUtils.groovy | 20 +- .../mso/bpmn/common/scripts/AppCClient.groovy | 135 +++++ .../mso/bpmn/common/scripts/CatalogDbUtils.groovy | 264 +++++---- .../bpmn/common/scripts/CompleteMsoProcess.groovy | 622 +++++++++---------- .../common/scripts/ConfirmVolumeGroupName.groovy | 18 +- .../common/scripts/ConfirmVolumeGroupTenant.groovy | 8 +- .../bpmn/common/scripts/CreateAAIVfModule.groovy | 26 +- .../scripts/CreateAAIVfModuleVolumeGroup.groovy | 14 +- .../bpmn/common/scripts/CustomE2EGetService.groovy | 10 +- .../bpmn/common/scripts/CustomE2EPutService.groovy | 6 +- .../bpmn/common/scripts/DecomposeService.groovy | 27 +- .../bpmn/common/scripts/DeleteAAIVfModule.groovy | 24 +- .../mso/bpmn/common/scripts/ExceptionUtil.groovy | 34 +- .../mso/bpmn/common/scripts/FalloutHandler.groovy | 18 +- .../common/scripts/GenerateVfModuleName.groovy | 8 +- .../common/scripts/GenericDeleteService.groovy | 9 +- .../bpmn/common/scripts/GenericDeleteVnf.groovy | 8 +- .../bpmn/common/scripts/GenericGetService.groovy | 11 +- .../mso/bpmn/common/scripts/GenericGetVnf.groovy | 8 +- .../scripts/GenericNotificationService.groovy | 4 +- .../bpmn/common/scripts/GenericPutService.groovy | 18 +- .../mso/bpmn/common/scripts/GenericPutVnf.groovy | 6 +- .../mso/bpmn/common/scripts/Homing.groovy | 39 +- .../mso/bpmn/common/scripts/ManualHandling.groovy | 100 +++- .../mso/bpmn/common/scripts/NetworkUtils.groovy | 79 ++- .../common/scripts/PrepareUpdateAAIVfModule.groovy | 18 +- .../mso/bpmn/common/scripts/RainyDayHandler.groovy | 85 ++- .../common/scripts/ReceiveWorkflowMessage.groovy | 18 +- .../mso/bpmn/common/scripts/SDNCAdapter.groovy | 20 +- .../bpmn/common/scripts/SDNCAdapterRestV1.groovy | 14 +- .../bpmn/common/scripts/SDNCAdapterRestV2.groovy | 254 ++++++++ .../bpmn/common/scripts/SDNCAdapterUtils.groovy | 123 ++-- .../mso/bpmn/common/scripts/SNIROUtils.groovy | 98 ++- .../common/scripts/ServiceTaskProcessor.groovy | 5 +- .../common/scripts/TrinityExceptionUtil.groovy | 12 +- .../bpmn/common/scripts/UpdateAAIGenericVnf.groovy | 14 +- .../bpmn/common/scripts/UpdateAAIVfModule.groovy | 14 +- .../mso/bpmn/common/scripts/VfModuleBase.groovy | 572 ++++++++++-------- .../bpmn/common/scripts/VnfAdapterRestV1.groovy | 20 +- .../mso/bpmn/common/scripts/VnfAdapterUtils.groovy | 4 +- .../mso/bpmn/appc/payload/PayloadClient.java | 109 ++++ .../appc/payload/beans/ConfigModifyAction.java | 59 ++ .../beans/ConfigurationParametersConfigModify.java | 58 ++ .../beans/ConfigurationParametersHealthCheck.java | 45 ++ .../beans/ConfigurationParametersQuiesce.java | 59 ++ .../ConfigurationParametersResumeTraffic.java | 45 ++ .../beans/ConfigurationParametersUpgrade.java | 71 +++ .../bpmn/appc/payload/beans/HealthCheckAction.java | 59 ++ .../appc/payload/beans/QuiesceTrafficAction.java | 46 ++ .../beans/RequestParametersConfigModify.java | 46 ++ .../beans/RequestParametersHealthCheck.java | 47 ++ .../appc/payload/beans/ResumeTrafficAction.java | 45 ++ .../bpmn/appc/payload/beans/SnapshotAction.java | 59 ++ .../bpmn/appc/payload/beans/StartStopAction.java | 45 ++ .../mso/bpmn/appc/payload/beans/UpgradeAction.java | 45 ++ .../workflow/service/AbstractCallbackService.java | 58 +- .../service/WorkflowAsyncCommonResource.java | 33 ++ .../workflow/service/WorkflowAsyncResource.java | 1 - .../mso/client/PreconditionFailedException.java | 35 -- .../mso/client/ResponseExceptionMapper.java | 98 --- .../mso/client/ResponseExceptionMapperImpl.java | 39 -- .../org/openecomp/mso/client/RestProperties.java | 30 - .../openecomp/mso/client/RestPropertiesLoader.java | 55 -- .../aai/AAIClientResponseExceptionMapper.java | 91 --- .../client/aai/AAICommonObjectMapperProvider.java | 49 -- .../client/aai/AAIQueryObjectMapperProvider.java | 47 -- .../aai/AAIResourcesObjectMapperProvider.java | 38 -- .../openecomp/mso/client/aai/AAIRestClient.java | 40 -- .../mso/client/aai/AAIRestClientImpl.java | 179 ------ .../org/openecomp/mso/client/aai/AAIUpdator.java | 31 - .../openecomp/mso/client/aai/AAIUpdatorImpl.java | 49 -- .../org/openecomp/mso/client/aai/AAIValidator.java | 32 - .../openecomp/mso/client/aai/AAIValidatorImpl.java | 71 --- .../mso/client/aai/entities/AAIEntity.java | 25 - .../mso/client/aai/entities/AAIError.java | 46 -- .../mso/client/aai/entities/CustomQuery.java | 68 --- .../mso/client/aai/entities/RequestError.java | 46 -- .../openecomp/mso/client/aai/entities/Results.java | 53 -- .../mso/client/aai/entities/ServiceException.java | 73 --- .../adapter/network/NetworkAdapterClient.java | 45 ++ .../adapter/network/NetworkAdapterClientImpl.java | 97 +++ .../network/NetworkAdapterRestProperties.java | 56 ++ .../adapter/requests/db/MsoRequestsDbAdapter.java | 35 ++ .../requests/db/MsoRequestsDbAdapterClient.java | 300 ++++++++++ .../db/entities/MsoRequestsDbException.java | 62 ++ .../db/entities/MsoRequestsDbExceptionBean.java | 48 ++ .../requests/db/entities/RequestStatusType.java | 69 +++ .../requests/db/entities/ResponseStatus.java | 33 ++ .../adapter/requests/db/entities/Status.java | 40 ++ .../requests/db/entities/UpdateInfraRequest.java | 138 +++++ .../mso/client/adapter/vnf/AdapterRestClient.java | 89 +++ .../client/adapter/vnf/AdapterRestProperties.java | 29 + .../mso/client/adapter/vnf/VnfAdapterClient.java | 48 ++ .../client/adapter/vnf/VnfAdapterClientImpl.java | 106 ++++ .../adapter/vnf/VnfAdapterRestProperties.java | 56 ++ .../client/appc/ApplicationControllerAction.java | 178 ++++++ .../client/appc/ApplicationControllerCallback.java | 5 +- .../client/appc/ApplicationControllerClient.java | 133 ++--- .../appc/ApplicationControllerOrchestrator.java | 50 ++ ...ApplicationControllerOrchestratorException.java | 36 ++ .../client/appc/ApplicationControllerSupport.java | 101 ++-- .../org/openecomp/mso/client/dmaap/Consumer.java | 26 - .../client/dmaap/DefaultDmaapPropertiesImpl.java | 38 -- .../openecomp/mso/client/dmaap/DmaapClient.java | 68 --- .../openecomp/mso/client/dmaap/DmaapConsumer.java | 131 ---- .../mso/client/dmaap/DmaapProperties.java | 32 - .../mso/client/dmaap/DmaapPropertiesLoader.java | 48 -- .../openecomp/mso/client/dmaap/DmaapPublisher.java | 51 -- .../org/openecomp/mso/client/dmaap/Publisher.java | 26 - .../dmaap/exceptions/DMaaPConsumerFailure.java | 34 -- .../exceptions/ExceededMaximumPollingTime.java | 34 -- .../mso/client/dmaap/rest/DMaaPRestClient.java | 57 -- .../mso/client/dmaap/rest/PropertiesBean.java | 131 ---- .../mso/client/dmaap/rest/RestConsumer.java | 60 -- .../mso/client/dmaap/rest/RestPublisher.java | 56 -- .../dmaaproperties/DefaultDmaapPropertiesImpl.java | 39 ++ .../mso/client/exceptions/SDNOException.java | 39 -- .../mso/client/orchestration/AAIOrchestrator.java | 114 ++++ .../mso/client/orchestration/SDNCOrchestrator.java | 61 ++ .../client/policy/CommonObjectMapperProvider.java | 51 -- .../mso/client/policy/DecisionAttributes.java | 93 --- .../openecomp/mso/client/policy/LoggingFilter.java | 138 ----- .../mso/client/policy/PolicyDecision.java | 57 -- .../mso/client/policy/PolicyDecisionRequest.java | 57 -- .../mso/client/policy/PolicyRestClient.java | 66 --- .../mso/client/policy/PolicyRestProperties.java | 64 -- .../openecomp/mso/client/policy/RestClient.java | 220 ------- .../client/policy/entities/PolicyServiceType.java | 48 -- .../client/restproperties/AAIPropertiesImpl.java | 55 ++ .../restproperties/PolicyRestPropertiesImpl.java | 64 ++ .../mso/client/sdnc/beans/SDNCRequest.java | 95 +++ .../mso/client/sdnc/beans/SDNCSvcAction.java | 46 ++ .../mso/client/sdnc/beans/SDNCSvcOperation.java | 43 ++ .../mso/client/sdnc/mapper/SDNCRequestMapper.java | 46 ++ .../ServiceTopologyOperationRequestMapper.java | 98 +++ .../mso/client/sdnc/sync/CallbackHeader.java | 154 +++++ .../openecomp/mso/client/sdnc/sync/Constants.java | 48 ++ .../mso/client/sdnc/sync/ObjectFactory.java | 77 +++ .../mso/client/sdnc/sync/RequestHeader.java | 219 +++++++ .../mso/client/sdnc/sync/RequestTunables.java | 222 +++++++ .../sdnc/sync/SDNCAdapterCallbackRequest.java | 136 +++++ .../mso/client/sdnc/sync/SDNCAdapterPortType.java | 57 ++ .../client/sdnc/sync/SDNCAdapterPortTypeImpl.java | 108 ++++ .../mso/client/sdnc/sync/SDNCAdapterRequest.java | 128 ++++ .../mso/client/sdnc/sync/SDNCAdapterResponse.java | 53 ++ .../sdnc/sync/SDNCCallbackAdapterPortType.java | 45 ++ .../sdnc/sync/SDNCCallbackAdapterService.java | 126 ++++ .../mso/client/sdnc/sync/SDNCRequestIdUtil.java | 39 ++ .../mso/client/sdnc/sync/SDNCResponse.java | 73 +++ .../mso/client/sdnc/sync/SDNCSyncRpcClient.java | 317 ++++++++++ .../org/openecomp/mso/client/sdnc/sync/Utils.java | 195 ++++++ .../openecomp/mso/client/sdno/SDNOValidator.java | 37 -- .../mso/client/sdno/SDNOValidatorImpl.java | 54 -- .../org/openecomp/mso/client/sdno/beans/Body.java | 77 --- .../org/openecomp/mso/client/sdno/beans/Input.java | 79 --- .../client/sdno/beans/RequestHealthDiagnostic.java | 185 ------ .../mso/client/sdno/beans/ResultInfo.java | 116 ---- .../org/openecomp/mso/client/sdno/beans/SDNO.java | 131 ---- .../sdno/dmaap/SDNOHealthCheckDmaapConsumer.java | 156 ----- .../sdno/dmaap/SDNOHealthCheckDmaapPublisher.java | 50 -- .../org/openecomp/mso/jsonpath/JsonPathUtil.java | 59 -- .../src/main/resources/META-INF/processes.xml | 32 - .../org.openecomp.mso.client.RestProperties | 2 + .../org.openecomp.mso.client.dmaap.DmaapProperties | 1 + .../subprocess/BuildingBlock/AppCClient.bpmn | 127 ++++ .../subprocess/BuildingBlock/DecomposeService.bpmn | 2 +- .../resources/subprocess/BuildingBlock/Homing.bpmn | 502 ++++++++-------- .../subprocess/BuildingBlock/ManualHandling.bpmn | 192 ++++-- .../subprocess/BuildingBlock/RainyDayHandler.bpmn | 4 +- .../subprocess/ReceiveWorkflowMessage.bpmn | 2 +- .../resources/subprocess/SDNCAdapterRestV2.bpmn | 539 +++++++++++++++++ .../src/main/resources/xsd/MSOWorkflowSchemaV1.xsd | 21 +- .../resources/xsd/MsoServiceRequestTypesV1.xsd | 21 +- bpmn/MSOCommonBPMN/src/main/resources/xsd/test.xsd | 68 +++ .../common/scripts/SDNCAdapterUtilsTest.groovy | 39 +- .../mso/bpmn/common/scripts/VidUtilsTest.groovy | 2 +- .../common/scripts/VnfAdapterRestV1Test.groovy | 44 ++ .../openecomp/mso/bpmn/common/AppCClientTest.java | 119 ++++ .../mso/bpmn/common/DecomposeServiceTest.java | 3 +- .../mso/bpmn/common/GenerateVfModuleNameTest.java | 78 +++ .../org/openecomp/mso/bpmn/common/HomingTest.java | 112 +++- .../mso/bpmn/common/ManualHandlingTest.java | 4 +- .../mso/bpmn/common/RainyDayHandlerTest.java | 4 +- .../bpmn/common/ReceiveWorkflowMessageTest.java | 29 +- .../mso/bpmn/common/SDNCAdapterRestV2Test.java | 152 +++++ .../mso/bpmn/common/SPIPropertiesTest.java | 69 +++ .../mso/bpmn/common/VnfAdapterRestV1Test.java | 8 +- .../openecomp/mso/bpmn/common/WorkflowTest.java | 68 ++- .../mso/bpmn/mock/SDNCAdapterAsyncTransformer.java | 157 +++++ .../openecomp/mso/bpmn/mock/StubResponseAAI.java | 30 +- .../openecomp/mso/bpmn/mock/StubResponseAPPC.java | 65 ++ .../mso/bpmn/mock/StubResponsePolicy.java | 29 + .../mso/bpmn/mock/VnfAdapterAsyncTransformer.java | 163 +++++ .../openecomp/mso/client/aai/AAIPServerTest.java | 65 -- .../openecomp/mso/client/aai/AAIValidatorTest.java | 99 ---- .../org/openecomp/mso/client/aai/EntitiesTest.java | 41 -- .../adapter/network/NetworkAdapterClientTest.java | 146 +++++ .../requests/db/RequestsDbAdapterClientTest.java | 50 ++ .../client/adapter/vnf/VnfAdapterClientTest.java | 156 +++++ .../appc/ApplicationControllerClientTest.java | 93 +-- .../ApplicationControllerOrchestratorTest.java | 73 +++ .../appc/ApplicationControllerSupportTest.java | 97 +-- .../openecomp/mso/client/sndc/SDNCOrchTest.java | 82 +++ .../__files/BuildingBlocks/catalogResp.json | 5 +- .../__files/BuildingBlocks/sniroCallback2AR1Vnf | 11 +- .../BuildingBlocks/sniroCallback2AR1Vnf2Net | 17 +- .../__files/BuildingBlocks/sniroCallbackInfraVnf | 3 +- .../__files/BuildingBlocks/sniroRequest_infravnf | 2 +- .../CreateVfModuleVolumeGroup_VID_request.json | 146 ++--- .../__files/CreateVfModule_VID_request.json | 126 ++-- .../__files/SDNCAdapterRestCallbackFinal.json | 8 + .../__files/SDNCAdapterRestCallbackNonFinal.json | 8 + .../__files/SDNCAdapterRestV2Request.json | 21 + .../__files/SDNCInterimNotification1.json | 41 ++ .../__files/StandardSDNCSynchResponse.xml | 5 + .../UpdateNetworkV2/updateNetworkResponse_500.xml | 136 ++--- .../__files/aai/bulkprocess/response-failure.json | 32 + .../__files/aai/bulkprocess/response-success.json | 32 + .../__files/aai/bulkprocess/test-request.json | 22 + .../__files/aai/resources/e2e-complex.json | 660 +++++++++++++++++++++ .../__files/aai/resources/empty-query-result.json | 3 + .../__files/aai/resources/mockObject.json | 10 + .../resources/service-instance-pathed-query.json | 8 + .../__files/getCatalogServiceResourcesData.json | 1 + .../getCatalogServiceResourcesDataWithConfig.json | 182 ++++++ .../resources/__files/sdncCallbackSoapWrapper.xml | 19 + .../src/test/resources/camunda.cfg.xml | 15 - .../src/test/resources/mso.bpmn.urn.properties | 37 +- .../src/test/resources/mso.properties | 42 ++ .../src/test/resources/mso.sdnc.properties | 152 +++++ .../ruby/create-ticket/create-ticket-request.json | 15 + .../custom-lport-mirror-post-check-request.json | 26 + .../custom-lport-mirror-pre-check-request.json | 26 + .../custom-port-mirror-post-check-request.json | 22 + .../custom-port-mirror-pre-check-request.json | 22 + .../openecomp/mso/client/sdno/output-failure.json | 25 + .../openecomp/mso/client/sdno/output-success.json | 22 + .../org/openecomp/mso/client/sdno/response.json | 17 + .../test/resources/sdnc_adapter_data_request.xml | 33 ++ .../src/test/resources/sdnc_adapter_request.xml | 47 ++ 242 files changed, 11712 insertions(+), 5892 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AppCClient.groovy create mode 100644 bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterRestV2.groovy create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/PayloadClient.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigModifyAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersConfigModify.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersHealthCheck.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersQuiesce.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersResumeTraffic.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersUpgrade.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/HealthCheckAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/QuiesceTrafficAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/RequestParametersConfigModify.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/RequestParametersHealthCheck.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ResumeTrafficAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/SnapshotAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/StartStopAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/UpgradeAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestProperties.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorException.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DefaultDmaapPropertiesImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaaproperties/DefaultDmaapPropertiesImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/AAIOrchestrator.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/SDNCOrchestrator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/PolicyRestPropertiesImpl.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java create mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml create mode 100644 bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.openecomp.mso.client.RestProperties create mode 100644 bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.openecomp.mso.client.dmaap.DmaapProperties create mode 100644 bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/AppCClient.bpmn create mode 100644 bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV2.bpmn create mode 100644 bpmn/MSOCommonBPMN/src/main/resources/xsd/test.xsd create mode 100644 bpmn/MSOCommonBPMN/src/test/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1Test.groovy create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/AppCClientTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenerateVfModuleNameTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterRestV2Test.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SPIPropertiesTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterAsyncTransformer.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAPPC.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterAsyncTransformer.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/EntitiesTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/RequestsDbAdapterClientTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sndc/SDNCOrchTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/SDNCAdapterRestCallbackFinal.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/SDNCAdapterRestCallbackNonFinal.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/SDNCAdapterRestV2Request.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/SDNCInterimNotification1.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/StandardSDNCSynchResponse.xml create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/response-failure.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/response-success.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/test-request.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/e2e-complex.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/empty-query-result.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/mockObject.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/service-instance-pathed-query.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/getCatalogServiceResourcesDataWithConfig.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/sdncCallbackSoapWrapper.xml create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/mso.properties create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/mso.sdnc.properties create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/output-success.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/response.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/sdnc_adapter_data_request.xml create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/sdnc_adapter_request.xml (limited to 'bpmn/MSOCommonBPMN/src') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy index f5f011fd0c..5a4b25dca9 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AaiUtil.groovy @@ -20,7 +20,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; import org.openecomp.mso.rest.APIResponse; import org.openecomp.mso.rest.RESTClient @@ -40,7 +40,7 @@ class AaiUtil { this.taskProcessor = taskProcessor } - public String getNetworkGenericVnfEndpoint(Execution execution) { + public String getNetworkGenericVnfEndpoint(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String endpoint = execution.getVariable("URN_aai_endpoint") def uri = getNetworkGenericVnfUri(execution) @@ -48,56 +48,56 @@ class AaiUtil { return endpoint + uri } - public String getNetworkGenericVnfUri(Execution execution) { + public String getNetworkGenericVnfUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'generic_vnf') taskProcessor.logDebug('AaiUtil.getNetworkGenericVnfUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getNetworkVpnBindingUri(Execution execution) { + public String getNetworkVpnBindingUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'vpn_binding') taskProcessor.logDebug('AaiUtil.getNetworkVpnBindingUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getNetworkPolicyUri(Execution execution) { + public String getNetworkPolicyUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'network_policy') taskProcessor.logDebug('AaiUtil.getNetworkPolicyUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getNetworkTableReferencesUri(Execution execution) { + public String getNetworkTableReferencesUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'route_table_reference') taskProcessor.logDebug('AaiUtil.getNetworkTableReferencesUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getNetworkVceUri(Execution execution) { + public String getNetworkVceUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'vce') taskProcessor.logDebug('AaiUtil.getNetworkVceUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getNetworkL3NetworkUri(Execution execution) { + public String getNetworkL3NetworkUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'l3_network') taskProcessor.logDebug('AaiUtil.getNetworkL3NetworkUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getBusinessCustomerUri(Execution execution) { + public String getBusinessCustomerUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'customer') taskProcessor.logDebug('AaiUtil.getBusinessCustomerUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - //public String getBusinessCustomerUriv7(Execution execution) { + //public String getBusinessCustomerUriv7(DelegateExecution execution) { // def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') // //def uri = getUri(execution, BUSINESS_CUSTOMERV7) // def uri = getUri(execution, 'Customer') @@ -105,7 +105,7 @@ class AaiUtil { // return uri //} - public String getCloudInfrastructureCloudRegionEndpoint(Execution execution) { + public String getCloudInfrastructureCloudRegionEndpoint(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String endpoint = execution.getVariable("URN_aai_endpoint") def uri = getCloudInfrastructureCloudRegionUri(execution) @@ -113,28 +113,28 @@ class AaiUtil { return endpoint + uri } - public String getCloudInfrastructureCloudRegionUri(Execution execution) { + public String getCloudInfrastructureCloudRegionUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'cloud_region') taskProcessor.logDebug('AaiUtil.getCloudInfrastructureCloudRegionUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getCloudInfrastructureTenantUri(Execution execution) { + public String getCloudInfrastructureTenantUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'tenant') taskProcessor.logDebug('AaiUtil.getCloudInfrastructureTenantUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getSearchNodesQueryUri(Execution execution) { + public String getSearchNodesQueryUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'nodes_query') taskProcessor.logDebug('AaiUtil.getSearchNodesQueryUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getSearchNodesQueryEndpoint(Execution execution) { + public String getSearchNodesQueryEndpoint(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String endpoint = execution.getVariable("URN_aai_endpoint") def uri = getSearchNodesQueryUri(execution) @@ -142,14 +142,14 @@ class AaiUtil { return endpoint + uri } - public String getSearchGenericQueryUri(Execution execution) { + public String getSearchGenericQueryUri(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def uri = getUri(execution, 'generic_query') taskProcessor.logDebug('AaiUtil.getSearchGenericQueryUri() - AAI URI: ' + uri, isDebugLogEnabled) return uri } - public String getVersion(Execution execution, resourceName, processKey) { + public String getVersion(DelegateExecution execution, resourceName, processKey) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') resourceName = resourceName.replaceAll('-', '_') @@ -178,7 +178,7 @@ class AaiUtil { (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}") } - public String getUri(Execution execution, resourceName) { + public String getUri(DelegateExecution execution, resourceName) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def processKey = taskProcessor.getMainProcessKey(execution) @@ -208,7 +208,7 @@ class AaiUtil { (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file') } - public String setNamespace(Execution execution) { + public String setNamespace(DelegateExecution execution) { def key = AAI_NAMESPACE_STRING_KEY aaiNamespace = execution.getVariable(key) if (aaiNamespace == null ) { @@ -219,7 +219,7 @@ class AaiUtil { /** * This method can be used for getting the building namespace out of uri. * NOTE: A getUri() method needs to be invoked first. - * Alternative method is the getNamespaceFromUri(Execution execution, String uri) + * Alternative method is the getNamespaceFromUri(DelegateExecution execution, String uri) * return namespace (plus version from uri) * * @param url @@ -242,13 +242,13 @@ class AaiUtil { /** * This method can be used for building namespace with aai version out of uri. - * NOTE: 2 arguments: Execution execution & String uri + * NOTE: 2 arguments: DelegateExecution execution & String uri * @param execution * @param url * * @return namespace */ - public String getNamespaceFromUri(Execution execution, String uri) { + public String getNamespaceFromUri(DelegateExecution execution, String uri) { String namespace = execution.getVariable(AAI_NAMESPACE_STRING_KEY) if (namespace == null ) { (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + AAI_NAMESPACE_STRING_KEY + ' not defined in the MSO URN properties file') @@ -293,7 +293,7 @@ class AaiUtil { * @return APIResponse * */ - public APIResponse executeAAIGetCall(Execution execution, String url){ + public APIResponse executeAAIGetCall(DelegateExecution execution, String url){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") taskProcessor.logDebug(" ======== STARTED Execute AAI Get Process ======== ", isDebugEnabled) APIResponse apiResponse = null @@ -315,7 +315,7 @@ class AaiUtil { taskProcessor.logDebug( "======== COMPLETED Execute AAI Get Process ======== ", isDebugEnabled) }catch(Exception e){ taskProcessor.logDebug("Exception occured while executing AAI Get Call. Exception is: \n" + e, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } return apiResponse } @@ -333,7 +333,7 @@ class AaiUtil { * @return APIResponse * */ - public APIResponse executeAAIPutCall(Execution execution, String url, String payload){ + public APIResponse executeAAIPutCall(DelegateExecution execution, String url, String payload){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") taskProcessor.logDebug( " ======== Started Execute AAI Put Process ======== ", isDebugEnabled) APIResponse apiResponse = null @@ -354,7 +354,7 @@ class AaiUtil { taskProcessor.logDebug( "======== Completed Execute AAI Put Process ======== ", isDebugEnabled) }catch(Exception e){ taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } return apiResponse } @@ -371,7 +371,7 @@ class AaiUtil { * @return APIResponse * */ - public APIResponse executeAAIPatchCall(Execution execution, String url, String payload){ + public APIResponse executeAAIPatchCall(DelegateExecution execution, String url, String payload){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") taskProcessor.logDebug( " ======== Started Execute AAI Patch Process ======== ", isDebugEnabled) APIResponse apiResponse = null @@ -393,7 +393,7 @@ class AaiUtil { taskProcessor.logDebug( "======== Completed Execute AAI Patch Process ======== ", isDebugEnabled) }catch(Exception e){ taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Patch Call. Exception is: \n" + e, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } return apiResponse } @@ -410,7 +410,7 @@ class AaiUtil { * @return APIResponse * */ - public APIResponse executeAAIDeleteCall(Execution execution, String url){ + public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled) APIResponse apiResponse = null @@ -431,7 +431,7 @@ class AaiUtil { taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled) }catch(Exception e){ taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } return apiResponse } @@ -448,7 +448,7 @@ class AaiUtil { * @return APIResponse * */ - public APIResponse executeAAIDeleteCall(Execution execution, String url, String payload, String authHeader){ + public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url, String payload, String authHeader){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled) APIResponse apiResponse = null @@ -469,7 +469,7 @@ class AaiUtil { taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled) }catch(Exception e){ taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } return apiResponse } @@ -486,7 +486,7 @@ class AaiUtil { * @return APIResponse * */ - public APIResponse executeAAIPostCall(Execution execution, String url, String payload){ + public APIResponse executeAAIPostCall(DelegateExecution execution, String url, String payload){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled) APIResponse apiResponse = null @@ -507,7 +507,7 @@ class AaiUtil { taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled) }catch(Exception e){ taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } return apiResponse } @@ -527,7 +527,7 @@ class AaiUtil { * @return APIResponse * */ - public APIResponse executeAAIPostCall(Execution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){ + public APIResponse executeAAIPostCall(DelegateExecution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled) APIResponse apiResponse = null @@ -546,7 +546,7 @@ class AaiUtil { taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled) }catch(Exception e){ taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } return apiResponse } @@ -559,7 +559,7 @@ class AaiUtil { * @param backend - "PO" - real region, or "SDNC" - v2.5 (fake region). */ - public String getAAICloudReqion(Execution execution, String url, String backend, inputCloudRegion){ + public String getAAICloudReqion(DelegateExecution execution, String url, String backend, inputCloudRegion){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") String regionId = "" try{ @@ -600,7 +600,7 @@ class AaiUtil { } }catch(Exception e) { taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") + (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage()) } return regionId } @@ -631,7 +631,7 @@ class AaiUtil { * @return moduleIndex * */ - public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(Execution execution, String aaiVnfResponse, String key, String value) { + public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(DelegateExecution execution, String aaiVnfResponse, String key, String value) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") if (aaiVnfResponse != null) { String vfModulesText = taskProcessor.utils.getNodeXml(aaiVnfResponse, "vf-modules") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index 32925f0619..d3f3696fcf 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -23,7 +23,7 @@ package org.openecomp.mso.bpmn.common.scripts; import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.camunda.bpm.engine.variable.VariableMap import org.camunda.bpm.engine.variable.Variables import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats @@ -126,7 +126,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * Logs a WorkflowException at the ERROR level with the specified message. * @param execution the execution */ - public void logWorkflowException(Execution execution, String message) { + public void logWorkflowException(DelegateExecution execution, String message) { def workflowException = execution.getVariable("WorkflowException") if (workflowException == null) { @@ -143,7 +143,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * @param execution the execution * @return the name of the destination variable */ - public saveWorkflowException(Execution execution, String variable) { + public saveWorkflowException(DelegateExecution execution, String variable) { if (variable == null) { throw new NullPointerException(); } @@ -164,7 +164,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * @param execution the execution * @return the validated request */ - public String validateRequest(Execution execution, String... requiredVariables) { + public String validateRequest(DelegateExecution execution, String... requiredVariables) { ExceptionUtil exceptionUtil = new ExceptionUtil() def method = getClass().getSimpleName() + '.validateRequest(' + 'execution=' + execution.getId() + @@ -252,7 +252,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * @param execution the execution * @return the inputVars */ - public Map validateJSONReq(Execution execution) { + public Map validateJSONReq(DelegateExecution execution) { def method = getClass().getSimpleName() + '.validateJSONReq(' + 'execution=' + execution.getId() + ')' @@ -303,7 +303,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * top-level process * @throws IllegalStateException if a response has already been sent */ - protected void sendWorkflowResponse(Execution execution, Object responseCode, String response) { + protected void sendWorkflowResponse(DelegateExecution execution, Object responseCode, String response) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') try { String processKey = getProcessKey(execution); @@ -376,7 +376,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * Returns true if a workflow response has already been sent. * @param execution the execution */ - protected boolean isWorkflowResponseSent(Execution execution) { + protected boolean isWorkflowResponseSent(DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String processKey = getProcessKey(execution); return String.valueOf(execution.getVariable(processKey + "WorkflowResponseSent")).equals("true"); @@ -388,7 +388,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * * @param execution the execution */ - public String getProcessKey(Execution execution) { + public String getProcessKey(DelegateExecution execution) { def testKey = execution.getVariable("testProcessKey") if(testKey!=null){ return testKey @@ -402,11 +402,11 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * top-level process. * @param execution the execution */ - public String getMainProcessKey(Execution execution) { - Execution exec = execution + public String getMainProcessKey(DelegateExecution execution) { + DelegateExecution exec = execution while (true) { - Execution parent = exec.getSuperExecution() + DelegateExecution parent = exec.getSuperExecution() if (parent == null) { parent = exec.getParent() @@ -433,7 +433,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * @param elementName Name of element to search for. * @return The element node, if found in the xml. */ - protected String getRequiredNodeXml(Execution execution, String xml, String elementName) { + protected String getRequiredNodeXml(DelegateExecution execution, String xml, String elementName) { ExceptionUtil exceptionUtil = new ExceptionUtil() def element = utils.getNodeXml(xml, elementName, false) if (element.trim().isEmpty()) { @@ -455,7 +455,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * @param elementName Name of element to whose value to get. * @return The non-empty value of the element, if found in the xml. */ - protected String getRequiredNodeText(Execution execution, String xml, String elementName) { + protected String getRequiredNodeText(DelegateExecution execution, String xml, String elementName) { ExceptionUtil exceptionUtil = new ExceptionUtil() def elementText = utils.getNodeText1(xml, elementName) if ((elementText == null) || (elementText.isEmpty())) { @@ -501,7 +501,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess *@param name *@param value */ - public void setVariable(Execution execution, String name, Object value) { + public void setVariable(DelegateExecution execution, String name, Object value) { VariableMap variables = Variables.createVariables() variables.putValueTyped('payload', Variables.objectValue(value) .serializationDataFormat(SerializationDataFormats.JAVA) // tells the engine to use java serialization for persisting the value @@ -517,7 +517,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess *@param name *@return **/ - public String getVariable(Execution execution, String name) { + public String getVariable(DelegateExecution execution, String name) { def myObj = execution.getVariable(name) if(myObj instanceof VariableMap){ VariableMap serializedObjectMap = (VariableMap) myObj @@ -571,7 +571,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * Sets flows success indicator variable. * */ - public void setSuccessIndicator(Execution execution, boolean isSuccess) { + public void setSuccessIndicator(DelegateExecution execution, boolean isSuccess) { String prefix = execution.getVariable('prefix') def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') @@ -584,7 +584,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * Sends a Error Sync Response * */ - public void sendSyncError(Execution execution) { + public void sendSyncError(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") String requestId = execution.getVariable("mso-request-id") logDebug('sendSyncError, requestId: ' + requestId, isDebugEnabled) @@ -605,7 +605,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess if (args != null && args.size() > 0) { // First argument of method to call is always the execution object - Execution execution = (Execution) args[0] + DelegateExecution execution = (DelegateExecution) args[0] def classAndMethod = getClass().getSimpleName() + '.' + methodName + '(execution=' + execution.getId() + ')' def isDebugEnabled = execution.getVariable('isDebugLogEnabled') @@ -693,7 +693,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * @param messageType the message type (e.g. SDNCAResponse or VNFAResponse) * @param correlator the correlator value (e.g. a request ID) */ - public String createCallbackURL(Execution execution, String messageType, String correlator) { + public String createCallbackURL(DelegateExecution execution, String messageType, String correlator) { String endpoint = (String) execution.getVariable('URN_mso_workflow_message_endpoint') if (endpoint == null || endpoint.isEmpty()) { @@ -719,7 +719,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess * @param messageType the message type (e.g. SNIROResponse) * @param correlator the correlator value (e.g. a request ID) */ - public String createWorkflowMessageAdapterCallbackURL(Execution execution, String messageType, String correlator) { + public String createWorkflowMessageAdapterCallbackURL(DelegateExecution execution, String messageType, String correlator) { String endpoint = (String) execution.getVariable('URN_mso_adapters_workflow_message_endpoint') if (endpoint == null || endpoint.isEmpty()) { @@ -737,7 +737,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess '/' + UriUtils.encodePathSegment(correlator, 'UTF-8') } - public void setRollbackEnabled(Execution execution, isDebugLogEnabled) { + public void setRollbackEnabled(DelegateExecution execution, isDebugLogEnabled) { // Rollback settings def prefix = execution.getVariable('prefix') @@ -771,7 +771,7 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess logDebug('rollbackEnabled (aka backoutOnFailure): ' + rollbackEnabled, isDebugLogEnabled) } - public void setBasicDBAuthHeader(Execution execution, isDebugLogEnabled) { + public void setBasicDBAuthHeader(DelegateExecution execution, isDebugLogEnabled) { try { String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy index 8e2403ceea..fc099caa5f 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AllottedResourceUtils.groovy @@ -2,14 +2,14 @@ package org.openecomp.mso.bpmn.common.scripts import org.apache.commons.lang3.StringEscapeUtils; import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.delegate.DelegateExecution; import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse; import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.delegate.DelegateExecution; import groovy.util.XmlParser import groovy.util.Node @@ -34,7 +34,7 @@ class AllottedResourceUtils { * return: orchStatus - > AR found with this orchStatus * setsVariable aaiARGetResponse */ - public String getAROrchStatus (Execution execution) { + public String getAROrchStatus (DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") utils.log("DEBUG"," ***** getAROrchStatus *****", isDebugEnabled) @@ -81,7 +81,7 @@ class AllottedResourceUtils { // get Allotted Resource by AllottedResourceId // used on Delete - called from doDeleteAR // setsVariable aaiARGetResponse - public String getARbyId (Execution execution, String allottedResourceId) { + public String getARbyId (DelegateExecution execution, String allottedResourceId) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", " ***** getARbyId ***** ", isDebugEnabled) String arLink = getARLinkbyId(execution, allottedResourceId) @@ -94,7 +94,7 @@ class AllottedResourceUtils { return ar; } - public String getPSIFmARLink(Execution execution, String arLink) + public String getPSIFmARLink(DelegateExecution execution, String arLink) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") // Path: /aai/{version}/business/customers/customer/{cust}/service-subscriptions/service-subscription/{subs}/service-instances/service-instance/{psiid}/allotted-resources/allotted-resource/{arid} @@ -108,7 +108,7 @@ class AllottedResourceUtils { // get Allotted Resource Link by AllottedResourceId using Nodes Query // used on Delete - called from getARbyId - public String getARLinkbyId (Execution execution, String allottedResourceId) { + public String getARLinkbyId (DelegateExecution execution, String allottedResourceId) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", " ***** getARLinkbyId ***** ", isDebugEnabled) String arLink = null @@ -154,7 +154,7 @@ class AllottedResourceUtils { // used on Create called from getARORchStatus // used on Delete called from getARbyId // setsVariable aaiARPath - used for Patch in create - public String getARbyLink (Execution execution, String link, String role) { + public String getARbyLink (DelegateExecution execution, String link, String role) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", " ***** getARbyLink ***** ", isDebugEnabled) String ar = null @@ -237,7 +237,7 @@ class AllottedResourceUtils { return ar } - public void updateAROrchStatus(Execution execution, String status, String aaiARPath){ + public void updateAROrchStatus(DelegateExecution execution, String status, String aaiARPath){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", " *** updaAROrchStatus *** ", isDebugEnabled) try{ @@ -275,7 +275,7 @@ class AllottedResourceUtils { } //Sets Variable "wasDeleted" - public void deleteAR(Execution execution, String aaiARPath){ + public void deleteAR(DelegateExecution execution, String aaiARPath){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", " *** deleteAR *** aaiARPath:" + aaiARPath, isDebugEnabled) try { @@ -315,7 +315,7 @@ class AllottedResourceUtils { utils.log("DEBUG", " *** Exit deleteAR *** ", isDebugEnabled) } - public void buildAAIErrorResponse(Execution execution, String response, String errorMessage){ + public void buildAAIErrorResponse(DelegateExecution execution, String response, String errorMessage){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", " *** BuildAAIErrorResponse*** ", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AppCClient.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AppCClient.groovy new file mode 100644 index 0000000000..8df6af7adb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AppCClient.groovy @@ -0,0 +1,135 @@ +package org.openecomp.mso.bpmn.common.scripts + +import java.util.HashMap; +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.hibernate.event.internal.AbstractLockUpgradeEventListener +import org.openecomp.mso.bpmn.core.HealthCheckHandler +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.client.appc.ApplicationControllerOrchestrator +import org.openecomp.mso.client.appc.ApplicationControllerOrchestratorException +import org.onap.appc.client.lcm.model.Action +import org.onap.appc.client.lcm.model.Status +import org.openecomp.mso.bpmn.appc.payload.PayloadClient +import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs +import org.openecomp.mso.client.appc.ApplicationControllerAction; +import groovy.transform.TypeChecked; +import java.util.UUID; + +/** + * This groovy class supports the AppCClient.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - mso-request-Id + * @param - isDebugLogEnabled + * @param - requestId + * @param - vnfId + * @param - action + * @param - payload + * + * Outputs: + * @param - errorcode + * @param - errorText + * @param - responsePayload + * @param - healthCheckIndex + * @param - workstep + * @param - rollbackVnfStop + * @param - rollbackVnfLock + * @param - rollbackQuiesceTraffic + */ + +public class AppCClient extends AbstractServiceTaskProcessor{ + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtils = new JsonUtils() + def prefix = "UPDVnfI_" + + public void preProcessRequest(DelegateExecution execution){ + + } + + public void runAppcCommand(DelegateExecution execution) { + String isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + utils.log("DEBUG", "***** Start runCommand *****", isDebugLogEnabled) + def method = getClass().getSimpleName() + '.runAppcCommand(' + + 'execution=' + execution.getId() + + ')' + logDebug('Entered ' + method, isDebugLogEnabled) + execution.setVariable("rollbackVnfStop", false) + execution.setVariable("rollbackVnfLock", false) + execution.setVariable("rollbackQuiesceTraffic", false) + String appcCode = "1002" + String responsePayload = "" + String appcMessage = "" + Action action = null + try { + action = (Action) execution.getVariable("action") + String vnfId = execution.getVariable('vnfId') + String msoRequestId = execution.getVariable('msoRequestId') + String vnfName = execution.getVariable('vnfName') + String aicIdentity = execution.getVariable('aicIdentity') + String vnfHostIpAddress = execution.getVariable('vnfHostIpAddress') + String vmIdList = execution.getVariable("vmIdList") + String identityUrl = execution.getVariable("identityUrl") + HashMap payloadInfo = new HashMap(); + payloadInfo.put("vnfName", vnfName) + payloadInfo.put("aicIdentity", aicIdentity) + payloadInfo.put("vnfHostIpAddress", vnfHostIpAddress) + payloadInfo.put("vmIdList", vmIdList) + payloadInfo.put("identityUrl", identityUrl) + Optional payload + logDebug("Running APP-C action: " + action.toString(), isDebugLogEnabled) + utils.log("DEBUG", "VNFID: " + vnfId, isDebugLogEnabled) + execution.setVariable('msoRequestId', msoRequestId) + execution.setVariable("failedActivity", "APP-C") + execution.setVariable('workStep', action.toString()) + if(execution.getVariable("payload") != null){ + String pay = execution.getVariable("payload") + payload = Optional.of(pay) + } + if(action.equals(Action.HealthCheck)){ + String healthCheckIndex = execution.getVariable('healthCheckIndex') + execution.setVariable('workStep', action.toString() + healthCheckIndex) + execution.setVariable('healthCheckIndex', healthCheckIndex + 1) + } + ApplicationControllerAction client = new ApplicationControllerAction() + utils.log("DEBUG", "Created Application Controller Action Object", isDebugLogEnabled) + //PayloadInfo contains extra information that adds on to payload before making request to appc + client.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo) + utils.log("DEBUG", "ran through the main method for Application Contoller", isDebugLogEnabled) + appcCode = client.getErrorCode() + appcMessage = client.getErrorMessage() + } + catch (BpmnError e) { + logError('Caught exception in ' + method, e) + appcMessage = e.getMessage() + } + execution.setVariable("errorCode", appcCode) + if (appcCode == '0' && action != null) { + if (action.equals(Action.Lock)) { + execution.setVariable("rollbackVnfLock", true) + } + if (action.equals(Action.Unlock)) { + execution.setVariable("rollbackVnfLock", false) + } + if (action.equals(Action.Start)) { + execution.setVariable("rollbackVnfStop", true) + } + if (action.equals(Action.Stop)) { + execution.setVariable("rollbackVnfStop", false) + } + if (action.equals(Action.QuiesceTraffic)) { + execution.setVariable("rollbackQuiesceTraffic", true) + } + if (action.equals(Action.ResumeTraffic)) { + execution.setVariable("rollbackQuiesceTraffic", false) + } + } + execution.setVariable("errorText", appcMessage) + execution.setVariable("responsePayload", responsePayload) + utils.log("DEBUG", "Error Message: " + appcMessage, isDebugLogEnabled) + utils.log("DEBUG","ERROR CODE: " + execution.getVariable("errorCode"), isDebugLogEnabled) + utils.log("DEBUG", "***** End of runCommand *****", isDebugLogEnabled) + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy index 921e0ee00d..7fcf310210 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CatalogDbUtils.groovy @@ -33,7 +33,7 @@ import groovy.json.JsonSlurper import groovy.util.slurpersupport.GPathResult import groovy.xml.QName; -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.rest.APIResponse; @@ -47,14 +47,14 @@ import org.openecomp.mso.rest.RESTConfig */ class CatalogDbUtils { - + MsoUtils utils = new MsoUtils() JsonUtils jsonUtils = new JsonUtils() MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); static private String defaultDbAdapterVersion = "v2" - public JSONArray getAllNetworksByServiceModelUuid(Execution execution, String serviceModelUuid) { - JSONArray networksList = null + public JSONArray getAllNetworksByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) { + JSONArray networksList = null String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -71,8 +71,8 @@ class CatalogDbUtils { return networksList } - public JSONArray getAllNetworksByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) { - JSONArray networksList = null + public JSONArray getAllNetworksByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) { + JSONArray networksList = null String endPoint = "/serviceNetworks?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -95,8 +95,8 @@ class CatalogDbUtils { return networksList } - public JSONArray getAllNetworksByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) { - JSONArray networksList = null + public JSONArray getAllNetworksByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) { + JSONArray networksList = null String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -113,8 +113,8 @@ class CatalogDbUtils { return networksList } - public JSONArray getAllNetworksByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { - JSONArray networksList = null + public JSONArray getAllNetworksByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { + JSONArray networksList = null String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -137,8 +137,8 @@ class CatalogDbUtils { return networksList } - public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) { - JSONArray networksList = null + public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) { + JSONArray networksList = null String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -155,8 +155,8 @@ class CatalogDbUtils { return networksList } - public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { - JSONArray networksList = null + public JSONArray getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { + JSONArray networksList = null String endPoint = "/serviceNetworks?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -179,8 +179,8 @@ class CatalogDbUtils { return networksList } - public JSONArray getAllNetworksByNetworkModelCustomizationUuid(Execution execution, String networkModelCustomizationUuid) { - JSONArray networksList = null + public JSONArray getAllNetworksByNetworkModelCustomizationUuid(DelegateExecution execution, String networkModelCustomizationUuid) { + JSONArray networksList = null String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -197,8 +197,8 @@ class CatalogDbUtils { return networksList } - public JSONArray getAllNetworksByNetworkModelCustomizationUuid(Execution execution, String networkModelCustomizationUuid, String catalogUtilsVersion) { - JSONArray networksList = null + public JSONArray getAllNetworksByNetworkModelCustomizationUuid(DelegateExecution execution, String networkModelCustomizationUuid, String catalogUtilsVersion) { + JSONArray networksList = null String endPoint = "/serviceNetworks?networkModelCustomizationUuid=" + UriUtils.encode(networkModelCustomizationUuid, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -221,8 +221,8 @@ class CatalogDbUtils { return networksList } - public JSONArray getAllNetworksByNetworkType(Execution execution, String networkType) { - JSONArray networksList = null + public JSONArray getAllNetworksByNetworkType(DelegateExecution execution, String networkType) { + JSONArray networksList = null String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -239,8 +239,8 @@ class CatalogDbUtils { return networksList } - public JSONArray getAllNetworksByNetworkType(Execution execution, String networkType, String catalogUtilsVersion) { - JSONArray networksList = null + public JSONArray getAllNetworksByNetworkType(DelegateExecution execution, String networkType, String catalogUtilsVersion) { + JSONArray networksList = null String endPoint = "/serviceNetworks?networkType=" + UriUtils.encode(networkType, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) @@ -264,8 +264,8 @@ class CatalogDbUtils { } - public JSONArray getAllVnfsByServiceModelUuid(Execution execution, String serviceModelUuid) { - JSONArray vnfsList = null + public JSONArray getAllVnfsByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) { + JSONArray vnfsList = null String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") try { msoLogger.debug("ENDPOINT: " + endPoint) @@ -283,8 +283,8 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllVnfsByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) { - JSONArray vnfsList = null + public JSONArray getAllVnfsByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) { + JSONArray vnfsList = null String endPoint = "/serviceVnfs?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") try { msoLogger.debug("ENDPOINT: " + endPoint) @@ -308,8 +308,8 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllVnfsByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) { - JSONArray vnfsList = null + public JSONArray getAllVnfsByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) { + JSONArray vnfsList = null String endPoint ="/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") try { msoLogger.debug("ENDPOINT: " + endPoint) @@ -327,8 +327,8 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllVnfsByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { - JSONArray vnfsList = null + public JSONArray getAllVnfsByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { + JSONArray vnfsList = null String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") try { msoLogger.debug("ENDPOINT: " + endPoint) @@ -352,8 +352,8 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) { - JSONArray vnfsList = null + public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) { + JSONArray vnfsList = null String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") try { msoLogger.debug("ENDPOINT: " + endPoint) @@ -371,8 +371,8 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { - JSONArray vnfsList = null + public JSONArray getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { + JSONArray vnfsList = null String endPoint = "/serviceVnfs?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") try { msoLogger.debug("ENDPOINT: " + endPoint) @@ -396,8 +396,8 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllVnfsByVnfModelCustomizationUuid(Execution execution, String vnfModelCustomizationUuid) { - JSONArray vnfsList = null + public JSONArray getAllVnfsByVnfModelCustomizationUuid(DelegateExecution execution, String vnfModelCustomizationUuid) { + JSONArray vnfsList = null String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8") try { msoLogger.debug("ENDPOINT: " + endPoint) @@ -414,7 +414,7 @@ class CatalogDbUtils { return vnfsList } - + /** * This method gets a all vnfs for a particular * service from the catalog database using the @@ -423,9 +423,9 @@ class CatalogDbUtils { * @param catalogDbEndpoint * @param serviceModelModelName * @return vnfsList * - * + * */ - public JSONArray getAllVnfsByServiceModelModelName(Execution execution, String serviceModelModelName) { + public JSONArray getAllVnfsByServiceModelModelName(DelegateExecution execution, String serviceModelModelName) { JSONArray vnfsList = null String endPoint = "/serviceVnfs?serviceModelName=" + UriUtils.encode(serviceModelModelName, "UTF-8") try { @@ -441,8 +441,8 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllVnfsByVnfModelCustomizationUuid(Execution execution, String vnfModelCustomizationUuid, String catalogUtilsVersion) { - JSONArray vnfsList = null + public JSONArray getAllVnfsByVnfModelCustomizationUuid(DelegateExecution execution, String vnfModelCustomizationUuid, String catalogUtilsVersion) { + JSONArray vnfsList = null String endPoint = "/serviceVnfs?vnfModelCustomizationUuid=" + UriUtils.encode(vnfModelCustomizationUuid, "UTF-8") try { msoLogger.debug("ENDPOINT: " + endPoint) @@ -476,8 +476,8 @@ class CatalogDbUtils { * @param vfModuleModelName * @return vfModule */ - public JSONObject getVfModuleByVfModuleModelName(Execution execution, String vfModuleModelName) { - JSONObject vfModule = null + public JSONObject getVfModuleByVfModuleModelName(DelegateExecution execution, String vfModuleModelName) { + JSONObject vfModule = null String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8") try{ msoLogger.debug("Get VfModule By VfModule ModelName Endpoint is: " + endPoint) @@ -505,7 +505,7 @@ class CatalogDbUtils { * @param catalogUtilsVersion * @return vfModules */ - public JSONObject getVfModuleByVfModuleModelName(Execution execution, String vfModuleModelName, String catalogUtilsVersion) { + public JSONObject getVfModuleByVfModuleModelName(DelegateExecution execution, String vfModuleModelName, String catalogUtilsVersion) { JSONObject vfModule = null String endPoint = "/vfModules?vfModuleModelName=" + UriUtils.encode(vfModuleModelName, "UTF-8") try{ @@ -524,7 +524,7 @@ class CatalogDbUtils { } - public JSONArray getAllottedResourcesByServiceModelUuid(Execution execution, String serviceModelUuid) { + public JSONArray getAllottedResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) { JSONArray vnfsList = null String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") try { @@ -542,7 +542,7 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllottedResourcesByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) { + public JSONArray getAllottedResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) { JSONArray vnfsList = null String endPoint = "/ServiceAllottedResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") try { @@ -566,7 +566,7 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllottedResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) { + public JSONArray getAllottedResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) { JSONArray vnfsList = null String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") try { @@ -584,7 +584,7 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllottedResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { + public JSONArray getAllottedResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { JSONArray vnfsList = null String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") try { @@ -609,7 +609,7 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) { + public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) { JSONArray vnfsList = null String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") try { @@ -627,7 +627,7 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { + public JSONArray getAllottedResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { JSONArray vnfsList = null String endPoint = "/serviceAllottedResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") try { @@ -652,7 +652,7 @@ class CatalogDbUtils { } - public JSONArray getAllottedResourcesByArModelCustomizationUuid(Execution execution, String arModelCustomizationUuid) { + public JSONArray getAllottedResourcesByArModelCustomizationUuid(DelegateExecution execution, String arModelCustomizationUuid) { JSONArray vnfsList = null String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8") try { @@ -670,7 +670,7 @@ class CatalogDbUtils { return vnfsList } - public JSONArray getAllottedResourcesByArModelCustomizationUuid(Execution execution, String arModelCustomizationUuid, String catalogUtilsVersion) { + public JSONArray getAllottedResourcesByArModelCustomizationUuid(DelegateExecution execution, String arModelCustomizationUuid, String catalogUtilsVersion) { JSONArray vnfsList = null String endPoint = "/serviceAllottedResources?serviceModelCustomizationUuid=" + UriUtils.encode(arModelCustomizationUuid, "UTF-8") try { @@ -694,58 +694,75 @@ class CatalogDbUtils { return vnfsList } - public JSONObject getServiceResourcesByServiceModelUuid(Execution execution, String serviceModelUuid) { - JSONObject resources = null - String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) + public JSONObject getServiceResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid) { + JSONObject resources = null + String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) + + if (catalogDbResponse != null) { + + resources = parseServiceResourcesJson(catalogDbResponse, "v1") + } + + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return resources + } - if (catalogDbResponse != null) { + public JSONObject getServiceResourcesByServiceModelUuid(DelegateExecution execution, String serviceModelUuid, String catalogUtilsVersion) { + JSONObject resources = null + String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - resources = parseServiceResourcesJson(catalogDbResponse, "v1") - } + if (catalogDbResponse != null) { + if (!catalogUtilsVersion.equals("v1")) { + resources = new JSONObject(catalogDbResponse) + } + else { + resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion) + } + } + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } - } - catch (Exception e) { - utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) - } + return resources + } - return resources - } + public JSONObject getServiceResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid) { + JSONObject resources = null + String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + try { + String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - public JSONObject getServiceResourcesByServiceModelUuid(Execution execution, String serviceModelUuid, String catalogUtilsVersion) { - JSONObject resources = null - String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8") - try { - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) + if (catalogDbResponse != null) { - if (catalogDbResponse != null) { - if (!catalogUtilsVersion.equals("v1")) { - resources = new JSONObject(catalogDbResponse) - } - else { - resources = parseServiceResourcesJson(catalogDbResponse, catalogUtilsVersion) - } - } + resources = parseServiceResourcesJson(catalogDbResponse, "v1") + } - } - catch (Exception e) { - utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) - } + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } - return resources - } + return resources + } - - public JSONObject getServiceResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid) { - JSONObject resources = null + public String getServiceResourcesByServiceModelInvariantUuidString(DelegateExecution execution, String serviceModelInvariantUuid) { + String resources = null String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) if (catalogDbResponse != null) { - resources = parseServiceResourcesJson(catalogDbResponse, "v1") + resources = catalogDbResponse } } @@ -756,7 +773,7 @@ class CatalogDbUtils { return resources } - public JSONObject getServiceResourcesByServiceModelInvariantUuid(Execution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { + public JSONObject getServiceResourcesByServiceModelInvariantUuid(DelegateExecution execution, String serviceModelInvariantUuid, String catalogUtilsVersion) { JSONObject resources = null String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") try { @@ -780,13 +797,14 @@ class CatalogDbUtils { } - public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion) { + public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion) { JSONObject resources = null String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") try { String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) if (catalogDbResponse != null) { + //TODO this is wrong resources = parseServiceResourcesJson(catalogDbResponse) } @@ -798,7 +816,7 @@ class CatalogDbUtils { return resources } - public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(Execution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { + public JSONObject getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(DelegateExecution execution, String serviceModelInvariantUuid, String serviceModelVersion, String catalogUtilsVersion) { JSONObject resources = null String endPoint = "/serviceResources?serviceModelInvariantUuid=" + UriUtils.encode(serviceModelInvariantUuid, "UTF-8") + "&serviceModelVersion=" + UriUtils.encode(serviceModelVersion, "UTF-8") try { @@ -903,9 +921,11 @@ class CatalogDbUtils { modelJson.put("nfNamingCode", nfCode) String nfFunction = jsonUtils.getJsonValueForKey(vnf, "nfFunction") modelJson.put("nfFunction", nfFunction) + String multiStageDesign = jsonUtils.getJsonValueForKey(vnf, "multiStageDesign") + modelJson.put("multiStageDesign", multiStageDesign) break } - + JSONArray vfModules = null try { vfModules = vnf.getJSONArray("vfModules") @@ -925,6 +945,7 @@ class CatalogDbUtils { vfModuleModelJson.put("vfModuleType", vfModuleType) switch(catalogUtilsVersion) { case "v1": + //TODO this does not work, isBase is not a integer. Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase") if (isBase.intValue() == 1) { vfModuleModelJson.put("isBase", "true") @@ -1042,8 +1063,10 @@ class CatalogDbUtils { modelJson.put("nfNamingCode", nfCode) String nfFunction = jsonUtils.getJsonValueForKey(allottedResource, "nfFunction") modelJson.put("nfFunction", nfFunction) - String parentServiceModelUuid = jsonUtils.getJsonValueForKey(allottedResource, "parentServiceModelUuid") - modelJson.put("parentServiceModelUuid", parentServiceModelUuid) + String providingServiceModelName = jsonUtils.getJsonValueForKey(allottedResource, "providingServiceModelName") + modelJson.put("providingServiceModelName", providingServiceModelName) + String providingServiceModelUuid = jsonUtils.getJsonValueForKey(allottedResource, "providingServiceModelUuid") + modelJson.put("providingServiceModelUuid", providingServiceModelUuid) break } @@ -1061,6 +1084,7 @@ class CatalogDbUtils { return modelInfos } + //TODO this is wrong private JSONObject parseServiceResourcesJson (String catalogDbResponse) { JSONObject serviceResources = new JSONObject() String catalogUtilsVersion = "v1" @@ -1124,7 +1148,7 @@ class CatalogDbUtils { modelInfo.put("modelType", modelType) String modelInvariantId = jsonUtils.getJsonValueForKey(modelFromDb, "modelInvariantUuid") modelInfo.put("modelInvariantId", modelInvariantId) - if(modelType.equalsIgnoreCase("allottedResource")){ + if(modelType.equalsIgnoreCase("allottedResource") || modelType.equalsIgnoreCase("vnf")){ String modelInstanceName = jsonUtils.getJsonValueForKey(modelFromDb, "modelInstanceName") modelInfo.put("modelInstanceName", modelInstanceName) } @@ -1162,7 +1186,7 @@ class CatalogDbUtils { return modelInfo } - private String getResponseFromCatalogDb (Execution execution, String endPoint) { + private String getResponseFromCatalogDb (DelegateExecution execution, String endPoint) { try { String catalogDbEndpoint = execution.getVariable("URN_mso_catalog_db_endpoint") String queryEndpoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + endPoint @@ -1174,7 +1198,7 @@ class CatalogDbUtils { addHeader('X-FromAppId', 'BPMN'). addHeader('Content-Type', 'application/json'). addHeader('Accept','application/json'); - + String basicAuthCred = execution.getVariable("BasicAuthHeaderValueDB") if (basicAuthCred != null && !"".equals(basicAuthCred)) { client.addAuthorizationHeader(basicAuthCred) @@ -1203,25 +1227,25 @@ class CatalogDbUtils { } } - - /** - * get resource recipe by resource model uuid and action - */ - public JSONObject getResourceRecipe(Execution execution, String resourceModelUuid, String action) { - String endPoint = "/resourceRecipe?resourceModelUuid=" + UriUtils.encode(resourceModelUuid, "UTF-8")+ "&action=" + UriUtils.encode(action, "UTF-8") - JSONObject responseJson = null - try { - msoLogger.debug("ENDPOINT: " + endPoint) - String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) - - if (catalogDbResponse != null) { - responseJson = new JSONObject(catalogDbResponse) - } - } - catch (Exception e) { - utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) - } - - return responseJson - } -} \ No newline at end of file + + /** + * get resource recipe by resource model uuid and action + */ + public JSONObject getResourceRecipe(DelegateExecution execution, String resourceModelUuid, String action) { + String endPoint = "/resourceRecipe?resourceModelUuid=" + UriUtils.encode(resourceModelUuid, "UTF-8")+ "&action=" + UriUtils.encode(action, "UTF-8") + JSONObject responseJson = null + try { + msoLogger.debug("ENDPOINT: " + endPoint) + String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint) + + if (catalogDbResponse != null) { + responseJson = new JSONObject(catalogDbResponse) + } + } + catch (Exception e) { + utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message) + } + + return responseJson + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy index 66a7c8e2b5..57a04e5439 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CompleteMsoProcess.groovy @@ -1,308 +1,314 @@ -/*- - * ============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.bpmn.common.scripts - -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution - - -public class CompleteMsoProcess extends AbstractServiceTaskProcessor { - - String Prefix="CMSO_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - // Complete MSO Request processing - public initializeProcessVariables(Execution execution){ - - def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - try { - - /* Initialize all the process request variables in this block */ - execution.setVariable("prefix",Prefix) - execution.setVariable("CMSO_request_id","") - execution.setVariable("CMSO_notification-url","") - execution.setVariable("CMSO_mso-bpel-name","") - execution.setVariable("CMSO_request_action","") - execution.setVariable("CMSO_notification-url-Ok", false) - execution.setVariable("CMSO_request_id-Ok", false) - - //updateRequest Adapter process variables - execution.setVariable("CMSO_updateRequestResponse", "") - execution.setVariable("CMSO_updateRequestResponseCode", "") - execution.setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "") - - //Set DB adapter variables here - execution.setVariable("CMSO_updateDBStatusToSuccessPayload", "") - execution.setVariable("CMSO_updateInfraRequestDBPayload", "") - execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "") - - //Auth variables - execution.setVariable("BasicAuthHeaderValue","") - - //Response variables - execution.setVariable("CompletionHandlerResponse","") - execution.setVariable("CMSO_ErrorResponse", null) - execution.setVariable("CMSO_ResponseCode", "") - - setSuccessIndicator(execution, false) - - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) - } - - } - - public void preProcessRequest (Execution execution) { - - initializeProcessVariables(execution) - def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') -// utils.log("DEBUG", "*** Started CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled); - logDebug('Entered ' + method, isDebugLogEnabled) - - setBasicDBAuthHeader(execution, isDebugLogEnabled) - - try { - def xml = execution.getVariable("CompleteMsoProcessRequest") - - utils.logAudit("CompleteMsoProcess Request: " + xml) - utils.log("DEBUG", "Incoming Request is: "+ xml, isDebugLogEnabled) - - //mso-bpel-name from the incoming request - def msoBpelName = utils.getNodeText1(xml,"mso-bpel-name") - execution.setVariable("CMSO_mso-bpel-name",msoBpelName) - - //Check the incoming request type - //Incoming request can be ACTIVE_REQUESTS (request-information node) or INFRA_ACTIVE_REQUESTS (request-info node) - if (utils.nodeExists(xml, "request-information")) { - execution.setVariable("CMSO_request_id-Ok", true) // Incoming request is for ACTIVE_REQUESTS - } - - //Check notification-url for the incoming request type - //ACTIVE_REQUESTS may have notificationurl node - //INFRA_ACTIVE_REQUESTS notificationurl node does not exist - def notificationurl = "" - if (utils.nodeExists(xml, "notification-url")) { - notificationurl = utils.getNodeText(xml,"notification-url") - if(notificationurl != null && !notificationurl.isEmpty()) { - execution.setVariable("CMSO_notification-url-Ok", true) - execution.setVariable("CMSO_notification-url",notificationurl) - } - } - - //Check request_id for the incoming request type - //For INFRA_ACTIVE_REQUESTS payload request-id IS optional (Not sure why this is option since req id is primary key ... also tried exe through SOAP UI to check if MSO code handles null like auto generated seq not it does not) - //For ACTIVE_REQUESTS payload request-id is NOT optional - def request_id = "" - if (utils.nodeExists(xml, "request-id")) { - execution.setVariable("CMSO_request_id",utils.getNodeText(xml,"request-id")) - } - - - // INFRA_ACTIVE_REQUESTS have "action" element ... mandatory - // ACTIVE_REQUEST have "request-action" ... mandatory - if (utils.nodeExists(xml, "request-action")) { - execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"request-action")) - } else if (utils.nodeExists(xml, "action")) { - execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"action")) - } - - //Check source for the incoming request type - //For INFRA_ACTIVE_REQUESTS payload source IS optional - //For ACTIVE_REQUESTS payload source is NOT optional - def source = "" - if (utils.nodeExists(xml, "source")) { - execution.setVariable("CMSO_source",utils.getNodeText(xml,"source")) - } - - utils.log("DEBUG", "CMSO_notification-url-Ok --> " + execution.getVariable("CMSO_notification-url-Ok"), isDebugLogEnabled) - utils.log("DEBUG", "CMSO_request_id-Ok --> " + execution.getVariable("CMSO_request_id-Ok"), isDebugLogEnabled) - - // set the DHV/Service Instantiation values if specified in the request - execution.setVariable("CMSO_is_srv_inst_req", String.valueOf("true".equals(utils.getNodeText1(xml, "is-srv-inst-req")))) - utils.log("DEBUG", "CMSO_is_srv_inst_req --> " + execution.getVariable("CMSO_is_srv_inst_req"), isDebugLogEnabled) - execution.setVariable("CMSO_is_json_content", String.valueOf("JSON".equals(utils.getNodeText1(xml, "resp-content-type")))) - utils.log("DEBUG", "CMSO_is_json_content --> " + execution.getVariable("CMSO_is_json_content"), isDebugLogEnabled) - execution.setVariable("CMSO_service_inst_id", utils.getNodeText1(xml, "service-instance-id")) - utils.log("DEBUG", "CMSO_service_inst_id --> " + execution.getVariable("CMSO_service_inst_id"), isDebugLogEnabled) - execution.setVariable("CMSO_start_time", utils.getNodeText1(xml, "start-time")) - utils.log("DEBUG", "CMSO_start_time --> " + execution.getVariable("CMSO_start_time"), isDebugLogEnabled) - // this variable is used by the camunda flow to set the Content-Type for the async response - if (execution.getVariable("CMSO_is_srv_inst_req").equals("true") && - execution.getVariable("CMSO_is_json_content").equals("true")) { - execution.setVariable("CMSO_content_type", "application/json") - } else { - execution.setVariable("CMSO_content_type", "text/xml") - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - utils.log("DEBUG", "Exception Occured During PreProcessRequest: " + e, isDebugLogEnabled); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in " + method) - } - -// utils.log("DEBUG", "*** Completed CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled); - } - - public void setUpdateDBstatustoSuccessPayload (Execution execution){ - - def method = getClass().getSimpleName() + '.setUpdateDBstatustoSuccessPayload(' +'execution=' + execution.getId() +')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - - def xml = execution.getVariable("CompleteMsoProcessRequest") - - //Get statusMessage if exists - def statusMessage - if(utils.nodeExists(xml, "status-message")){ - statusMessage = utils.getNodeText1(xml, "status-message") - }else{ - statusMessage = "Resource Completed Successfully" - } - - //Get instance Id if exist - String idXml = "" - if(utils.nodeExists(xml, "vnfId")){ - idXml = utils.getNodeXml(xml, "vnfId") - }else if(utils.nodeExists(xml, "networkId")){ - idXml = utils.getNodeXml(xml, "networkId") - }else if(utils.nodeExists(xml, "serviceInstanceId")){ - idXml = utils.getNodeXml(xml, "serviceInstanceId") - }else if(utils.nodeExists(xml, "vfModuleId")){ - idXml = utils.getNodeXml(xml, "vfModuleId") - }else if(utils.nodeExists(xml, "volumeGroupId")){ - idXml = utils.getNodeXml(xml, "volumeGroupId") - }else{ - idXml = "" - } - idXml = utils.removeXmlPreamble(idXml) - utils.log("DEBUG", "Incoming Instance Id Xml: " + idXml, isDebugLogEnabled) - - String payload = """ - - - - - ${execution.getVariable("CMSO_request_id")} - ${execution.getVariable("CMSO_mso-bpel-name")} - ${statusMessage} - COMPLETE - 100 - ${idXml} - - - """ - - execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", payload) - utils.log("DEBUG", "Outgoing Update Mso Request Payload is: " + payload, isDebugLogEnabled) - utils.logAudit("setUpdateDBstatustoSuccessPayload: " + payload) - - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) - } - logDebug('Exited ' + method, isDebugLogEnabled) - } - - public void buildDataError (Execution execution, String message) { - - def method = getClass().getSimpleName() + '.buildDataError(' +'execution=' + execution.getId() +')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - try { - - def msoCompletionResponse = """ - - BPEL ${execution.getVariable("CMSO_mso-bpel-name")} FAILED - - """.trim() - - // Format Response - def xmlMsoCompletionResponse = utils.formatXml(msoCompletionResponse) - String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim() - utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString) - execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString) - utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompletionHandlerResponse"), isDebugLogEnabled) - - exceptionUtil.buildAndThrowWorkflowException(execution, 500, message) - - } catch (BpmnError e) { - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugLogEnabled) - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) - } - - } - - public void postProcessResponse (Execution execution) { - - def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - // utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled); - try { - - def msoCompletionResponse = """ - - BPEL ${execution.getVariable("CMSO_mso-bpel-name")} completed - - """.trim() - - // Format Response - def xmlMsoCompletionResponse = utils.formatXML(msoCompletionResponse) - String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim() - // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead - execution.setVariable("WorkflowResponse", buildMsoCompletionResponseAsString) - utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString) - execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString) - execution.setVariable("CMSO_ResponseCode", "200") - - setSuccessIndicator(execution, true) - - utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"), isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) - } - // utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled); - - } - - -} +/*- + * ============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.bpmn.common.scripts + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution + + +public class CompleteMsoProcess extends AbstractServiceTaskProcessor { + + String Prefix="CMSO_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + + // Complete MSO Request processing + public initializeProcessVariables(DelegateExecution execution){ + + def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + try { + + /* Initialize all the process request variables in this block */ + execution.setVariable("prefix",Prefix) + execution.setVariable("CMSO_request_id","") + execution.setVariable("CMSO_notification-url","") + execution.setVariable("CMSO_mso-bpel-name","") + execution.setVariable("CMSO_request_action","") + execution.setVariable("CMSO_notification-url-Ok", false) + execution.setVariable("CMSO_request_id-Ok", false) + + //updateRequest Adapter process variables + execution.setVariable("CMSO_updateRequestResponse", "") + execution.setVariable("CMSO_updateRequestResponseCode", "") + execution.setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "") + + //Set DB adapter variables here + execution.setVariable("CMSO_updateDBStatusToSuccessPayload", "") + execution.setVariable("CMSO_updateInfraRequestDBPayload", "") + execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "") + + //Auth variables + execution.setVariable("BasicAuthHeaderValue","") + + //Response variables + execution.setVariable("CompletionHandlerResponse","") + execution.setVariable("CMSO_ErrorResponse", null) + execution.setVariable("CMSO_ResponseCode", "") + + setSuccessIndicator(execution, false) + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + + } + + public void preProcessRequest (DelegateExecution execution) { + + initializeProcessVariables(execution) + def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') +// utils.log("DEBUG", "*** Started CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled); + logDebug('Entered ' + method, isDebugLogEnabled) + + setBasicDBAuthHeader(execution, isDebugLogEnabled) + + try { + def xml = execution.getVariable("CompleteMsoProcessRequest") + + utils.logAudit("CompleteMsoProcess Request: " + xml) + utils.log("DEBUG", "Incoming Request is: "+ xml, isDebugLogEnabled) + + //mso-bpel-name from the incoming request + def msoBpelName = utils.getNodeText1(xml,"mso-bpel-name") + execution.setVariable("CMSO_mso-bpel-name",msoBpelName) + + //Check the incoming request type + //Incoming request can be ACTIVE_REQUESTS (request-information node) or INFRA_ACTIVE_REQUESTS (request-info node) + if (utils.nodeExists(xml, "request-information")) { + execution.setVariable("CMSO_request_id-Ok", true) // Incoming request is for ACTIVE_REQUESTS + } + + //Check for rehome indicator + def rehomeIndicator = utils.getNodeText1(xml,"rehomeDone") + execution.setVariable("rehomeDone", rehomeIndicator) + + //Check notification-url for the incoming request type + //ACTIVE_REQUESTS may have notificationurl node + //INFRA_ACTIVE_REQUESTS notificationurl node does not exist + def notificationurl = "" + if (utils.nodeExists(xml, "notification-url")) { + notificationurl = utils.getNodeText(xml,"notification-url") + if(notificationurl != null && !notificationurl.isEmpty()) { + execution.setVariable("CMSO_notification-url-Ok", true) + execution.setVariable("CMSO_notification-url",notificationurl) + } + } + + //Check request_id for the incoming request type + //For INFRA_ACTIVE_REQUESTS payload request-id IS optional (Not sure why this is option since req id is primary key ... also tried exe through SOAP UI to check if MSO code handles null like auto generated seq not it does not) + //For ACTIVE_REQUESTS payload request-id is NOT optional + def request_id = "" + if (utils.nodeExists(xml, "request-id")) { + execution.setVariable("CMSO_request_id",utils.getNodeText(xml,"request-id")) + } + + + // INFRA_ACTIVE_REQUESTS have "action" element ... mandatory + // ACTIVE_REQUEST have "request-action" ... mandatory + if (utils.nodeExists(xml, "request-action")) { + execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"request-action")) + } else if (utils.nodeExists(xml, "action")) { + execution.setVariable("CMSO_request_action",utils.getNodeText(xml,"action")) + } + + //Check source for the incoming request type + //For INFRA_ACTIVE_REQUESTS payload source IS optional + //For ACTIVE_REQUESTS payload source is NOT optional + def source = "" + if (utils.nodeExists(xml, "source")) { + execution.setVariable("CMSO_source",utils.getNodeText(xml,"source")) + } + + utils.log("DEBUG", "CMSO_notification-url-Ok --> " + execution.getVariable("CMSO_notification-url-Ok"), isDebugLogEnabled) + utils.log("DEBUG", "CMSO_request_id-Ok --> " + execution.getVariable("CMSO_request_id-Ok"), isDebugLogEnabled) + + // set the DHV/Service Instantiation values if specified in the request + execution.setVariable("CMSO_is_srv_inst_req", String.valueOf("true".equals(utils.getNodeText1(xml, "is-srv-inst-req")))) + utils.log("DEBUG", "CMSO_is_srv_inst_req --> " + execution.getVariable("CMSO_is_srv_inst_req"), isDebugLogEnabled) + execution.setVariable("CMSO_is_json_content", String.valueOf("JSON".equals(utils.getNodeText1(xml, "resp-content-type")))) + utils.log("DEBUG", "CMSO_is_json_content --> " + execution.getVariable("CMSO_is_json_content"), isDebugLogEnabled) + execution.setVariable("CMSO_service_inst_id", utils.getNodeText1(xml, "service-instance-id")) + utils.log("DEBUG", "CMSO_service_inst_id --> " + execution.getVariable("CMSO_service_inst_id"), isDebugLogEnabled) + execution.setVariable("CMSO_start_time", utils.getNodeText1(xml, "start-time")) + utils.log("DEBUG", "CMSO_start_time --> " + execution.getVariable("CMSO_start_time"), isDebugLogEnabled) + // this variable is used by the camunda flow to set the Content-Type for the async response + if (execution.getVariable("CMSO_is_srv_inst_req").equals("true") && + execution.getVariable("CMSO_is_json_content").equals("true")) { + execution.setVariable("CMSO_content_type", "application/json") + } else { + execution.setVariable("CMSO_content_type", "text/xml") + } + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + utils.log("DEBUG", "Exception Occured During PreProcessRequest: " + e, isDebugLogEnabled); + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in " + method) + } + +// utils.log("DEBUG", "*** Completed CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled); + } + + public void setUpdateDBstatustoSuccessPayload (DelegateExecution execution){ + + def method = getClass().getSimpleName() + '.setUpdateDBstatustoSuccessPayload(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + + def xml = execution.getVariable("CompleteMsoProcessRequest") + + //Get statusMessage if exists + def statusMessage + if(utils.nodeExists(xml, "status-message")){ + statusMessage = utils.getNodeText1(xml, "status-message") + }else{ + statusMessage = "Resource Completed Successfully" + } + + //Get instance Id if exist + String idXml = "" + if(utils.nodeExists(xml, "vnfId")){ + idXml = utils.getNodeXml(xml, "vnfId") + }else if(utils.nodeExists(xml, "networkId")){ + idXml = utils.getNodeXml(xml, "networkId") + }else if(utils.nodeExists(xml, "configurationId")){ + idXml = utils.getNodeXml(xml, "configurationId") + }else if(utils.nodeExists(xml, "serviceInstanceId")){ + idXml = utils.getNodeXml(xml, "serviceInstanceId") + }else if(utils.nodeExists(xml, "vfModuleId")){ + idXml = utils.getNodeXml(xml, "vfModuleId") + }else if(utils.nodeExists(xml, "volumeGroupId")){ + idXml = utils.getNodeXml(xml, "volumeGroupId") + }else{ + idXml = "" + } + idXml = utils.removeXmlPreamble(idXml) + utils.log("DEBUG", "Incoming Instance Id Xml: " + idXml, isDebugLogEnabled) + + String payload = """ + + + + + ${execution.getVariable("CMSO_request_id")} + ${execution.getVariable("CMSO_mso-bpel-name")} + ${statusMessage} + COMPLETE + 100 + ${idXml} + + + """ + + execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", payload) + utils.log("DEBUG", "Outgoing Update Mso Request Payload is: " + payload, isDebugLogEnabled) + utils.logAudit("setUpdateDBstatustoSuccessPayload: " + payload) + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + logDebug('Exited ' + method, isDebugLogEnabled) + } + + public void buildDataError (DelegateExecution execution, String message) { + + def method = getClass().getSimpleName() + '.buildDataError(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + try { + + def msoCompletionResponse = """ + + BPEL ${execution.getVariable("CMSO_mso-bpel-name")} FAILED + + """.trim() + + // Format Response + def xmlMsoCompletionResponse = utils.formatXml(msoCompletionResponse) + String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim() + utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString) + execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString) + utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompletionHandlerResponse"), isDebugLogEnabled) + + exceptionUtil.buildAndThrowWorkflowException(execution, 500, message) + + } catch (BpmnError e) { + utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugLogEnabled) + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + + } + + public void postProcessResponse (DelegateExecution execution) { + + def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + // utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled); + try { + + def msoCompletionResponse = """ + + BPEL ${execution.getVariable("CMSO_mso-bpel-name")} completed + + """.trim() + + // Format Response + def xmlMsoCompletionResponse = utils.formatXML(msoCompletionResponse) + String buildMsoCompletionResponseAsString = xmlMsoCompletionResponse.drop(38).trim() + // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead + execution.setVariable("WorkflowResponse", buildMsoCompletionResponseAsString) + utils.logAudit("CompleteMsoProcess Response: " + buildMsoCompletionResponseAsString) + execution.setVariable("CompleteMsoProcessResponse", buildMsoCompletionResponseAsString) + execution.setVariable("CMSO_ResponseCode", "200") + + setSuccessIndicator(execution, true) + + utils.log("DEBUG", "@@ CompleteMsoProcess Response @@ " + "\n" + execution.getVariable("CompleteMsoProcessResponse"), isDebugLogEnabled) + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + // utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled); + + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupName.groovy index 6c8f315193..615e25de71 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupName.groovy @@ -19,7 +19,7 @@ */ package org.openecomp.mso.bpmn.common.scripts -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.rest.APIResponse @@ -28,7 +28,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ def Prefix="CVGN_" ExceptionUtil exceptionUtil = new ExceptionUtil() - public void initProcessVariables(Execution execution) { + public void initProcessVariables(DelegateExecution execution) { execution.setVariable("prefix",Prefix) execution.setVariable("CVGN_volumeGroupId",null) execution.setVariable("CVGN_volumeGroupName",null) @@ -44,8 +44,8 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ execution.setVariable("RollbackData", null) } - // store the incoming data in the flow Execution - public void preProcessRequest(Execution execution) { + // store the incoming data in the flow DelegateExecution + public void preProcessRequest(DelegateExecution execution) { def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") def volumeGroupId = execution.getVariable("ConfirmVolumeGroupName_volumeGroupId") def volumeGroupName= execution.getVariable("ConfirmVolumeGroupName_volumeGroupName") @@ -66,7 +66,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ // send a GET request to AA&I to retrieve the Volume information based on volume-group-id // expect a 200 response with the information in the response body or a 404 if the volume group id does not exist - public void queryAAIForVolumeGroupId(Execution execution) { + public void queryAAIForVolumeGroupId(DelegateExecution execution) { def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("CVGN_volumeGroupGetEndpoint") @@ -97,7 +97,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ // process the result from queryAAIVolumeGroupId() - public void checkAAIQueryResult(Execution execution) { + public void checkAAIQueryResult(DelegateExecution execution) { def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") def result = execution.getVariable("CVGN_queryVolumeGroupResponse") @@ -123,7 +123,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ // generates a WorkflowException if the A&AI query returns a response code other than 200/404 - public void handleAAIQueryFailure(Execution execution) { + public void handleAAIQueryFailure(DelegateExecution execution) { def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") logError("Error occurred attempting to query AAI, Response Code " + @@ -136,7 +136,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ } // generates a WorkflowException if the volume group name does not match AAI record for this volume group - public void handleVolumeGroupNameNoMatch(Execution execution) { + public void handleVolumeGroupNameNoMatch(DelegateExecution execution) { def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") def errorNotAssociated = "Error occurred - volume group id " + execution.getVariable("CVGN_volumeGroupId") + @@ -150,7 +150,7 @@ public class ConfirmVolumeGroupName extends AbstractServiceTaskProcessor{ } // sends a successful WorkflowResponse - public void reportSuccess(Execution execution) { + public void reportSuccess(DelegateExecution execution) { def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") logDebug("Sending 200 back to the caller", isDebugLogEnabled) def responseXML = "" diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy index b9fba52dbd..ecb18043a7 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ConfirmVolumeGroupTenant.groovy @@ -25,7 +25,7 @@ import javax.xml.parsers.DocumentBuilderFactory import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse import org.w3c.dom.Document @@ -48,7 +48,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ String Prefix="CVGT_" ExceptionUtil exceptionUtil = new ExceptionUtil() - public void preProcessRequest(Execution execution){ + public void preProcessRequest(DelegateExecution execution){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix", Prefix) utils.log("DEBUG", " ======== STARTED Confirm Volume Group Tenant Subflow ======== ", isDebugEnabled) @@ -148,7 +148,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ utils.log("DEBUG", "=== COMPLETED queryAAIForVolumeGroup Process === ", isDebugEnabled) } - public void assignVolumeHeatId(Execution execution){ + public void assignVolumeHeatId(DelegateExecution execution){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix", Prefix) try{ @@ -170,7 +170,7 @@ class ConfirmVolumeGroupTenant extends AbstractServiceTaskProcessor{ utils.log("DEBUG", "======== COMPLETED Confirm Volume Group Tenant Subflow ======== ", isDebugEnabled) } - public void assignWorkflowException(Execution execution, String message){ + public void assignWorkflowException(DelegateExecution execution, String message){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix", Prefix) String processKey = getProcessKey(execution); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy index 5c72c33b13..41036e7f43 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModule.groovy @@ -19,7 +19,7 @@ */ package org.openecomp.mso.bpmn.common.scripts -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.core.RollbackData import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse @@ -30,7 +30,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ def Prefix="CAAIVfMod_" ExceptionUtil exceptionUtil = new ExceptionUtil() - public void initProcessVariables(Execution execution) { + public void initProcessVariables(DelegateExecution execution) { execution.setVariable("prefix",Prefix) execution.setVariable("CAAIVfMod_vnfId",null) execution.setVariable("CAAIVfMod_vnfName",null) @@ -73,8 +73,8 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ } // parse the incoming CREATE_VF_MODULE request and store the Generic VNF - // and VF Module data in the flow Execution - public void preProcessRequest(Execution execution) { + // and VF Module data in the flow DelegateExecution + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") initProcessVariables(execution) @@ -180,7 +180,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ // send a GET request to AA&I to retrieve the Generic VNF/VF Module information based on a Vnf Name // expect a 200 response with the information in the response body or a 404 if the Generic VNF does not exist - public void queryAAIForGenericVnf(Execution execution) { + public void queryAAIForGenericVnf(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("CAAIVfMod_genericVnfGetEndpoint") @@ -209,7 +209,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ // process the result from queryAAIForGenericVnf() // note: this method is primarily for logging as the actual decision logic is embedded in the bpmn flow - public void processAAIGenericVnfQuery(Execution execution) { + public void processAAIGenericVnfQuery(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def result = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") @@ -236,7 +236,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ // construct and send a PUT request to A&AI to create a new Generic VNF // note: to get here, the vnf-id in the original CREATE_VF_MODULE request was absent or "" - public void createGenericVnf(Execution execution) { + public void createGenericVnf(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") // TBD - is this how we want to generate the Id for the new Generic VNF? def newVnfId = UUID.randomUUID().toString() @@ -287,7 +287,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ } // construct and send a PUT request to A&AI to create a Base or Add-on VF Module - public void createVfModule(Execution execution, Boolean isBaseModule) { + public void createVfModule(DelegateExecution execution, Boolean isBaseModule) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") // TBD - is this how we want to generate the Id for the new (Base) VF Module? @@ -402,7 +402,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ // parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name // requested for an Add-on VF Module does not already exist for the specified Generic VNF // also retrieves VNF name from AAI response for existing VNF - public void parseForAddOnModule(Execution execution) { + public void parseForAddOnModule(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def xml = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") def vnfNameFromAAI = utils.getNodeText1(xml, "vnf-name") @@ -439,7 +439,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ // parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name // requested for an Add-on VF Module does not already exist for the specified Generic VNF; // also retrieves VNF name from AAI response for existing VNF - public void parseForBaseModule(Execution execution) { + public void parseForBaseModule(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def xml = execution.getVariable("CAAIVfMod_queryGenericVnfResponse") def vnfNameFromAAI = utils.getNodeText1(xml, "vnf-name") @@ -491,7 +491,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ } // generates a WorkflowException when the A&AI query returns a response code other than 200 or 404 - public void handleAAIQueryFailure(Execution execution) { + public void handleAAIQueryFailure(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("ERROR", "Error occurred attempting to query AAI, Response Code " + @@ -508,7 +508,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ // - the requested Generic VNF does not exist but vnf-id != null // - the A&AI VF Module PUT returns a response code other than 200 or 201 // - the requested VF Module already exists for the Generic VNF - public void handleCreateVfModuleFailure(Execution execution) { + public void handleCreateVfModuleFailure(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def errorCode @@ -563,7 +563,7 @@ public class CreateAAIVfModule extends AbstractServiceTaskProcessor{ * main CreateVfModule flow. * @param execution the execution */ - public void rollback(Execution execution) { + public void rollback(DelegateExecution execution) { def method = getClass().getSimpleName() + ".rollback(" + "execution=" + execution.getId() + ")" diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy index a15a86d566..5edf391bb4 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CreateAAIVfModuleVolumeGroup.groovy @@ -21,7 +21,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.rest.APIResponse @@ -35,7 +35,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void initProcessVariables(Execution execution) { + public void initProcessVariables(DelegateExecution execution) { execution.setVariable('prefix', 'CAAIVfModVG_') execution.setVariable('CAAIVfModVG_vnfId', null) execution.setVariable('CAAIVfModVG_vfModuleId', null) @@ -52,7 +52,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def method = getClass().getSimpleName() + '.preProcessRequest(' + 'execution=' + execution.getId() + ')' @@ -93,7 +93,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void getVfModule(Execution execution) { + public void getVfModule(DelegateExecution execution) { def method = getClass().getSimpleName() + '.getVfModule(' + 'execution=' + execution.getId() + ')' @@ -143,7 +143,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void updateVfModule(Execution execution) { + public void updateVfModule(DelegateExecution execution) { def method = getClass().getSimpleName() + '.updateVfModule(' + 'execution=' + execution.getId() + ')' @@ -295,7 +295,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void handleAAIQueryFailure(Execution execution) { + public void handleAAIQueryFailure(DelegateExecution execution) { def method = getClass().getSimpleName() + '.handleAAIQueryFailure(' + 'execution=' + execution.getId() + ')' @@ -316,7 +316,7 @@ public class CreateAAIVfModuleVolumeGroup extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void handleUpdateVfModuleFailure(Execution execution) { + public void handleUpdateVfModuleFailure(DelegateExecution execution) { def method = getClass().getSimpleName() + '.handleUpdateVfModuleFailure(' + 'execution=' + execution.getId() + ')' diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CustomE2EGetService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CustomE2EGetService.groovy index af2da67439..86b35853ba 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CustomE2EGetService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CustomE2EGetService.groovy @@ -25,7 +25,7 @@ import static org.apache.commons.lang3.StringUtils.* import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.rest.APIResponse import org.springframework.web.util.UriUtils @@ -102,7 +102,7 @@ class CustomE2EGetService extends AbstractServiceTaskProcessor{ * @param - execution * */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService PreProcessRequest Process*** ", isDebugEnabled) @@ -188,7 +188,7 @@ class CustomE2EGetService extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void obtainServiceInstanceUrlById(Execution execution){ + public void obtainServiceInstanceUrlById(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlById Process*** ", isDebugEnabled) @@ -270,7 +270,7 @@ class CustomE2EGetService extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void obtainServiceInstanceUrlByName(Execution execution){ + public void obtainServiceInstanceUrlByName(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlByName Process*** ", isDebugEnabled) @@ -338,7 +338,7 @@ class CustomE2EGetService extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void getServiceObject(Execution execution){ + public void getServiceObject(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService GetServiceObject Process*** ", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CustomE2EPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CustomE2EPutService.groovy index 946ba1aaa0..2c42ef03b3 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CustomE2EPutService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/CustomE2EPutService.groovy @@ -23,7 +23,7 @@ package org.openecomp.mso.bpmn.common.scripts import static org.apache.commons.lang3.StringUtils.*; import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.delegate.DelegateExecution; import org.apache.commons.codec.binary.Base64 import org.apache.commons.lang3.* @@ -78,7 +78,7 @@ class CustomE2EPutService extends AbstractServiceTaskProcessor{ ExceptionUtil exceptionUtil = new ExceptionUtil() - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericPutService PreProcessRequest Process*** ", isDebugEnabled) @@ -174,7 +174,7 @@ class CustomE2EPutService extends AbstractServiceTaskProcessor{ * @param - execution * */ - public void putServiceInstance(Execution execution){ + public void putServiceInstance(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericPutService PutServiceInstance method*** ", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy index 8d855e9311..7a81ce519e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DecomposeService.groovy @@ -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 @@ import static org.apache.commons.lang3.StringUtils.*; import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONObject; import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils @@ -64,7 +64,7 @@ public class DecomposeService extends AbstractServiceTaskProcessor { CatalogDbUtils catalogDbUtils = new CatalogDbUtils() JsonUtils jsonUtils = new JsonUtils() - public void preProcessRequest (Execution execution) { + public void preProcessRequest (DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") String msg = "" utils.log("DEBUG"," ***** preProcessRequest of DecomposeService *****", isDebugEnabled) @@ -76,7 +76,13 @@ public class DecomposeService extends AbstractServiceTaskProcessor { String requestId = execution.getVariable("msoRequestId") String serviceInstanceId = execution.getVariable("serviceInstanceId") String serviceModelInfo = execution.getVariable("serviceModelInfo") - execution.setVariable("DDS_serviceModelInvariantId", jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid")) + String invariantId + if(jsonUtils.jsonElementExist(serviceModelInfo, "modelInvariantUuid")){ + invariantId = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid") + }else if(jsonUtils.jsonElementExist(serviceModelInfo, "modelInvariantId")){ + invariantId = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantId") + } + execution.setVariable("DDS_serviceModelInvariantId", invariantId) execution.setVariable("DDS_serviceModelUuid", jsonUtils.getJsonValue(serviceModelInfo, "modelUuid")) execution.setVariable("DDS_modelVersion", jsonUtils.getJsonValue(serviceModelInfo, "modelVersion")) } catch (BpmnError e) { @@ -89,7 +95,7 @@ public class DecomposeService extends AbstractServiceTaskProcessor { utils.log("DEBUG"," ***** Exit preProcessRequest of DecomposeService *****", isDebugEnabled) } - public void queryCatalogDb (Execution execution) { + public void queryCatalogDb (DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") String msg = "" utils.log("DEBUG"," ***** queryCatalogDB of DecomposeService *****", isDebugEnabled) @@ -111,6 +117,13 @@ public class DecomposeService extends AbstractServiceTaskProcessor { catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(execution, serviceModelInvariantId, modelVersion, "v2") else catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuid(execution, serviceModelInvariantId, "v2") + + if (catalogDbResponse == null || catalogDbResponse.toString().equalsIgnoreCase("null")) { + msg = "No data found in Catalog DB" + utils.log("DEBUG", msg, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + String catalogDbResponseString = catalogDbResponse.toString() execution.setVariable("DDS_catalogDbResponse", catalogDbResponseString) @@ -128,7 +141,7 @@ public class DecomposeService extends AbstractServiceTaskProcessor { - public void actuallyDecomposeService (Execution execution) { + public void actuallyDecomposeService (DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") String msg = "" utils.log("DEBUG"," ***** actuallyDecomposeService of DecomposeService *****", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy index 63f12dd9cb..54e3da54d2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/DeleteAAIVfModule.groovy @@ -19,7 +19,7 @@ */ package org.openecomp.mso.bpmn.common.scripts -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse import org.openecomp.mso.rest.RESTClient; @@ -31,7 +31,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ def Prefix="DAAIVfMod_" ExceptionUtil exceptionUtil = new ExceptionUtil() private MsoUtils utils = new MsoUtils() - public void initProcessVariables(Execution execution) { + public void initProcessVariables(DelegateExecution execution) { execution.setVariable("prefix",Prefix) execution.setVariable("DAAIVfMod_vnfId",null) execution.setVariable("DAAIVfMod_vnfName",null) @@ -56,8 +56,8 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ } // parse the incoming DELETE_VF_MODULE request and store the Generic Vnf - // and Vf Module Ids in the flow Execution - public void preProcessRequest(Execution execution) { + // and Vf Module Ids in the flow DelegateExecution + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def xml = execution.getVariable("DeleteAAIVfModuleRequest") utils.logAudit("DeleteAAIVfModule Request: " + xml) @@ -79,7 +79,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // send a GET request to AA&I to retrieve the Generic Vnf/Vf Module information based on a Vnf Id // expect a 200 response with the information in the response body or a 404 if the Generic Vnf does not exist - public void queryAAIForGenericVnf(Execution execution) { + public void queryAAIForGenericVnf(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def delModuleId = execution.getVariable("DAAIVfMod_vfModuleId") def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + "?depth=1" @@ -117,7 +117,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // construct and send a DELETE request to A&AI to delete a Generic Vnf // note: to get here, all the modules associated with the Generic Vnf must already be deleted - public void deleteGenericVnf(Execution execution) { + public void deleteGenericVnf(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def aaiRequestId = utils.getRequestID() def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_genericVnfEndpoint") + @@ -150,7 +150,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ } // construct and send a DELETE request to A&AI to delete the Base or Add-on Vf Module - public void deleteVfModule(Execution execution) { + public void deleteVfModule(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def endPoint = execution.getVariable("URN_aai_endpoint") + execution.getVariable("DAAIVfMod_vfModuleEndpoint") + "/?resource-version=" + execution.getVariable("DAAIVfMod_vfModRsrcVer") @@ -189,7 +189,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // parses the output from the result from queryAAIForGenericVnf() to determine if the Vf Module // to be deleted exists for the specified Generic Vnf and if it is the Base Module, // there are no Add-on Modules present - public void parseForVfModule(Execution execution) { + public void parseForVfModule(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def xml = execution.getVariable("DAAIVfMod_queryGenericVnfResponse") utils.logAudit("DeleteAAIVfModule - queryGenericVnfResponse" + xml) @@ -270,7 +270,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // parses the output from the result from queryAAIForGenericVnf() to determine if the Vf Module // to be deleted exists for the specified Generic Vnf and if it is the Base Module, // there are no Add-on Modules present - public void parseForResourceVersion(Execution execution) { + public void parseForResourceVersion(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def xml = execution.getVariable("DAAIVfMod_queryGenericVnfResponse") utils.logAudit("DeleteAAIVfModule - queryGenericVnfResponse" + xml) @@ -281,7 +281,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // generates a WorkflowException if the A&AI query returns a response code other than 200 - public void handleAAIQueryFailure(Execution execution) { + public void handleAAIQueryFailure(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("ERROR", "Error occurred attempting to query AAI, Response Code " + @@ -300,7 +300,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // - the A&AI Vf Module DELETE returns a response code other than 200 // - the Vf Module is a Base Module that is not the last Vf Module // - the Vf Module does not exist for the Generic Vnf - public void handleDeleteVfModuleFailure(Execution execution) { + public void handleDeleteVfModuleFailure(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") def errorCode = 2000 @@ -341,7 +341,7 @@ public class DeleteAAIVfModule extends AbstractServiceTaskProcessor{ // generates a WorkflowException if // - the A&AI Generic Vnf DELETE returns a response code other than 200 - public void handleDeleteGenericVnfFailure(Execution execution) { + public void handleDeleteGenericVnfFailure(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("ERROR", "AAI error occurred deleting the Generic Vnf: " + execution.getVariable("DAAIVfMod_deleteGenericVnfResponse"), isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy index 121e0c8ccb..b65ce74c70 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ExceptionUtil.groovy @@ -22,9 +22,11 @@ package org.openecomp.mso.bpmn.common.scripts import static org.apache.commons.lang3.StringUtils.* +import com.google.common.xml.XmlEscapers + import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.core.WorkflowException /** @@ -44,7 +46,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { * @param execution the execution * @param response the aai exception */ - WorkflowException MapAAIExceptionToWorkflowException(String response, Execution execution) + WorkflowException MapAAIExceptionToWorkflowException(String response, DelegateExecution execution) { def utils=new MsoUtils() def isDebugEnabled=execution.getVariable("isDebugLogEnabled") @@ -116,7 +118,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { * @param execution the execution * @param response the aai exception */ - WorkflowException MapAAIExceptionToWorkflowExceptionGeneric(Execution execution, String response, int resCode){ + WorkflowException MapAAIExceptionToWorkflowExceptionGeneric(DelegateExecution execution, String response, int resCode){ def utils=new MsoUtils() def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", "Start MapAAIExceptionToWorkflowExceptionGeneric Process", isDebugLogEnabled) @@ -159,7 +161,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { String buildErrorResponseXml(WorkflowException wfex) { String xml if(wfex != null){ - String mes = wfex.getErrorMessage() + String mes = XmlEscapers.xmlContentEscaper().escape(wfex.getErrorMessage()) int code = wfex.getErrorCode() xml = """ @@ -221,12 +223,11 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { errorMessage="" } if( errorCode.equals('5010')){ - return 'Could not communicate with A&AI' + return 'Could not communicate with A&AI' }else if (errorCode.equals('5020')){ - return 'No response from A&AI' + return 'No response from A&AI' }else{ - errorMessage = errorMessage.replace("&", "&").replace("<", "<").replace(">", ">") - return 'Received error from A&AI (' +errorMessage +')' + return 'Received error from A&AI (' +errorMessage +')' } } @@ -261,7 +262,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { * @param errorCode the error code * @param errorMessage the error message */ - public void buildWorkflowException(Execution execution, int errorCode, String errorMessage) { + public void buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) { MsoUtils utils = new MsoUtils() def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String processKey = getProcessKey(execution); @@ -281,7 +282,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { * @param errorCode the error code * @param errorMessage the error message */ - public void buildAndThrowWorkflowException(Execution execution, int errorCode, String errorMessage) { + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) { def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') String processKey = getProcessKey(execution); utils.log("Building a WorkflowException for Subflow " + processKey, isDebugLogEnabled) @@ -302,7 +303,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { * @param - execution * */ - public void processSubflowsBPMNException(Execution execution){ + public void processSubflowsBPMNException(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") String processKey = getProcessKey(execution) try{ @@ -329,7 +330,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { * @return - falloutHandlerRequest * */ - public String processMainflowsBPMNException(Execution execution, String requestInfo){ + public String processMainflowsBPMNException(DelegateExecution execution, String requestInfo){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") String processKey = getProcessKey(execution) try{ @@ -339,7 +340,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { } requestInfo = utils.removeXmlPreamble(requestInfo) WorkflowException wfex = execution.getVariable("WorkflowException") - String errorMessage = wfex.getErrorMessage() + String errorMessage = XmlEscapers.xmlContentEscaper().escape(wfex.getErrorMessage()) int errorCode = wfex.getErrorCode() String falloutHandlerRequest = @@ -354,13 +355,14 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { """ utils.log("DEBUG", processKey + " Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled) - utils.log("DEBUG", processKey + "Completed ProcessMainflowBPMNException Outgoing FalloutHandler Request is: " + falloutHandlerRequest, isDebugEnabled) + utils.log("DEBUG", processKey + " Outgoing FalloutHandler Request is: " + falloutHandlerRequest, isDebugEnabled) return falloutHandlerRequest }catch(Exception e){ utils.log("DEBUG", "Caught Exception during ProcessMainflowBPMNException Method: " + e, isDebugEnabled) return null } + utils.log("DEBUG", "Completed ProcessMainflowBPMNException Method", isDebugEnabled) } /** @@ -371,7 +373,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { * @param - execution * */ - public void processJavaException(Execution execution){ + public void processJavaException(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") String processKey = getProcessKey(execution) try{ @@ -389,7 +391,7 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { } - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { // TODO Auto-generated method stub } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy index 8237fcfd11..0356397eaa 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/FalloutHandler.groovy @@ -23,13 +23,13 @@ package org.openecomp.mso.bpmn.common.scripts import java.text.SimpleDateFormat import org.apache.commons.lang3.* -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution public class FalloutHandler extends AbstractServiceTaskProcessor { String Prefix="FH_" ExceptionUtil exceptionUtil = new ExceptionUtil() - public initializeProcessVariables(Execution execution){ + public initializeProcessVariables(DelegateExecution execution){ def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')' def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') logDebug('Entered ' + method, isDebugLogEnabled) @@ -93,7 +93,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } } - public void preProcessRequest (Execution execution) { + public void preProcessRequest (DelegateExecution execution) { def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') logDebug('Entered ' + method, isDebugLogEnabled) @@ -207,7 +207,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { utils.log("DEBUG","OUTOF --> Initialize Variables Fallout Handler #########",isDebugLogEnabled); } - public String updateRequestPayload (Execution execution){ + public String updateRequestPayload (DelegateExecution execution){ def method = getClass().getSimpleName() + '.updateRequestPayload(' +'execution=' + execution.getId() +')' def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') logDebug('Entered ' + method, isDebugLogEnabled) @@ -238,7 +238,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } } - public String updateRequestInfraPayload (Execution execution){ + public String updateRequestInfraPayload (DelegateExecution execution){ def method = getClass().getSimpleName() + '.updateRequestInfraPayload(' +'execution=' + execution.getId() +')' def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') logDebug('Entered ' + method, isDebugLogEnabled) @@ -268,7 +268,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } } - public String updateRequestGammaPayload (Execution execution){ + public String updateRequestGammaPayload (DelegateExecution execution){ def method = getClass().getSimpleName() + '.updateRequestGammaPayload(' +'execution=' + execution.getId() +')' def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') logDebug('Entered ' + method, isDebugLogEnabled) @@ -298,7 +298,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } } - public String updateResponseStatusPayload (Execution execution){ + public String updateResponseStatusPayload (DelegateExecution execution){ def method = getClass().getSimpleName() + '.updateResponseStatusPayload(' +'execution=' + execution.getId() +')' def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') logDebug('Entered ' + method, isDebugLogEnabled) @@ -326,7 +326,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { } } - public void buildDBWorkflowException(Execution execution, String responseCodeVariable) { + public void buildDBWorkflowException(DelegateExecution execution, String responseCodeVariable) { def method = getClass().getSimpleName() + '.buildDBWorkflowException(' + 'execution=' + execution.getId() + ', responseCodeVariable=' + responseCodeVariable + ')' @@ -348,7 +348,7 @@ public class FalloutHandler extends AbstractServiceTaskProcessor { /** * Used to create a workflow response in success and failure cases. */ - public void postProcessResponse (Execution execution) { + public void postProcessResponse (DelegateExecution execution) { def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')' def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') logDebug('Entered ' + method, isDebugLogEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy index 9fbc7b35e0..95c258f2a4 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -21,7 +21,7 @@ package org.openecomp.mso.bpmn.common.scripts import java.io.Serializable; import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.springframework.web.util.UriUtils import org.openecomp.mso.bpmn.core.json.JsonUtils @@ -37,7 +37,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") try { @@ -58,7 +58,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ } - public void queryAAI(Execution execution) { + public void queryAAI(DelegateExecution execution) { def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") def method = getClass().getSimpleName() + '.queryAAI(' + 'execution=' + execution.getId() + @@ -150,7 +150,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ } - public void generateName (Execution execution) { + public void generateName (DelegateExecution execution) { def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") def method = getClass().getSimpleName() + '.generateName() ' + 'execution=' + execution.getId() + diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteService.groovy index 6dd27b292f..8d9defdb86 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteService.groovy @@ -24,7 +24,7 @@ import static org.apache.commons.lang3.StringUtils.* import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.rest.APIResponse import org.springframework.web.util.UriUtils @@ -85,7 +85,7 @@ class GenericDeleteService extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericDeleteService PreProcessRequest Process*** ", isDebugEnabled) @@ -153,7 +153,7 @@ class GenericDeleteService extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void getServiceResourceVersion(Execution execution){ + public void getServiceResourceVersion(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericDeleteService GetServiceResourceVersion Process*** ", isDebugEnabled) @@ -193,6 +193,7 @@ class GenericDeleteService extends AbstractServiceTaskProcessor{ String aaiResponse = response.getResponseBodyAsString() aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) + aaiResponse = aaiResponse.replaceAll("&", "&") execution.setVariable("GENDS_getServiceResponse", aaiResponse) utils.logAudit("GET Service Instance response : " + aaiResponse) @@ -231,7 +232,7 @@ class GenericDeleteService extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void deleteServiceObject(Execution execution){ + public void deleteServiceObject(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericDeleteService DeleteServiceObject Process*** ", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy index ea7365c192..d6a49d9f51 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericDeleteVnf.groovy @@ -24,7 +24,7 @@ import static org.apache.commons.lang3.StringUtils.* import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.rest.APIResponse import org.springframework.web.util.UriUtils @@ -84,7 +84,7 @@ class GenericDeleteVnf extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericDeleteVnf PreProcessRequest Process*** ", isDebugEnabled) @@ -130,7 +130,7 @@ class GenericDeleteVnf extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void getVnfResourceVersion(Execution execution){ + public void getVnfResourceVersion(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericDeleteVnf GetVnfResourceVersion Process*** ", isDebugEnabled) @@ -208,7 +208,7 @@ class GenericDeleteVnf extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void deleteVnf(Execution execution){ + public void deleteVnf(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericDeleteVnf DeleteVnf Process*** ", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy index cfc5171dca..3b380a9164 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetService.groovy @@ -22,7 +22,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.apache.commons.lang3.StringEscapeUtils import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.rest.APIResponse import org.springframework.web.util.UriUtils @@ -101,7 +101,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{ * @param - execution * */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService PreProcessRequest Process*** ", isDebugEnabled) @@ -187,7 +187,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void obtainServiceInstanceUrlById(Execution execution){ + public void obtainServiceInstanceUrlById(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlById Process*** ", isDebugEnabled) @@ -269,7 +269,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void obtainServiceInstanceUrlByName(Execution execution){ + public void obtainServiceInstanceUrlByName(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlByName Process*** ", isDebugEnabled) @@ -339,7 +339,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void getServiceObject(Execution execution){ + public void getServiceObject(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetService GetServiceObject Process*** ", isDebugEnabled) @@ -410,6 +410,7 @@ class GenericGetService extends AbstractServiceTaskProcessor{ aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) execution.setVariable("GENGS_getServiceResponse", aaiResponse) utils.logAudit("GenericGetService AAI Response: " + aaiResponse) + aaiResponse = aaiResponse.replaceAll("&", "&") //Process Response if(responseCode == 200 || responseCode == 202){ utils.log("DEBUG", "GET Service Received a Good Response Code", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy index 3192971f9b..1e181a6ee9 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericGetVnf.groovy @@ -24,7 +24,7 @@ import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.*; import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.rest.APIResponse import org.springframework.web.util.UriUtils @@ -84,7 +84,7 @@ class GenericGetVnf extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetVnf PreProcessRequest Process*** ", isDebugEnabled) @@ -126,7 +126,7 @@ class GenericGetVnf extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void getVnfByName(Execution execution){ + public void getVnfByName(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetVnf GetVnfByName Process*** ", isDebugEnabled) @@ -199,7 +199,7 @@ class GenericGetVnf extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void getVnfById(Execution execution){ + public void getVnfById(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericGetVnf GetVnfById Process*** ", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericNotificationService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericNotificationService.groovy index 62d476d294..7f3b41d6ec 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericNotificationService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericNotificationService.groovy @@ -1,7 +1,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.core.WorkflowException @@ -14,7 +14,7 @@ public class GenericNotificationService extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() - public void preProcessRequest (Execution execution) { + public void preProcessRequest (DelegateExecution execution) { } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy index cfe662f74c..d1b733aecb 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutService.groovy @@ -22,7 +22,7 @@ package org.openecomp.mso.bpmn.common.scripts import static org.apache.commons.lang3.StringUtils.*; import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.delegate.DelegateExecution; import org.apache.commons.codec.binary.Base64 import org.apache.commons.lang3.* @@ -77,7 +77,8 @@ class GenericPutService extends AbstractServiceTaskProcessor{ ExceptionUtil exceptionUtil = new ExceptionUtil() - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { + execution.setVariable("isDebugLogEnabled","true") def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericPutService PreProcessRequest Process*** ", isDebugEnabled) @@ -95,7 +96,7 @@ class GenericPutService extends AbstractServiceTaskProcessor{ String allottedResourceId = execution.getVariable("GENPS_allottedResourceId") String tunnelXconnectId = execution.getVariable("GENPS_tunnelXconnectId") String type = execution.getVariable("GENPS_type") - + if(type != null){ utils.log("DEBUG", "Incoming GENPS_type is: " + type, isDebugEnabled) if(type.equalsIgnoreCase("service-instance")){ @@ -164,8 +165,6 @@ class GenericPutService extends AbstractServiceTaskProcessor{ } - - /** * This method executes a Put call to AAI for the provided * service instance. @@ -173,8 +172,8 @@ class GenericPutService extends AbstractServiceTaskProcessor{ * @param - execution * */ - public void putServiceInstance(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + public void putServiceInstance(DelegateExecution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericPutService PutServiceInstance method*** ", isDebugEnabled) try { @@ -195,6 +194,7 @@ class GenericPutService extends AbstractServiceTaskProcessor{ String serviceType = execution.getVariable("GENPS_serviceType") utils.log("DEBUG", " Incoming GENPS_serviceType is: " + serviceType, isDebugEnabled) + String globalSubscriberId = execution.getVariable("GENPS_globalSubscriberId") utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) @@ -241,7 +241,6 @@ class GenericPutService extends AbstractServiceTaskProcessor{ execution.setVariable("GENPS_putServiceInstanceAaiPath", serviceAaiPath) utils.log("DEBUG", "PUT Service Instance AAI Path is: " + "\n" + serviceAaiPath, isDebugEnabled) - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, serviceAaiPath, payload) int responseCode = response.getStatusCode() execution.setVariable("GENPS_putServiceInstanceResponseCode", responseCode) @@ -251,7 +250,6 @@ class GenericPutService extends AbstractServiceTaskProcessor{ aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) execution.setVariable("GENPS_putServiceInstanceResponse", aaiResponse) - //Process Response if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) //200 OK 201 CREATED 202 ACCEPTED @@ -275,6 +273,4 @@ class GenericPutService extends AbstractServiceTaskProcessor{ utils.log("DEBUG", " *** COMPLETED GenericPutService PutServiceInstance Process*** ", isDebugEnabled) } - - } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutVnf.groovy index 04f0ab7926..e814950b94 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/GenericPutVnf.groovy @@ -24,7 +24,7 @@ import static org.apache.commons.lang3.StringUtils.* import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.rest.APIResponse import org.springframework.web.util.UriUtils @@ -68,7 +68,7 @@ class GenericPutVnf extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericPutVnf PreProcessRequest Process*** ", isDebugEnabled) @@ -113,7 +113,7 @@ class GenericPutVnf extends AbstractServiceTaskProcessor{ * * @param - execution */ - public void putVnf(Execution execution){ + public void putVnf(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix",Prefix) utils.log("DEBUG", " *** STARTED GenericPutVnf PutVnf Process*** ", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy index 0abab94597..2325e6c3d3 100755 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/Homing.groovy @@ -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. @@ -20,7 +20,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil @@ -29,6 +29,7 @@ import org.openecomp.mso.bpmn.core.domain.InventoryType import org.openecomp.mso.bpmn.core.domain.Resource import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition import org.openecomp.mso.bpmn.core.domain.Subscriber +import org.openecomp.mso.bpmn.core.domain.VnfResource import org.openecomp.mso.bpmn.core.json.JsonUtils import org.openecomp.mso.rest.APIResponse import org.openecomp.mso.rest.RESTClient @@ -64,7 +65,7 @@ class Homing extends AbstractServiceTaskProcessor{ * * @author cb645j */ - public void callSniro(Execution execution){ + public void callSniro(DelegateExecution execution){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") execution.setVariable("prefix","HOME_") utils.log("DEBUG", "*** Started Homing Call Sniro ***", isDebugEnabled) @@ -139,16 +140,11 @@ class Homing extends AbstractServiceTaskProcessor{ utils.log("DEBUG", "Posting to Sniro Url: " + url, isDebugEnabled) logDebug( "URL to be used is: " + url, isDebugEnabled) - - String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey")) - + RESTConfig config = new RESTConfig(url); RESTClient client = new RESTClient(config).addAuthorizationHeader(authHeader).addHeader("Content-Type", "application/json") - if (basicAuthCred != null && !"".equals(basicAuthCred)) { - client.addAuthorizationHeader(basicAuthCred) - } APIResponse response = client.httpPost(sniroRequest) - + int responseCode = response.getStatusCode() execution.setVariable("syncResponseCode", responseCode); logDebug("SNIRO sync response code is: " + responseCode, isDebugEnabled) @@ -165,7 +161,7 @@ class Homing extends AbstractServiceTaskProcessor{ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in Homing CallSniro: " + e.getMessage()) } } - + /** * This method processes the callback response * and the contained homing solution. It sets @@ -176,7 +172,7 @@ class Homing extends AbstractServiceTaskProcessor{ * * @author cb645j */ - public void processHomingSolution(Execution execution){ + public void processHomingSolution(DelegateExecution execution){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", "*** Started Homing Process Homing Solution ***", isDebugEnabled) try{ @@ -185,7 +181,7 @@ class Homing extends AbstractServiceTaskProcessor{ utils.logAudit("Sniro Async Callback Response is: " + response) sniroUtils.validateCallbackResponse(execution, response) - String placements = jsonUtil.getJsonValue(response, "solutionInfo.placement") + String placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo") ServiceDecomposition decomposition = execution.getVariable("serviceDecomposition") utils.log("DEBUG", "Service Decomposition: " + decomposition, isDebugEnabled) @@ -202,14 +198,17 @@ class Homing extends AbstractServiceTaskProcessor{ String inventoryType = placement.getString("inventoryType") resource.getHomingSolution().setInventoryType(InventoryType.valueOf(inventoryType)) resource.getHomingSolution().setCloudRegionId(placement.getString("cloudRegionId")) + resource.getHomingSolution().setRehome(placement.getBoolean("isRehome")) JSONArray assignmentArr = placement.getJSONArray("assignmentInfo") Map assignmentMap = jsonUtil.entryArrayToMap(execution, assignmentArr.toString(), "variableName", "variableValue") resource.getHomingSolution().setCloudOwner(assignmentMap.get("cloudOwner")) resource.getHomingSolution().setAicClli(assignmentMap.get("aicClli")) resource.getHomingSolution().setAicVersion(assignmentMap.get("aicVersion")) if(inventoryType.equalsIgnoreCase("service")){ - resource.getHomingSolution().setVnfHostname(assignmentMap.get("vnfHostName")); - resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId")); + VnfResource vnf = new VnfResource() + vnf.setVnfHostname(assignmentMap.get("vnfHostName")) + resource.getHomingSolution().setVnf(vnf) + resource.getHomingSolution().setServiceInstanceId(placement.getString("serviceInstanceId")) } } } @@ -226,11 +225,11 @@ class Homing extends AbstractServiceTaskProcessor{ //match String jsonEntitlementPoolList = jsonUtil.getJsonValue(license.toString(), "entitlementPoolList") List entitlementPoolList = jsonUtil.StringArrayToList(execution, jsonEntitlementPoolList) - resource.getHomingSolution().setEntitlementPoolList(entitlementPoolList) + resource.getHomingSolution().getLicense().setEntitlementPoolList(entitlementPoolList) String jsonLicenseKeyGroupList = jsonUtil.getJsonValue(license.toString(), "licenseKeyGroupList") List licenseKeyGroupList = jsonUtil.StringArrayToList(execution, jsonLicenseKeyGroupList) - resource.getHomingSolution().setLicenseKeyGroupList(licenseKeyGroupList) + resource.getHomingSolution().getLicense().setLicenseKeyGroupList(licenseKeyGroupList) } } } @@ -254,7 +253,7 @@ class Homing extends AbstractServiceTaskProcessor{ * @param - execution * @author cb645j */ - public String logStart(Execution execution){ + public String logStart(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") String requestId = execution.getVariable("testReqId") if(isBlank(requestId)){ @@ -270,6 +269,6 @@ class Homing extends AbstractServiceTaskProcessor{ /** * Auto-generated method stub */ - public void preProcessRequest(Execution execution){} + public void preProcessRequest(DelegateExecution execution){} } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ManualHandling.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ManualHandling.groovy index 59a1bcf797..e79071f1e9 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ManualHandling.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ManualHandling.groovy @@ -23,6 +23,8 @@ import static org.apache.commons.lang3.StringUtils.*; import java.time.chrono.AbstractChronology import java.util.List +import java.text.SimpleDateFormat +import java.util.Date import org.apache.commons.lang3.* import org.camunda.bpm.engine.TaskService @@ -31,12 +33,13 @@ import org.camunda.bpm.engine.task.TaskQuery import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateTask import org.camunda.bpm.engine.delegate.DelegateExecution -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONObject; import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.client.ruby.* @@ -57,6 +60,7 @@ import org.openecomp.mso.bpmn.core.json.JsonUtils * @param - errorCode * @param - errorText * @param - validResponses + * @param - vnfName * * Outputs: * @param - WorkflowException @@ -70,13 +74,14 @@ public class ManualHandling extends AbstractServiceTaskProcessor { JsonUtils jsonUtils = new JsonUtils() - public void preProcessRequest (Execution execution) { + public void preProcessRequest (DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") String msg = "" utils.log("DEBUG"," ***** preProcessRequest of ManualHandling *****", isDebugLogEnabled) try { execution.setVariable("prefix", Prefix) + setBasicDBAuthHeader(execution, isDebugLogEnabled) // check for required input String requestId = execution.getVariable("msoRequestId") utils.log("DEBUG", "msoRequestId is: " + requestId, isDebugLogEnabled) @@ -109,7 +114,7 @@ public class ManualHandling extends AbstractServiceTaskProcessor { utils.log("DEBUG"," ***** Exit preProcessRequest of RainyDayHandler *****", isDebugLogEnabled) } - public void createManualTask (Execution execution) { + public void createManualTask (DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") String msg = "" utils.log("DEBUG"," ***** createManualTask of ManualHandling *****", isDebugLogEnabled) @@ -247,7 +252,94 @@ public class ManualHandling extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } utils.log("DEBUG"," ***** Exit completeTask of ManualHandling *****", isDebugLogEnabled) - } + } + + public void prepareRequestsDBStatusUpdate (DelegateExecution execution, String requestStatus){ + + def method = getClass().getSimpleName() + '.prepareRequestsDBStatusUpdate(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + utils.log("DEBUG"," ***** prepareRequestsDBStatusUpdate of ManualHandling *****", isDebugLogEnabled) + try { + def requestId = execution.getVariable("msoRequestId") + String payload = """ + + + + + ${requestId} + ManualHandling + ${requestStatus} + + + + """ + + execution.setVariable("setUpdateDBstatusPayload", payload) + utils.log("DEBUG", "Outgoing Update Mso Request Payload is: " + payload, isDebugLogEnabled) + utils.logAudit("setUpdateDBstatusPayload: " + payload) + + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) + } + + utils.log("DEBUG"," ***** Exit prepareRequestsDBStatusUpdate of ManualHandling *****", isDebugLogEnabled) + } + + public void createAOTSTicket (DelegateExecution execution) { + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + String msg = "" + utils.log("DEBUG"," ***** createAOTSTicket of ManualHandling *****", isDebugLogEnabled) + + // This method will not be throwing an exception, but rather log the error + + try { + execution.setVariable("prefix", Prefix) + setBasicDBAuthHeader(execution, isDebugLogEnabled) + // check for required input + String requestId = execution.getVariable("msoRequestId") + utils.log("DEBUG", "requestId is: " + requestId, isDebugLogEnabled) + def currentActivity = execution.getVariable("currentActivity") + utils.log("DEBUG", "currentActivity is: " + currentActivity, isDebugLogEnabled) + def workStep = execution.getVariable("workStep") + utils.log("DEBUG", "workStep is: " + workStep, isDebugLogEnabled) + def failedActivity = execution.getVariable("failedActivity") + utils.log("DEBUG", "failedActivity is: " + failedActivity, isDebugLogEnabled) + def errorCode = execution.getVariable("errorCode") + utils.log("DEBUG", "errorCode is: " + errorCode, isDebugLogEnabled) + def errorText = execution.getVariable("errorText") + utils.log("DEBUG", "errorText is: " + errorText, isDebugLogEnabled) + def vnfName = execution.getVariable("vnfName") + utils.log("DEBUG", "vnfName is: " + vnfName, isDebugLogEnabled) + + String rubyRequestId = UUID.randomUUID() + utils.log("DEBUG", "rubyRequestId: " + rubyRequestId, isDebugLogEnabled) + String sourceName = vnfName + utils.log("DEBUG", "sourceName: " + sourceName, isDebugLogEnabled) + String reason = "VID Workflow failed at " + failedActivity + " " + workStep + " call with error " + errorCode + utils.log("DEBUG", "reason: " + reason, isDebugLogEnabled) + String workflowId = requestId + utils.log("DEBUG", "workflowId: " + workflowId, isDebugLogEnabled) + String notification = "Request originated from VID | Workflow fallout on " + vnfName + " | Workflow step failure: " + workStep + " failed | VID workflow ID: " + workflowId + utils.log("DEBUG", "notification: " + notification, isDebugLogEnabled) + + utils.log("DEBUG", "Creating AOTS Ticket request") + + RubyClient rubyClient = new RubyClient() + rubyClient.rubyCreateTicketCheckRequest(rubyRequestId, sourceName, reason, workflowId, notification) + + } catch (BpmnError e) { + msg = "BPMN error in createAOTSTicket " + ex.getMessage() + utils.log("ERROR", msg, isDebugLogEnabled) + } catch (Exception ex){ + msg = "Exception in createAOTSTicket " + ex.getMessage() + utils.log("ERROR", msg, isDebugLogEnabled) + } + utils.log("DEBUG"," ***** Exit createAOTSTicket of ManualHandling *****", isDebugLogEnabled) + } + } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy index 3eaed1015e..f6b36546aa 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/NetworkUtils.groovy @@ -33,7 +33,7 @@ import javax.xml.transform.dom.DOMSource import javax.xml.transform.stream.StreamResult import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.w3c.dom.Document import org.w3c.dom.Element @@ -43,7 +43,7 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; import org.w3c.dom.Document import org.w3c.dom.Element @@ -1010,7 +1010,7 @@ class NetworkUtils { if (orchestrationStatus == "PendingDelete" || orchestrationStatus == "pending-delete") { // skip, do not include in processing, remove!!! } else { - def subnetList = ["subnet-id", "neutron-subnet-id", "gateway-address", "network-start-address", "cidr-mask", "ip-version", "orchestration-status", "dhcp-enabled", "dhcp-start", "dhcp-end", "resource-version", "subnet-name"] + def subnetList = ["subnet-id", "neutron-subnet-id", "gateway-address", "network-start-address", "cidr-mask", "ip-version", "orchestration-status", "dhcp-enabled", "dhcp-start", "dhcp-end", "resource-version", "subnet-name", "ip-assignment-direction", "host-routes"] rebuildingSubnets += buildSubNetworkElements(subnetXml, createNetworkResponse, subnetList, "subnet") } } @@ -1041,7 +1041,7 @@ class NetworkUtils { if (orchestrationStatus == "pending-delete" || orchestrationStatus == "PendingDelete") { // skip, do not include in processing, remove!!! } else { - def subnetList = ["dhcp-start", "dhcp-end", "network-start-address", "cidr-mask", "dhcp-enabled", "gateway-address", "ip-version", "subnet-id", "subnet-name"] + def subnetList = ["dhcp-start", "dhcp-end", "network-start-address", "cidr-mask", "dhcp-enabled", "gateway-address", "ip-version", "subnet-id", "subnet-name", "ip-assignment-direction", "host-routes"] rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "subnets") //rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "") } @@ -1084,7 +1084,14 @@ class NetworkUtils { if (element=="neutron-subnet-id") { // skip } else { - xmlBuild += "<"+element+">"+var.toString()+"" + if (element=="host-routes") { + if (subnetXml.contains("host-routes")) { + List elementRoute = ["host-route-id", "route-prefix", "next-hop", "next-hop-type", "resource-version"] + xmlBuild += buildXMLElements(subnetXml, "host-routes", "host-route", elementRoute) + } + } else { + xmlBuild += "<"+element+">"+var.toString()+"" + } } } } @@ -1150,6 +1157,17 @@ class NetworkUtils { if ((element == "subnet-name") && (var != null)) { xmlBuild += ""+var.toString()+"" } + if ((element == "ip-assignment-direction") && (var != null)) { + xmlBuild += ""+var.toString()+"" + } + if (element == "host-routes") { + def routes = "" + if (subnetXml.contains("host-routes")) { + routes = buildHostRoutes(subnetXml) + } + xmlBuild += routes + } + } } if (parentName != "") { @@ -1158,6 +1176,38 @@ class NetworkUtils { return xmlBuild } + // rebuild host-routes + def buildHostRoutes(subnetXml) { + List routeElementList = ["host-route-id", "route-prefix", "next-hop", "next-hop-type", "resource-version"] + def hostRoutes = buildXMLElements(subnetXml, "host-routes", "host-route", routeElementList) + def buildHostRoutes = "" + def var = "" + if (hostRoutes!=null) { + def routesData = new XmlSlurper().parseText(hostRoutes) + def routes = routesData.'**'.findAll {it.name() == "host-route"} + def routesSize = routes.size() + for (i in 0..routesSize-1) { + buildHostRoutes += "" + def route = routes[i] + def routeXml = XmlUtil.serialize(route) + List elementList = ["route-prefix", "next-hop"] + for (element in elementList) { + def xml= new XmlSlurper().parseText(routeXml) + var = xml.'**'.find {it.name() == element} + if (element == "route-prefix") { + buildHostRoutes += ""+var.toString()+"" + } + if (element == "next-hop") { + buildHostRoutes += ""+var.toString()+"" + } + } + buildHostRoutes += "" + } + } + return buildHostRoutes + + } + // rebuild ctag-assignments def rebuildCtagAssignments(xmlInput) { def rebuildingCtagAssignments = "" @@ -1470,7 +1520,7 @@ class NetworkUtils { return value } - public boolean isRollbackEnabled (Execution execution, String payloadXml) { + public boolean isRollbackEnabled (DelegateExecution execution, String payloadXml) { def rollbackEnabled = false def rollbackValueSet = false @@ -1499,17 +1549,24 @@ class NetworkUtils { /** * This method extracts the version for the the given ip-version. * - * @param String ipvVersion - IP protocols version (ex: ipv4 or ipv6) + * @param String ipvVersion - IP protocols version (ex: ipv4 or ipv6 or 4 or 6) * @return String version - digit version (ex: 4 or 6) */ public String getIpvVersion (String ipvVersion) { String version = "" - if (ipvVersion.isNumber()) { - version = ipvVersion - } else { - version = ipvVersion.substring(ipvVersion.indexOf("ipv")+3) + try { + if (ipvVersion.isNumber()) { + version = ipvVersion + } else { + version = ipvVersion.substring(ipvVersion.indexOf("ipv")+3) + if (!version.isNumber()) { + version = ipvVersion + } + } + } catch (Exception ex) { + version = ipvVersion } return version } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy index 95f129b7f5..bbdaab15e9 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy @@ -21,7 +21,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse import org.openecomp.mso.rest.RESTClient @@ -37,7 +37,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { * * @param execution The flow's execution instance. */ - public void initProcessVariables(Execution execution) { + public void initProcessVariables(DelegateExecution execution) { execution.setVariable('prefix', 'PUAAIVfMod_') execution.setVariable('PUAAIVfMod_vnfId', null) execution.setVariable('PUAAIVfMod_vfModuleId', null) @@ -58,7 +58,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { * * @param execution The flow's execution instance. */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def method = getClass().getSimpleName() + '.preProcessRequest(' + 'execution=' + execution.getId() + ')' @@ -96,7 +96,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { * * @param execution The flow's execution instance. */ - public void getGenericVnf(Execution execution) { + public void getGenericVnf(DelegateExecution execution) { def method = getClass().getSimpleName() + '.getGenericVnf(' + 'execution=' + execution.getId() + ')' @@ -162,7 +162,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { * * @param execution The flow's execution instance. */ - public void validateVfModule(Execution execution) { + public void validateVfModule(DelegateExecution execution) { def method = getClass().getSimpleName() + '.validateVfModule(' + 'execution=' + execution.getId() + ')' @@ -212,7 +212,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { * * @param execution The flow's execution instance. */ - public void updateVfModule(Execution execution) { + public void updateVfModule(DelegateExecution execution) { def method = getClass().getSimpleName() + '.updateVfModule(' + 'execution=' + execution.getId() + ')' @@ -309,7 +309,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { * * @param execution The flow's execution instance. */ - public void handleVnfNotFound(Execution execution) { + public void handleVnfNotFound(DelegateExecution execution) { def method = getClass().getSimpleName() + '.handleVnfNotFound(' + 'execution=' + execution.getId() + ')' @@ -332,7 +332,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { * * @param execution The flow's execution instance. */ - public void handleVfModuleValidationError(Execution execution) { + public void handleVfModuleValidationError(DelegateExecution execution) { def method = getClass().getSimpleName() + '.handleVfModuleValidationError(' + 'execution=' + execution.getId() + ')' @@ -355,7 +355,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase { * * @param execution The flow's execution instance. */ - public void handleUpdateVfModuleFailure(Execution execution) { + public void handleUpdateVfModuleFailure(DelegateExecution execution) { def method = getClass().getSimpleName() + '.handleUpdateVfModuleFailure(' + 'execution=' + execution.getId() + ')' diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/RainyDayHandler.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/RainyDayHandler.groovy index 8b4fe10649..0f7de9a23e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/RainyDayHandler.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/RainyDayHandler.groovy @@ -25,13 +25,17 @@ import static org.apache.commons.lang3.StringUtils.*; import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONObject; import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.client.policy.PolicyDecision +import org.openecomp.mso.client.policy.PolicyClient +import org.openecomp.mso.client.policy.PolicyClientImpl +import org.openecomp.mso.client.policy.entities.DictionaryData +import org.openecomp.mso.client.policy.entities.PolicyDecision +import org.openecomp.mso.client.policy.entities.Treatments import org.openecomp.mso.client.policy.PolicyRestClient @@ -54,6 +58,7 @@ import groovy.json.* * @param - failedActivity * @param - errorCode * @param - errorText + * @param - vnfName * * Outputs: * @param - WorkflowException @@ -67,7 +72,7 @@ public class RainyDayHandler extends AbstractServiceTaskProcessor { JsonUtils jsonUtils = new JsonUtils() - public void preProcessRequest (Execution execution) { + public void preProcessRequest (DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") String msg = "" utils.log("DEBUG"," ***** preProcessRequest of RainyDayHandler *****", isDebugLogEnabled) @@ -91,6 +96,9 @@ public class RainyDayHandler extends AbstractServiceTaskProcessor { utils.log("DEBUG", "errorCode is: " + errorCode, isDebugLogEnabled) def errorText = execution.getVariable("errorText") utils.log("DEBUG", "errorText is: " + errorText, isDebugLogEnabled) + String defaultPolicyDisposition = (String) execution.getVariable('URN_policy_default_disposition') + utils.log("DEBUG", "defaultPolicyDisposition is: " + defaultPolicyDisposition, isDebugLogEnabled) + execution.setVariable('defaultPolicyDisposition', defaultPolicyDisposition) } catch (BpmnError e) { throw e; @@ -102,7 +110,7 @@ public class RainyDayHandler extends AbstractServiceTaskProcessor { utils.log("DEBUG"," ***** Exit preProcessRequest of RainyDayHandler *****", isDebugLogEnabled) } - public void queryPolicy (Execution execution) { + public void queryPolicy (DelegateExecution execution) { def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") String msg = "" utils.log("DEBUG"," ***** queryPolicy of RainyDayHandler *****", isDebugLogEnabled) @@ -122,34 +130,55 @@ public class RainyDayHandler extends AbstractServiceTaskProcessor { utils.log("DEBUG", "Before querying policy", isDebugLogEnabled) - PolicyDecision decisionObject = null - - try { - PolicyRestClient policyClient = new PolicyRestClient() - utils.log("DEBUG", "Created policy client", isDebugLogEnabled) - decisionObject = policyClient.getDecision(serviceType, vnfType, bbId, workStep, errorCode) - utils.log("DEBUG", "Obtained decision object", isDebugLogEnabled) - } catch(Exception e) { - msg = "Exception in queryPolicy " + e.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - - } - String decision = 'DENY' - String disposition = "Abort" - if (decisionObject != null) { - decision = decisionObject.getDecision() - disposition = decisionObject.getDetails() - utils.log("DEBUG", "Obtained disposition from policy engine: " + disposition, isDebugLogEnabled) + String disposition = "Abort" + String defaultAllowedTreatments = "rollback, skip, manual, abort" + + String defaultPolicyDisposition = (String) execution.getVariable('defaultPolicyDisposition') + if (defaultPolicyDisposition != null) { + utils.log("DEBUG", "Setting disposition to the configured default instead of querying Policy: " + defaultPolicyDisposition, isDebugLogEnabled) + disposition = defaultPolicyDisposition + utils.log("DEBUG", "Setting default allowed treatments: " + defaultAllowedTreatments, isDebugLogEnabled) + execution.setVariable("validResponses", defaultAllowedTreatments) } else { - disposition = "Manual" - } - if (disposition == null) { - disposition = "Manual" + + PolicyDecision decisionObject = null + + try { + PolicyClient policyClient = new PolicyClientImpl() + utils.log("DEBUG", "Created policy client", isDebugLogEnabled) + decisionObject = policyClient.getDecision(serviceType, vnfType, bbId, workStep, errorCode) + utils.log("DEBUG", "Obtained decision object", isDebugLogEnabled) + DictionaryData dictClient = policyClient.getAllowedTreatments(bbId, workStep) + Treatments treatments = dictClient.getTreatments() + String validResponses = treatments.getString() + if (validResponses != null) { + validResponses = validResponses.toLowerCase() + } + utils.log("DEBUG", "Obtained validResponses: " + validResponses, isDebugLogEnabled) + execution.setVariable("validResponses", validResponses) + + } catch(Exception e) { + msg = "Exception in queryPolicy " + e.getMessage() + utils.log("DEBUG", msg, isDebugLogEnabled) + } + + + if (decisionObject != null) { + decision = decisionObject.getDecision() + disposition = decisionObject.getDetails() + utils.log("DEBUG", "Obtained disposition from policy engine: " + disposition, isDebugLogEnabled) + } + else { + disposition = "Abort" + } + if (disposition == null) { + disposition = "Abort" + } } - execution.setVariable("handlingCode", disposition) - execution.setVariable("validResponses", "rollback, abort, skip, retry") + execution.setVariable("handlingCode", disposition) + utils.log("DEBUG", "Disposition: "+ disposition, isDebugLogEnabled) } catch (BpmnError e) { diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ReceiveWorkflowMessage.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ReceiveWorkflowMessage.groovy index 6ad03abec6..1e1afb4d5d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ReceiveWorkflowMessage.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ReceiveWorkflowMessage.groovy @@ -1,10 +1,10 @@ -package org.openecomp.mso.bpmn.common.scripts +package org.openecomp.mso.bpmn.common.scripts; import groovy.json.* import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil @@ -18,7 +18,7 @@ class ReceiveWorkflowMessage extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ -public void preProcessRequest (Execution execution) { +public void preProcessRequest (DelegateExecution execution) { def method = getClass().getSimpleName() + '.preProcessRequest(' + 'execution=' + execution.getId() + ')' @@ -30,7 +30,7 @@ public void preProcessRequest (Execution execution) { setSuccessIndicator(execution, false) try { - + // Confirm that timeout value has been provided in 'RCVWFMSG_timeout'. def timeout = execution.getVariable('RCVWFMSG_timeout') logDebug('Timeout value is \'' + timeout + '\'', isDebugLogEnabled) @@ -40,7 +40,7 @@ public void preProcessRequest (Execution execution) { logError(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } - + // Confirm that message type has been provided in 'RCVWFMSG_messageType' def messageType = execution.getVariable('RCVWFMSG_messageType') logDebug('Message type is \'' + messageType + '\'', isDebugLogEnabled) @@ -50,7 +50,7 @@ public void preProcessRequest (Execution execution) { logError(msg) exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } - + // Confirm that correlator value has been provided in 'RCVWFMSG_correlator' def correlator = execution.getVariable('RCVWFMSG_correlator') logDebug('Correlator value is \'' + correlator + '\'', isDebugLogEnabled) @@ -61,7 +61,7 @@ public void preProcessRequest (Execution execution) { exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) } execution.setVariable(messageType + '_CORRELATOR', correlator) - + logDebug('Exited ' + method, isDebugLogEnabled) } catch (BpmnError e) { throw e @@ -78,7 +78,7 @@ public void preProcessRequest (Execution execution) { * * @param execution The flow's execution instance. */ - public void processReceivedMessage(Execution execution){ + public void processReceivedMessage(DelegateExecution execution){ def method = getClass().getSimpleName() + '.processReceivedMessage(' + 'execution=' + execution.getId() + ')' @@ -95,7 +95,7 @@ public void preProcessRequest (Execution execution) { // The received message is made available to the calling flow in WorkflowResponse execution.setVariable("WorkflowResponse", receivedMessage) - + setSuccessIndicator(execution, true) logDebug('Exited ' + method, isDebugLogEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy index 850a201503..44c9f3f829 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapter.groovy @@ -22,7 +22,7 @@ package org.openecomp.mso.bpmn.common.scripts; import java.text.SimpleDateFormat -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.core.WorkflowException @@ -34,10 +34,10 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() // Script Task: Process SDNC Workflow Request - // Params: Workflow Execution + // Params: Workflow DelegateExecution // Assume: Received SDNCAdapterWorkflowRequest is in variable 'sdncAdapterWorkflowRequest' // Put created SDNCAdapterRequest in variable 'sdncAdapterRequest' - public void preProcessRequest (Execution execution) { + public void preProcessRequest (DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") try{ @@ -155,7 +155,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { utils.log("DEBUG","=========== End pre Process SDNCRequestScript ===========", isDebugEnabled) } - public void postProcessResponse (Execution execution) { + public void postProcessResponse (DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") try{ @@ -224,7 +224,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { utils.log("DEBUG","=========== End POSTProcess SDNCAdapter ===========", isDebugEnabled) } - public void callbackResponsecheck(Execution execution){ + public void callbackResponsecheck(DelegateExecution execution){ def sdnccallbackreq=execution.getVariable("sdncAdapterCallbackRequest") utils.logAudit("sdncAdapterCallbackRequest :" + sdnccallbackreq) @@ -235,7 +235,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { } } - public void resetCallbackRequest(Execution execution) { + public void resetCallbackRequest(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") @@ -269,7 +269,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { } - public void prepareDBMessage(Execution execution) { + public void prepareDBMessage(DelegateExecution execution) { def isDebugEnabled=execution.getVariable("isDebugLogEnabled") @@ -302,13 +302,13 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { return utcTime; } - public void toggleSuccessIndicator(Execution execution){ + public void toggleSuccessIndicator(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") execution.setVariable("SDNCA_SuccessIndicator", true) utils.log("DEBUG","Setting SDNCA Success Indicator to True", isDebugEnabled) } - public void assignError(Execution execution){ + public void assignError(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("DEBUG","=========== Started Assign Error ===========", isDebugEnabled) WorkflowException wf = execution.getVariable("WorkflowException") @@ -322,7 +322,7 @@ public class SDNCAdapter extends AbstractServiceTaskProcessor { utils.log("DEBUG","=========== End Assign Error ===========", isDebugEnabled) } - public void setTimeout(Execution execution){ + public void setTimeout(DelegateExecution execution){ def isDebugEnabled=execution.getVariable("isDebugLogEnabled") utils.log("DEBUG","=========== Started SetTimeout ===========", isDebugEnabled) utils.log("DEBUG", "Timer expired, telling correlation service to stop listening", isDebugEnabled) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterRestV1.groovy index 1859838f29..41fcb6d08d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -6,7 +6,7 @@ import java.net.URLEncoder import org.apache.commons.codec.binary.Base64 import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import groovy.json.* @@ -27,7 +27,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { /** * Processes the incoming request. */ - public void preProcessRequest (Execution execution) { + public void preProcessRequest (DelegateExecution execution) { def method = getClass().getSimpleName() + '.preProcessRequest(' + 'execution=' + execution.getId() + ')' @@ -152,7 +152,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { /** * Sends the request to the SDNC adapter. */ - public void sendRequestToSDNCAdapter(Execution execution) { + public void sendRequestToSDNCAdapter(DelegateExecution execution) { def method = getClass().getSimpleName() + '.sendRequestToSDNCAdapter(' + 'execution=' + execution.getId() + ')' @@ -204,7 +204,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { /** * Processes a callback. */ - public void processCallback(Execution execution){ + public void processCallback(DelegateExecution execution){ def method = getClass().getSimpleName() + '.processCallback(' + 'execution=' + execution.getId() + ')' @@ -253,7 +253,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { * a WorkflowException. If the response cannot be parsed, a more generic * WorkflowException is created. */ - public void sdncAdapterBuildWorkflowException(Execution execution, String response) { + public void sdncAdapterBuildWorkflowException(DelegateExecution execution, String response) { try { String responseType = jsonUtil.getJsonRootProperty(response) String responseCode = jsonUtil.getJsonValue(response, responseType + ".responseCode") @@ -282,7 +282,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { /** * Gets the last callback request from the execution, or null if there was no callback. */ - public String getLastCallback(Execution execution) { + public String getLastCallback(DelegateExecution execution) { def method = getClass().getSimpleName() + '.getLastCallback(' + 'execution=' + execution.getId() + ')' @@ -318,7 +318,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { /** * Sets the timeout value to wait for the next notification. */ - public void setTimeoutValue(Execution execution) { + public void setTimeoutValue(DelegateExecution execution) { def method = getClass().getSimpleName() + '.setTimeoutValue(' + 'execution=' + execution.getId() + ')' diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterRestV2.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterRestV2.groovy new file mode 100644 index 0000000000..f4a7f055bd --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterRestV2.groovy @@ -0,0 +1,254 @@ +package org.openecomp.mso.bpmn.common.scripts + +import java.text.SimpleDateFormat +import java.net.URLEncoder + +import org.apache.commons.codec.binary.Base64 +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution + +import groovy.json.* + +import org.json.JSONObject + +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.rest.APIResponse +import org.openecomp.mso.rest.RESTClient +import org.openecomp.mso.rest.RESTConfig + +/** + * This version of SDNCAdapterRest allows for interim notifications to be sent for + * any non-final response received from SDNC. + */ +class SDNCAdapterRestV2 extends SDNCAdapterRestV1 { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + + /** + * Processes the incoming request. + */ + public void preProcessRequest (DelegateExecution execution) { + def method = getClass().getSimpleName() + '.preProcessRequest(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + def prefix="SDNCREST_" + execution.setVariable("prefix", prefix) + setSuccessIndicator(execution, false) + + try { + // Determine the request type and log the request + + String request = validateRequest(execution, "mso-request-id") + String requestType = jsonUtil.getJsonRootProperty(request) + execution.setVariable(prefix + 'requestType', requestType) + logDebug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType, isDebugLogEnabled) + utils.logAudit('SDNCAdapterRestV2, request: ' + request) + + // Determine the SDNCAdapter endpoint + + String sdncAdapterEndpoint = execution.getVariable("URN_mso_adapters_sdnc_rest_endpoint") + + if (sdncAdapterEndpoint == null || sdncAdapterEndpoint.isEmpty()) { + String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined' + logDebug(msg, isDebugLogEnabled) + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + while (sdncAdapterEndpoint.endsWith('/')) { + sdncAdapterEndpoint = sdncAdapterEndpoint.substring(0, sdncAdapterEndpoint.length()-1) + } + + String sdncAdapterMethod = null + String sdncAdapterUrl = null + String sdncAdapterRequest = request + + if ('SDNCServiceRequest'.equals(requestType)) { + // Get the sdncRequestId from the request + + String sdncRequestId = jsonUtil.getJsonValue(request, requestType + ".sdncRequestId") + + if (sdncRequestId == null || sdncRequestId.isEmpty()) { + String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType + logDebug(msg, isDebugLogEnabled) + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + execution.setVariable('SDNCAResponse_CORRELATOR', sdncRequestId) + logDebug(getProcessKey(execution) + ': SDNCAResponse_CORRELATOR = ' + sdncRequestId, isDebugLogEnabled) + + // Get the bpNotificationUrl from the request (just to make sure it's there) + + String bpNotificationUrl = jsonUtil.getJsonValue(request, requestType + ".bpNotificationUrl") + + if (bpNotificationUrl == null || bpNotificationUrl.isEmpty()) { + String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType + logDebug(msg, isDebugLogEnabled) + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + sdncAdapterMethod = 'POST' + sdncAdapterUrl = sdncAdapterEndpoint + '/services' + + } else { + String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType + logDebug(msg, isDebugLogEnabled) + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + + execution.setVariable(prefix + 'sdncAdapterMethod', sdncAdapterMethod) + logDebug(getProcessKey(execution) + ': ' + prefix + 'sdncAdapterMethod = ' + sdncAdapterMethod, isDebugLogEnabled) + execution.setVariable(prefix + 'sdncAdapterUrl', sdncAdapterUrl) + logDebug(getProcessKey(execution) + ': ' + prefix + 'sdncAdapterUrl = ' + sdncAdapterUrl, isDebugLogEnabled) + execution.setVariable(prefix + 'sdncAdapterRequest', sdncAdapterRequest) + logDebug(getProcessKey(execution) + ': ' + prefix + 'sdncAdapterRequest = \n' + sdncAdapterRequest, isDebugLogEnabled) + + // Get the Basic Auth credentials for the SDNCAdapter (yes... we ARE using the PO adapters credentials) + + String basicAuthValue = execution.getVariable("URN_mso_adapters_po_auth") + + if (basicAuthValue == null || basicAuthValue.isEmpty()) { + logDebug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", isDebugLogEnabled) + logError(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined") + } else { + logDebug(getProcessKey(execution) + ": Obtained BasicAuth credentials for SDNCAdapter:" + + basicAuthValue, isDebugLogEnabled) + try { + def encodedString = utils.getBasicAuth(basicAuthValue, execution.getVariable("URN_mso_msoKey")) + execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString) + } catch (IOException ex) { + logDebug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter", isDebugLogEnabled) + logError(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter") + } + } + + // Set the timeout value, e.g. PT5M. It may be specified in the request as the + // bpTimeout value. If it's not in the request, use the URN mapping value. + + String timeout = jsonUtil.getJsonValue(request, requestType + ".bpTimeout") + + if (timeout == null || timeout.isEmpty()) { + timeout = execution.getVariable("URN_mso_sdnc_timeout") + } + + execution.setVariable(prefix + 'timeout', timeout) + logDebug(getProcessKey(execution) + ': ' + prefix + 'timeout = ' + timeout, isDebugLogEnabled) + } catch (BpmnError e) { + throw e + } catch (Exception e) { + String msg = 'Caught exception in ' + method + ": " + e + logDebug(msg, isDebugLogEnabled) + logError(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + } + } + + /** + * Processes a callback. Check for possible interim notification. + */ + public void processCallback(DelegateExecution execution){ + def method = getClass().getSimpleName() + '.processCallback(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + String prefix = execution.getVariable('prefix') + String callback = execution.getVariable('SDNCAResponse_MESSAGE') + utils.logAudit("Incoming SDNC Rest Callback is: " + callback) + + try { + logDebug(getProcessKey(execution) + ": received callback:\n" + callback, isDebugLogEnabled) + + int callbackNumber = 1 + while (execution.getVariable(prefix + 'callback' + callbackNumber) != null) { + ++callbackNumber + } + + execution.setVariable(prefix + 'callback' + callbackNumber, callback) + execution.removeVariable('SDNCAResponse_MESSAGE') + + String responseType = jsonUtil.getJsonRootProperty(callback) + + // Get the ackFinalIndicator and make sure it's either Y or N. Default to Y. + String ackFinalIndicator = jsonUtil.getJsonValue(callback, responseType + ".ackFinalIndicator") + + if (!'N'.equals(ackFinalIndicator)) { + ackFinalIndicator = 'Y' + } + + execution.setVariable(prefix + "ackFinalIndicator", ackFinalIndicator) + + if (responseType.endsWith('Error')) { + sdncAdapterBuildWorkflowException(execution, callback) + } + + // Check for possible interim notification + execution.setVariable(prefix + "interimNotification", null) + execution.setVariable(prefix + "doInterimNotification", false) + if ('N'.equals(ackFinalIndicator)) { + def interimNotification = execution.getVariable(prefix + "InterimNotification" + callbackNumber) + if (interimNotification != null) { + execution.setVariable(prefix + "interimNotification", interimNotification) + execution.setVariable(prefix + "doInterimNotification", true) + } + } + + } catch (Exception e) { + callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback + String msg = "Received error from SDNCAdapter: " + callback + logDebug(getProcessKey(execution) + ': ' + msg, isDebugLogEnabled) + exceptionUtil.buildWorkflowException(execution, 5300, msg) + } + } + + /** + * Prepare to send an interim notification by extracting the variable/value definitions + * in the interimNotification JSON object and placing them in the execution. These + * variable/value definitions will be passed to the notification service. + */ + public void prepareInterimNotification(DelegateExecution execution) { + def method = getClass().getSimpleName() + '.prepareInterimNotification(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + String prefix = execution.getVariable('prefix') + utils.logAudit("Preparing Interim Notification") + + try { + def interimNotification = execution.getVariable(prefix + "interimNotification") + logDebug("Preparing Interim Notification:\n" + JsonUtils.prettyJson(interimNotification), isDebugLogEnabled) + + for (int i = 0; ; i++) { + def variable = JsonUtils.getJsonParamValue(interimNotification, 'variableList', 'variable', i) + + if (variable == null) { + break + } + + def String variableName = JsonUtils.getJsonValue(variable, "name") + if ((variableName != null) && !variableName.isEmpty()) { + def variableValue = JsonUtils.getJsonValue(variable, "value") + execution.setVariable(variableName, variableValue) + logDebug("Setting "+ variableName + "=" + variableValue, isDebugLogEnabled) + } + } + + } catch (Exception e) { + String msg = "Error preparing interim notification" + logDebug(getProcessKey(execution) + ': ' + msg, isDebugLogEnabled) + exceptionUtil.buildWorkflowException(execution, 5300, msg) + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy index 9de1708b5b..20a8210c50 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SDNCAdapterUtils.groovy @@ -22,9 +22,9 @@ package org.openecomp.mso.bpmn.common.scripts; import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils +import org.openecomp.mso.bpmn.core.json.JsonUtils; import org.springframework.web.util.UriUtils @@ -43,7 +43,7 @@ class SDNCAdapterUtils { this.taskProcessor = taskProcessor } - String SDNCAdapterFeatureRequest(Execution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) { + String SDNCAdapterFeatureRequest(DelegateExecution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) { def utils=new MsoUtils() def prefix = execution.getVariable('prefix') @@ -88,7 +88,7 @@ class SDNCAdapterUtils { return sdncAdapterFeatureRequest } - String SDNCAdapterActivateVnfRequest(Execution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) { + String SDNCAdapterActivateVnfRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) { def utils=new MsoUtils() def prefix = execution.getVariable('prefix') @@ -131,7 +131,7 @@ class SDNCAdapterUtils { return sdncAdapterActivateVnfRequest } - String SDNCAdapterL3ToHigherLayerRequest(Execution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) { + String SDNCAdapterL3ToHigherLayerRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) { def utils=new MsoUtils() def prefix = execution.getVariable('prefix') @@ -230,7 +230,7 @@ class SDNCAdapterUtils { - private void SDNCAdapterActivateRequest(Execution execution, String resultVar, String svcAction, + private void SDNCAdapterActivateRequest(DelegateExecution execution, String resultVar, String svcAction, String svcOperation, String additionalData) { def utils=new MsoUtils() @@ -273,6 +273,15 @@ class SDNCAdapterUtils { additionalData = "" } + boolean isAic3 = execution.getVariable("isAic3") + + if(isAic3) { + nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0") + } + else { + nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X") + } + String content = """ @@ -301,14 +310,27 @@ class SDNCAdapterUtils { execution.setVariable(resultVar, content) } + /** + * Builds an SDNC "reserve" request and stores it in the specified execution + * variable. + * @param execution the execution + * @param action the type of action: reserve, turnup, etc + * @param resultVar the execution variable in which the result will be stored + */ + public void sdncReservePrep(DelegateExecution execution, String action, String resultVar) { + sdncReservePrep(execution, action, resultVar, false) + } + /** * Builds an SDNC "reserve" request and stores it in the specified execution * variable. * @param execution the execution + * @param action the type of action: reserve, turnup, etc * @param resultVar the execution variable in which the result will be stored + * @param isAic3 boolean to indicate whether request is for AIC3.0 */ - public void sdncReservePrep(Execution execution, String action, String resultVar) { - sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, this.taskProcessor) + public void sdncReservePrep(DelegateExecution execution, String action, String resultVar, boolean isAic3) { + sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, isAic3, this.taskProcessor) } /** @@ -320,8 +342,22 @@ class SDNCAdapterUtils { * @param additionalData additional XML content to be inserted into the * RequestData element (may be null) */ - public void sdncPrep(Execution execution, String resultVar, String svcAction, - String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) { + public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction, + String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) { + sdncPrep(execution, resultVar, svcAction, svcOperation, additionalData, false, taskProcessor) + } + + /** + * Builds a basic SDNC request and stores it in the specified execution variable. + * @param execution the execution + * @param resultVar the execution variable in which the result will be stored + * @param svcAction the svcAction element value + * @param svcOperation the svcOperation element value + * @param additionalData additional XML content to be inserted into the RequestData element (may be null) + * @param isAic3 boolean to indicate whether request is for AIC3.0 + */ + public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction, + String svcOperation, String additionalData, boolean isAic3, AbstractServiceTaskProcessor taskProcessor) { def method = getClass().getSimpleName() + '.sdncPrep(' + 'execution=' + execution.getId() + ', resultVar=' + resultVar + @@ -382,6 +418,14 @@ class SDNCAdapterUtils { if (additionalData == null) { additionalData = "" } + + if(isAic3) { + nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0") + } + else { + nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X") + } + String content = """ " + } + else { + newHomingInfo = homingInfo.substring(0, homingInfo.indexOf("")) + "" + aicVersion + "" + } + } + /** * Builds a topology SDNC request and return String request. * As V2 will use 1607-style request, region instead of aic clli code @@ -435,7 +489,7 @@ class SDNCAdapterUtils { * @param additionalData additional XML content to be inserted into the * RequestData element (may be null) */ - public String sdncTopologyRequestV2 (Execution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String queryAAIResponse, String additionalData) { + public String sdncTopologyRequestV2 (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String queryAAIResponse, String additionalData) { def utils=new MsoUtils() // SNDC is expecting request Id for header as unique each call. @@ -553,7 +607,7 @@ class SDNCAdapterUtils { * @param additionalData additional XML content to be inserted into the * RequestData element (may be null) */ - public String sdncTopologyRequestRsrc (Execution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) { + public String sdncTopologyRequestRsrc (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) { def utils=new MsoUtils() // SNDC is expecting request Id for header as unique each call. @@ -675,12 +729,12 @@ class SDNCAdapterUtils { ${serviceId} ${subscriptionServiceType} - + ${serviceModelInvariantUuid} ${serviceModelUuid} ${serviceModelVersion} ${serviceModelName} - + ${serviceInstanceId} ${globalCustomerId} ${subscriberName} @@ -688,13 +742,13 @@ class SDNCAdapterUtils { ${networkId} ${networkType} - + ${modelInvariantUuid} ${modelCustomizationUuid} ${modelUuid} ${modelVersion} ${modelName} - + ${networkName} @@ -715,7 +769,7 @@ class SDNCAdapterUtils { * @param responseVar the execution variable in which the response is stored * @param workflowException the WorkflowException Object returned from sdnc call */ - public void validateSDNCResponse(Execution execution, String response, WorkflowException workflowException, boolean successIndicator){ + public void validateSDNCResponse(DelegateExecution execution, String response, WorkflowException workflowException, boolean successIndicator){ def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') taskProcessor.utils.log("DEBUG", "SDNC Response is: " + response, isDebugLogEnabled) taskProcessor.utils.log("DEBUG", "SuccessIndicator is: " + successIndicator, isDebugLogEnabled) @@ -730,8 +784,13 @@ class SDNCAdapterUtils { taskProcessor.utils.log("DEBUG", response + ' is empty'); exceptionUtil.buildAndThrowWorkflowException(execution, 500, "SDNCAdapter Workflow Response is Empty") }else{ + // we need to peer into the request data for error - def String decodedXml = taskProcessor.utils.getNodeText1(response, "RequestData") + def String sdncAdapterWorkflowResponse = taskProcessor.utils.getNodeXml(response, 'response-data', false) + def String decodedXml = decodeXML(sdncAdapterWorkflowResponse).replace('', "") + + // change '&' to "& (if present as data, ex: subscriber-name = 'FOUR SEASONS HEATING & COOLING_8310006378683' + decodedXml = decodedXml.replace("&", "&") taskProcessor.utils.log("DEBUG","decodedXml:\n" + decodedXml, isDebugLogEnabled) @@ -740,14 +799,12 @@ class SDNCAdapterUtils { try{ if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) { - requestDataResponseMessage = taskProcessor.utils.getNodeText1(decodedXml, "response-message") - - // note: ResponseMessage appears within "response", not "decodedXml" - } else if (taskProcessor.utils.nodeExists(response, "ResponseMessage")) { - requestDataResponseMessage = taskProcessor.utils.getNodeText1(response, "ResponseMessage") + requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message") + } else if (taskProcessor.utils.nodeExists(decodedXml, "ResponseMessage")) { + requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "ResponseMessage") } }catch(Exception e){ - taskProcessor.utils.log("DEBUG", 'Error caught while decoding response ' + e.getMessage(), isDebugLogEnabled) + taskProcessor.utils.log("DEBUG", 'Error caught while decoding resposne ' + e.getMessage(), isDebugLogEnabled) } if(taskProcessor.utils.nodeExists(decodedXml, "response-code")) { @@ -758,20 +815,18 @@ class SDNCAdapterUtils { taskProcessor.utils.log("DEBUG","response-code node is empty", isDebugLogEnabled) requestDataResponseCode = 0 }else{ - requestDataResponseCode = code as Integer + requestDataResponseCode = code.toInteger() taskProcessor.utils.log("DEBUG","response-code is: " + requestDataResponseCode, isDebugLogEnabled) } - - // note: ResponseCode appears within "response", not "decodedXml" - }else if(taskProcessor.utils.nodeExists(response, "ResponseCode")){ + }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){ taskProcessor.utils.log("DEBUG","ResponseCode node Exist ", isDebugLogEnabled) - String code = taskProcessor.utils.getNodeText1(response, "ResponseCode") + String code = taskProcessor.utils.getNodeText1(decodedXml, "ResponseCode") if(code.isEmpty() || code.equals("")){ // if ResponseCode blank then Success taskProcessor.utils.log("DEBUG","ResponseCode node is empty", isDebugLogEnabled) requestDataResponseCode = 0 }else{ - requestDataResponseCode = code as Integer + requestDataResponseCode = code.toInteger() taskProcessor.utils.log("DEBUG","ResponseCode is: " + requestDataResponseCode, isDebugLogEnabled) } }else{ @@ -828,7 +883,7 @@ class SDNCAdapterUtils { * @param responseCodeVar the execution variable in which the response code is stored * @param errorResponseVar the execution variable in which the error response is stored */ - public void validateL3BondingSDNCResp(Execution execution, String response, WorkflowException workflowException, boolean success) { + public void validateL3BondingSDNCResp(DelegateExecution execution, String response, WorkflowException workflowException, boolean success) { def method = getClass().getSimpleName() + '.validateL3BondingSDNCResp(' + 'execution=' + execution.getId() + ', response=' + response + @@ -951,13 +1006,13 @@ class SDNCAdapterUtils { } String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName") String ecompModelInformation = - """ + """ ${modelInvariantUuid} ${modelUuid} ${modelCustomizationString} ${modelVersion} ${modelName} - """ + """ return ecompModelInformation } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy index aba2b783e5..ab215c9949 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/SNIROUtils.groovy @@ -1,6 +1,27 @@ +/*- + * ============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.bpmn.common.scripts -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.json.JSONArray import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.common.scripts.MsoUtils @@ -38,7 +59,7 @@ class SNIROUtils{ * * @author cb645j */ - public String buildRequest(Execution execution, String requestId, ServiceDecomposition decomposition, Subscriber subscriber, String homingParams){ + public String buildRequest(DelegateExecution execution, String requestId, ServiceDecomposition decomposition, Subscriber subscriber, String homingParams){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", "Started Building Sniro Request", isDebugEnabled) def callbackUrl = utils.createWorkflowMessageAdapterCallbackURL(execution, "SNIROResponse", requestId) @@ -70,6 +91,25 @@ class SNIROUtils{ orderInfo = StringUtils.normalizeSpace(orderInfo) } + //Determine RequestType + //TODO Figure out better way to determine this + String requestType = "initial" + List resources = decomposition.getServiceResources() + for(Resource r:resources){ + HomingSolution currentSolution = r.getCurrentHomingSolution() + if(currentSolution != null){ + requestType = "speed changed" + } + } + + int timeoutSeconds = 1800 + String timeout = execution.getVariable("timeout") + if(isNotBlank(timeout)){ + String subT = timeout.substring(2, timeout.length() - 1) + int timeoutInt = Integer.parseInt(subT) + timeoutSeconds = timeoutInt * 60 + } + //Demands String placementDemands = "" StringBuilder sb = new StringBuilder() @@ -81,7 +121,7 @@ class SNIROUtils{ utils.log("DEBUG", "Allotted Resources List is empty - will try to get service VNFs instead.", isDebugEnabled) resourceList = decomposition.getServiceVnfs() } - + if(resourceList.isEmpty() || resourceList == null){ utils.log("DEBUG", "Resources List is Empty", isDebugEnabled) }else{ @@ -99,7 +139,19 @@ class SNIROUtils{ def resouceModelType = resourceModelInfo.getModelType() def tenantId = "" //Optional def tenantName = "" //Optional - + + + String existingPlacement = "" + HomingSolution currentPlacement = resource.getCurrentHomingSolution() + if(currentPlacement != null){ + String homedServiceInstanceId = currentPlacement.getServiceInstanceId() + existingPlacement = + ""","existingPlacement": { + "serviceInstanceId": "${homedServiceInstanceId}" + }""" + } + + String demand = """{ "resourceInstanceType": "${resourceInstanceType}", @@ -115,8 +167,9 @@ class SNIROUtils{ }, "tenantId": "${tenantId}", "tenantName": "${tenantName}" + ${existingPlacement} },""" - + placementDemands = sb.append(demand) } placementDemands = placementDemands.substring(0, placementDemands.length() - 1); @@ -126,7 +179,7 @@ class SNIROUtils{ sb = new StringBuilder() if(vnfResourceList.isEmpty() || vnfResourceList == null){ utils.log("DEBUG", "Vnf Resources List is Empty", isDebugEnabled) - }else{ + }else{ for(VnfResource vnfResource:vnfResourceList){ ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo() ResourceInstance vnfResourceInstance = vnfResource.getResourceInstance() @@ -139,7 +192,24 @@ class SNIROUtils{ def resouceModelVersion = vnfResourceModelInfo.getModelVersion() def resouceModelVersionId = vnfResourceModelInfo.getModelUuid() def resouceModelType = vnfResourceModelInfo.getModelType() - + + String curentLicenseJson = "" + HomingSolution currentSol = vnfResource.getCurrentHomingSolution() + if(currentSol != null){ + JSONArray entitlementPoolList = currentSol.getLicense().getEntitlementPoolListAsString() + JSONArray licenseKeyGroupList = currentSol.getLicense().getLicenseKeyGroupListAsString() + curentLicenseJson = + """ ,"existingLicense": [ + { + "entitlementPoolUUID": + ${entitlementPoolList}, + "licenseKeyGroupUUID": + ${licenseKeyGroupList} + + } + ]""" + } + String demand = """{ "resourceInstanceType": "${resourceInstanceType}", @@ -153,13 +223,14 @@ class SNIROUtils{ "modelVersionId": "${resouceModelVersionId}", "modelType": "${resouceModelType}" } + ${curentLicenseJson} },""" - + licenseDemands = sb.append(demand) } licenseDemands = licenseDemands.substring(0, licenseDemands.length() - 1); } - + String request = """{ "requestInfo": { @@ -167,12 +238,13 @@ class SNIROUtils{ "requestId": "${requestId}", "callbackUrl": "${callbackUrl}", "sourceId": "mso", + "requestType": "${requestType}", "optimizer": [ "placement", "license" ], "numSolutions": 1, - "timeout": 600 + "timeout": ${timeoutSeconds} }, "placementInfo": { "serviceModelInfo": { @@ -216,14 +288,14 @@ class SNIROUtils{ * * @author cb645j */ - public void validateCallbackResponse(Execution execution, String response){ + public void validateCallbackResponse(DelegateExecution execution, String response){ def isDebugEnabled = execution.getVariable("isDebugLogEnabled") String placements = "" if(isBlank(response)){ exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Sniro Async Callback Response is Empty") }else{ - if(JsonUtils.jsonElementExist(response, "solutionInfo.placement")){ - placements = jsonUtil.getJsonValue(response, "solutionInfo.placement") + if(JsonUtils.jsonElementExist(response, "solutionInfo.placementInfo")){ + placements = jsonUtil.getJsonValue(response, "solutionInfo.placementInfo") if(isBlank(placements) || placements.equalsIgnoreCase("[]")){ String statusMessage = jsonUtil.getJsonValue(response, "statusMessage") if(isBlank(statusMessage)){ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ServiceTaskProcessor.groovy index d127bd0d62..0b5d013fe0 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/ServiceTaskProcessor.groovy @@ -20,7 +20,8 @@ package org.openecomp.mso.bpmn.common.scripts; -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.camunda.bpm.engine.delegate.DelegateExecution /** @@ -28,5 +29,5 @@ import org.camunda.bpm.engine.runtime.Execution * */ public interface ServiceTaskProcessor { - public void preProcessRequest(Execution execution); + public void preProcessRequest(DelegateExecution execution); } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/TrinityExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/TrinityExceptionUtil.groovy index db1cc1ddc3..e75b115b63 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/TrinityExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/TrinityExceptionUtil.groovy @@ -20,7 +20,7 @@ package org.openecomp.mso.bpmn.common.scripts -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.apache.commons.lang3.* class TrinityExceptionUtil { @@ -60,7 +60,7 @@ class TrinityExceptionUtil { - String mapAdapterExecptionToCommonException(String response, Execution execution) + String mapAdapterExecptionToCommonException(String response, DelegateExecution execution) { def utils=new MsoUtils() def method = getClass().getSimpleName() + '.mapAdapterExecptionToCommonException(' + @@ -93,7 +93,7 @@ class TrinityExceptionUtil { * @param execution * @return mapped exception */ - String mapAOTSExecptionToCommonException(String response, Execution execution) + String mapAOTSExecptionToCommonException(String response, DelegateExecution execution) { def utils=new MsoUtils() @@ -128,7 +128,7 @@ class TrinityExceptionUtil { } } - String mapSDNCAdapterExceptionToErrorResponse(String sdncAdapterCallbackRequest, Execution execution) { + String mapSDNCAdapterExceptionToErrorResponse(String sdncAdapterCallbackRequest, DelegateExecution execution) { def utils=new MsoUtils() def prefix=execution.getVariable("prefix") def method = getClass().getSimpleName() + '.mapSDNCAdapterExceptionToErrorResponse(' + @@ -182,7 +182,7 @@ class TrinityExceptionUtil { * @param execution * @return an error response conforming to the common */ - String mapAAIExceptionTCommonException(String response, Execution execution) + String mapAAIExceptionTCommonException(String response, DelegateExecution execution) { def utils=new MsoUtils() def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") @@ -315,7 +315,7 @@ class TrinityExceptionUtil { } - String parseError(Execution execution){ + String parseError(DelegateExecution execution){ def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') def utils=new MsoUtils() def prefix=execution.getVariable("prefix") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy index f137d8d00a..84d9ffdb6b 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIGenericVnf.groovy @@ -21,7 +21,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse import org.springframework.web.util.UriUtils @@ -37,7 +37,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void initProcessVariables(Execution execution) { + public void initProcessVariables(DelegateExecution execution) { execution.setVariable('prefix', 'UAAIGenVnf_') execution.setVariable('UAAIGenVnf_vnfId', null) execution.setVariable('UAAIGenVnf_personaModelId', null) @@ -56,7 +56,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def method = getClass().getSimpleName() + '.preProcessRequest(' + 'execution=' + execution.getId() + ')' @@ -112,7 +112,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void getGenericVnf(Execution execution) { + public void getGenericVnf(DelegateExecution execution) { def method = getClass().getSimpleName() + '.getGenericVnf(' + 'execution=' + execution.getId() + ')' @@ -159,7 +159,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void updateGenericVnf(Execution execution) { + public void updateGenericVnf(DelegateExecution execution) { def method = getClass().getSimpleName() + '.updateGenericVnf(' + 'execution=' + execution.getId() + ')' @@ -301,7 +301,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void handleAAIQueryFailure(Execution execution) { + public void handleAAIQueryFailure(DelegateExecution execution) { def method = getClass().getSimpleName() + '.handleAAIQueryFailure(' + 'execution=' + execution.getId() + ')' @@ -325,7 +325,7 @@ public class UpdateAAIGenericVnf extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void handleUpdateGenericVnfFailure(Execution execution) { + public void handleUpdateGenericVnfFailure(DelegateExecution execution) { def method = getClass().getSimpleName() + '.handleUpdateGenericVnfFailure(' + 'execution=' + execution.getId() + ')' diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy index c16f0faf74..b3a9423727 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/UpdateAAIVfModule.groovy @@ -21,7 +21,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.rest.APIResponse import org.springframework.web.util.UriUtils @@ -37,7 +37,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void initProcessVariables(Execution execution) { + public void initProcessVariables(DelegateExecution execution) { execution.setVariable('prefix', 'UAAIVfMod_') execution.setVariable('UAAIVfMod_vnfId', null) execution.setVariable('UAAIVfMod_vfModuleId', null) @@ -55,7 +55,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void preProcessRequest(Execution execution) { + public void preProcessRequest(DelegateExecution execution) { def method = getClass().getSimpleName() + '.preProcessRequest(' + 'execution=' + execution.getId() + ')' @@ -89,7 +89,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void getVfModule(Execution execution) { + public void getVfModule(DelegateExecution execution) { def method = getClass().getSimpleName() + '.getVfModule(' + 'execution=' + execution.getId() + ')' @@ -137,7 +137,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void updateVfModule(Execution execution) { + public void updateVfModule(DelegateExecution execution) { def method = getClass().getSimpleName() + '.updateVfModule(' + 'execution=' + execution.getId() + ')' @@ -338,7 +338,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void handleAAIQueryFailure(Execution execution) { + public void handleAAIQueryFailure(DelegateExecution execution) { def method = getClass().getSimpleName() + '.handleAAIQueryFailure(' + 'execution=' + execution.getId() + ')' @@ -361,7 +361,7 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor { * * @param execution The flow's execution instance. */ - public void handleUpdateVfModuleFailure(Execution execution) { + public void handleUpdateVfModuleFailure(DelegateExecution execution) { def method = getClass().getSimpleName() + '.handleUpdateVfModuleFailure(' + 'execution=' + execution.getId() + ')' diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy index 473b71120b..e0b9c3020c 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VfModuleBase.groovy @@ -20,13 +20,14 @@ package org.openecomp.mso.bpmn.common.scripts; +import java.io.ObjectInputStream.BlockDataInputStream + //import groovy.util.Node; import javax.xml.parsers.DocumentBuilder import javax.xml.parsers.DocumentBuilderFactory import org.apache.commons.lang3.* -import org.camunda.bpm.engine.runtime.Execution import org.w3c.dom.Document import org.w3c.dom.Element import org.w3c.dom.Node @@ -234,245 +235,274 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { protected String buildVfModuleParams(Map vnfParamsMap, String sdncGetResponse, String vnfId, String vnfName, - String vfModuleId, String vfModuleName, String vfModuleIndex) { - - //Get SDNC Response Data - - String data = utils.getNodeXml(sdncGetResponse, "response-data") - data = data.replaceAll("<", "<") - data = data.replaceAll(">", ">") + String vfModuleId, String vfModuleName, String vfModuleIndex, String environmentContext, String workloadContext) { + + //Get SDNC Response Data + + String data = utils.getNodeXml(sdncGetResponse, "response-data") + data = data.replaceAll("<", "<") + data = data.replaceAll(">", ">") - String serviceData = utils.getNodeXml(data, "service-data") - serviceData = utils.removeXmlPreamble(serviceData) - serviceData = utils.removeXmlNamespaces(serviceData) - String vnfRequestInfo = utils.getNodeXml(serviceData, "vnf-request-information") - String oldVnfId = utils.getNodeXml(vnfRequestInfo, "vnf-id") - oldVnfId = utils.removeXmlPreamble(oldVnfId) - oldVnfId = utils.removeXmlNamespaces(oldVnfId) - serviceData = serviceData.replace(oldVnfId, "") - def vnfId1 = utils.getNodeText1(serviceData, "vnf-id") - - Map paramsMap = new HashMap() - - if (vfModuleIndex != null) { - paramsMap.put("vf_module_index", "${vfModuleIndex}") - } + String serviceData = utils.getNodeXml(data, "service-data") + serviceData = utils.removeXmlPreamble(serviceData) + serviceData = utils.removeXmlNamespaces(serviceData) + String vnfRequestInfo = utils.getNodeXml(serviceData, "vnf-request-information") + String oldVnfId = utils.getNodeXml(vnfRequestInfo, "vnf-id") + oldVnfId = utils.removeXmlPreamble(oldVnfId) + oldVnfId = utils.removeXmlNamespaces(oldVnfId) + serviceData = serviceData.replace(oldVnfId, "") + def vnfId1 = utils.getNodeText1(serviceData, "vnf-id") + + Map paramsMap = new HashMap() + + if (vfModuleIndex != null) { + paramsMap.put("vf_module_index", "${vfModuleIndex}") + } - // Add-on data - paramsMap.put("vnf_id", "${vnfId}") - paramsMap.put("vnf_name", "${vnfName}") - paramsMap.put("vf_module_id", "${vfModuleId}") - paramsMap.put("vf_module_name", "${vfModuleName}") - - InputSource source = new InputSource(new StringReader(data)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setNamespaceAware(true) - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document responseXml = docBuilder.parse(source) + // Add-on data + paramsMap.put("vnf_id", "${vnfId}") + paramsMap.put("vnf_name", "${vnfName}") + paramsMap.put("vf_module_id", "${vfModuleId}") + paramsMap.put("vf_module_name", "${vfModuleName}") + paramsMap.put("environment_context", "${environmentContext}") + paramsMap.put("workload_context", "${workloadContext}") + + InputSource source = new InputSource(new StringReader(data)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + docFactory.setNamespaceAware(true) + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document responseXml = docBuilder.parse(source) - // Availability Zones Data - - NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones") - String aZonePosition = "0" - for (int z = 0; z < aZonesList.getLength(); z++) { - Node node = aZonesList.item(z) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String aZoneValue = utils.getElementText(eElement, "availability-zone") - aZonePosition = z.toString() - paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}") + // Availability Zones Data + + NodeList aZonesList = responseXml.getElementsByTagNameNS("*", "availability-zones") + String aZonePosition = "0" + for (int z = 0; z < aZonesList.getLength(); z++) { + Node node = aZonesList.item(z) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String aZoneValue = utils.getElementText(eElement, "availability-zone") + aZonePosition = z.toString() + paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}") + } + } + + // Map of network-roles and network-tags from vm-networks + + NodeList vmNetworksListGlobal = responseXml.getElementsByTagNameNS("*", "vm-networks") + Map networkRoleMap = new HashMap() + for(int n = 0; n < vmNetworksListGlobal.getLength(); n++){ + Node nodeNetworkKey = vmNetworksListGlobal.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String networkRole = utils.getElementText(eElementNetworkKey, "network-role") + String networkRoleValue = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkRoleValue.isEmpty()) { + networkRoleValue = networkRole } + networkRoleMap.put(networkRole, networkRoleValue) } + } - // VNF Networks Data - - StringBuilder sbNet = new StringBuilder() - - NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks") - for (int x = 0; x < vnfNetworkList.getLength(); x++) { - Node node = vnfNetworkList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String vnfNetworkKey = utils.getElementText(eElement, "network-role") - String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") - String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") - String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") - String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") - String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") - paramsMap.put("${vnfNetworkKey}_net_id", "${vnfNetworkNeutronIdValue}") - paramsMap.put("${vnfNetworkKey}_net_name", "${vnfNetworkNetNameValue}") - paramsMap.put("${vnfNetworkKey}_subnet_id", "${vnfNetworkSubNetIdValue}") - paramsMap.put("${vnfNetworkKey}_v6_subnet_id", "${vnfNetworkV6SubNetIdValue}") - paramsMap.put("${vnfNetworkKey}_net_fqdn", "${vnfNetworkNetFqdnValue}") - - NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") - StringBuffer sriovFilterBuf = new StringBuffer() - String values = "" - for(int i = 0; i < sriovVlanFilterList.getLength(); i++){ - Node node1 = sriovVlanFilterList.item(i) - if (node1.getNodeType() == Node.ELEMENT_NODE) { - Element eElement1 = (Element) node1 - String value = utils.getElementText(eElement1, "sriov-vlan-filter") - if (i != sriovVlanFilterList.getLength() - 1) { - values = sriovFilterBuf.append(value + ",") - } - else { - values = sriovFilterBuf.append(value); - } + // VNF Networks Data + + StringBuilder sbNet = new StringBuilder() + + NodeList vnfNetworkList = responseXml.getElementsByTagNameNS("*", "vnf-networks") + for (int x = 0; x < vnfNetworkList.getLength(); x++) { + Node node = vnfNetworkList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + String vnfNetworkKey = utils.getElementText(eElement, "network-role-tag") + String networkRole = utils.getElementText(eElement, "network-role") + if (vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRoleMap.get(networkRole) + if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRole + } + } + String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") + String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") + String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") + String vnfNetworkV6SubNetIdValue = utils.getElementText(eElement, "ipv6-subnet-id") + String vnfNetworkNetFqdnValue = utils.getElementText(eElement, "contrail-network-fqdn") + paramsMap.put("${vnfNetworkKey}_net_id", "${vnfNetworkNeutronIdValue}") + paramsMap.put("${vnfNetworkKey}_net_name", "${vnfNetworkNetNameValue}") + paramsMap.put("${vnfNetworkKey}_subnet_id", "${vnfNetworkSubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_v6_subnet_id", "${vnfNetworkV6SubNetIdValue}") + paramsMap.put("${vnfNetworkKey}_net_fqdn", "${vnfNetworkNetFqdnValue}") + + NodeList sriovVlanFilterList = eElement.getElementsByTagNameNS("*","sriov-vlan-filter-list") + StringBuffer sriovFilterBuf = new StringBuffer() + String values = "" + for(int i = 0; i < sriovVlanFilterList.getLength(); i++){ + Node node1 = sriovVlanFilterList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + String value = utils.getElementText(eElement1, "sriov-vlan-filter") + if (i != sriovVlanFilterList.getLength() - 1) { + values = sriovFilterBuf.append(value + ",") } - } - if (!values.isEmpty()) { - paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}") + else { + values = sriovFilterBuf.append(value); } } - } + } + if (!values.isEmpty()) { + paramsMap.put("${vnfNetworkKey}_ATT_VF_VLAN_FILTER", "${values}") + } + } + } - // VNF-VMS Data - - def key - def value - def networkKey - def networkValue - def floatingIPKey - def floatingIPKeyValue - def floatingIPV6Key - def floatingIPV6KeyValue - StringBuilder sb = new StringBuilder() + // VNF-VMS Data + + def key + def value + def networkKey + def networkValue + def floatingIPKey + def floatingIPKeyValue + def floatingIPV6Key + def floatingIPV6KeyValue + StringBuilder sb = new StringBuilder() - NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms") - for (int x = 0; x < vmsList.getLength(); x++) { - Node node = vmsList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - key = utils.getElementText(eElement, "vm-type") - String values - String position = "0" - StringBuilder sb1 = new StringBuilder() - NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names") - NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks") - for(int i = 0; i < valueList.getLength(); i++){ - Node node1 = valueList.item(i) - if (node1.getNodeType() == Node.ELEMENT_NODE) { - Element eElement1 = (Element) node1 - value = utils.getElementText(eElement1, "vm-name") - if (i != valueList.getLength() - 1) { - values = sb1.append(value + ",") - } - else { - values = sb1.append(value); - } - position = i.toString() - paramsMap.put("${key}_name_${position}", "${value}") + NodeList vmsList = responseXml.getElementsByTagNameNS("*","vnf-vms") + for (int x = 0; x < vmsList.getLength(); x++) { + Node node = vmsList.item(x) + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element eElement = (Element) node + key = utils.getElementText(eElement, "vm-type") + String values + String position = "0" + StringBuilder sb1 = new StringBuilder() + NodeList valueList = eElement.getElementsByTagNameNS("*","vm-names") + NodeList vmNetworksList = eElement.getElementsByTagNameNS("*","vm-networks") + for(int i = 0; i < valueList.getLength(); i++){ + Node node1 = valueList.item(i) + if (node1.getNodeType() == Node.ELEMENT_NODE) { + Element eElement1 = (Element) node1 + value = utils.getElementText(eElement1, "vm-name") + if (i != valueList.getLength() - 1) { + values = sb1.append(value + ",") } + else { + values = sb1.append(value); + } + position = i.toString() + paramsMap.put("${key}_name_${position}", "${value}") } - for(int n = 0; n < vmNetworksList.getLength(); n++){ - String floatingIpKeyValueStr = "" - String floatingIpV6KeyValueStr = "" - Node nodeNetworkKey = vmNetworksList.item(n) - if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { - Element eElementNetworkKey = (Element) nodeNetworkKey - String ipAddressValues - String ipV6AddressValues - String networkPosition = "0" - StringBuilder sb2 = new StringBuilder() - StringBuilder sb3 = new StringBuilder() - StringBuilder sb4 = new StringBuilder() + } + for(int n = 0; n < vmNetworksList.getLength(); n++){ + String floatingIpKeyValueStr = "" + String floatingIpV6KeyValueStr = "" + Node nodeNetworkKey = vmNetworksList.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String ipAddressValues + String ipV6AddressValues + String networkPosition = "0" + StringBuilder sb2 = new StringBuilder() + StringBuilder sb3 = new StringBuilder() + StringBuilder sb4 = new StringBuilder() + networkKey = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkKey.isEmpty()) { networkKey = utils.getElementText(eElementNetworkKey, "network-role") - floatingIPKey = key + '_' + networkKey + '_floating_ip' - floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") - if(!floatingIPKeyValue.isEmpty()){ - paramsMap.put("$floatingIPKey", "$floatingIPKeyValue") - } - floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' - floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") - if(!floatingIPV6KeyValue.isEmpty()){ - paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue") - } - NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") - for(int a = 0; a < networkIpsList.getLength(); a++){ - Node ipAddress = networkIpsList.item(a) - if (ipAddress.getNodeType() == Node.ELEMENT_NODE) { - Element eElementIpAddress = (Element) ipAddress - String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address") - if (a != networkIpsList.getLength() - 1) { - ipAddressValues = sb2.append(ipAddressValue + ",") - } - else { - ipAddressValues = sb2.append(ipAddressValue); - } - networkPosition = a.toString() - paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}") + } + floatingIPKey = key + '_' + networkKey + '_floating_ip' + floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") + if(!floatingIPKeyValue.isEmpty()){ + paramsMap.put("$floatingIPKey", "$floatingIPKeyValue") + } + floatingIPV6Key = key + '_' + networkKey + '_floating_v6_ip' + floatingIPV6KeyValue = utils.getElementText(eElementNetworkKey, "floating-ip-v6") + if(!floatingIPV6KeyValue.isEmpty()){ + paramsMap.put("$floatingIPV6Key", "$floatingIPV6KeyValue") + } + NodeList networkIpsList = eElementNetworkKey.getElementsByTagNameNS("*","network-ips") + for(int a = 0; a < networkIpsList.getLength(); a++){ + Node ipAddress = networkIpsList.item(a) + if (ipAddress.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpAddress = (Element) ipAddress + String ipAddressValue = utils.getElementText(eElementIpAddress, "ip-address") + if (a != networkIpsList.getLength() - 1) { + ipAddressValues = sb2.append(ipAddressValue + ",") } - } - - paramsMap.put("${key}_${networkKey}_ips", "${ipAddressValues}") - - NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") - String interfaceRoutePrefixValues = sb3.append("[") - - for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ - Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) - if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { - Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix - String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") - if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { - interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") - } - if (a != interfaceRoutePrefixesList.getLength() - 1) { - interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") - } - else { - interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") - } + else { + ipAddressValues = sb2.append(ipAddressValue); } + networkPosition = a.toString() + paramsMap.put("${key}_${networkKey}_ip_${networkPosition}", "${ipAddressValue}") } - interfaceRoutePrefixValues = sb3.append("]") - if (interfaceRoutePrefixesList.getLength() > 0) { - paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}") + } + + paramsMap.put("${key}_${networkKey}_ips", "${ipAddressValues}") + + NodeList interfaceRoutePrefixesList = eElementNetworkKey.getElementsByTagNameNS("*","interface-route-prefixes") + String interfaceRoutePrefixValues = sb3.append("[") + + for(int a = 0; a < interfaceRoutePrefixesList.getLength(); a++){ + Node interfaceRoutePrefix = interfaceRoutePrefixesList.item(a) + if (interfaceRoutePrefix.getNodeType() == Node.ELEMENT_NODE) { + Element eElementInterfaceRoutePrefix = (Element) interfaceRoutePrefix + String interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix-cidr") + if (interfaceRoutePrefixValue == null || interfaceRoutePrefixValue.isEmpty()) { + interfaceRoutePrefixValue = utils.getElementText(eElementInterfaceRoutePrefix, "interface-route-prefix") + } + if (a != interfaceRoutePrefixesList.getLength() - 1) { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}" + ",") + } + else { + interfaceRoutePrefixValues = sb3.append("{\"interface_route_table_routes_route_prefix\": \"" + interfaceRoutePrefixValue + "\"}") + } } - - NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") - for(int a = 0; a < networkIpsV6List.getLength(); a++){ - Node ipV6Address = networkIpsV6List.item(a) - if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) { - Element eElementIpV6Address = (Element) ipV6Address - String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6") - if (a != networkIpsV6List.getLength() - 1) { - ipV6AddressValues = sb4.append(ipV6AddressValue + ",") - } - else { - ipV6AddressValues = sb4.append(ipV6AddressValue); - } - networkPosition = a.toString() - paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}") + } + interfaceRoutePrefixValues = sb3.append("]") + if (interfaceRoutePrefixesList.getLength() > 0) { + paramsMap.put("${key}_${networkKey}_route_prefixes", "${interfaceRoutePrefixValues}") + } + + NodeList networkIpsV6List = eElementNetworkKey.getElementsByTagNameNS("*","network-ips-v6") + for(int a = 0; a < networkIpsV6List.getLength(); a++){ + Node ipV6Address = networkIpsV6List.item(a) + if (ipV6Address.getNodeType() == Node.ELEMENT_NODE) { + Element eElementIpV6Address = (Element) ipV6Address + String ipV6AddressValue = utils.getElementText(eElementIpV6Address, "ip-address-ipv6") + if (a != networkIpsV6List.getLength() - 1) { + ipV6AddressValues = sb4.append(ipV6AddressValue + ",") } + else { + ipV6AddressValues = sb4.append(ipV6AddressValue); + } + networkPosition = a.toString() + paramsMap.put("${key}_${networkKey}_v6_ip_${networkPosition}", "${ipV6AddressValue}") } - paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}") } + paramsMap.put("${key}_${networkKey}_v6_ips", "${ipV6AddressValues}") } - paramsMap.put("${key}_names", "${values}") } + paramsMap.put("${key}_names", "${values}") } - //SDNC Response Params - String sdncResponseParams = "" - List sdncResponseParamsToSkip = ["vnf_id", "vf_module_id", "vnf_name", "vf_module_name"] - String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters") - if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ - // No SDNC params - }else{ - NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters") - for (int z = 0; z < paramsList.getLength(); z++) { - Node node = paramsList.item(z) - Element eElement = (Element) node - String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name") - if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { - String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") - paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") - } + } + //SDNC Response Params + String sdncResponseParams = "" + List sdncResponseParamsToSkip = ["vnf_id", "vf_module_id", "vnf_name", "vf_module_name"] + String vnfParamsChildNodes = utils.getChildNodes(data, "vnf-parameters") + if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ + // No SDNC params + }else{ + NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters") + for (int z = 0; z < paramsList.getLength(); z++) { + Node node = paramsList.item(z) + Element eElement = (Element) node + String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name") + if (!sdncResponseParamsToSkip.contains(vnfParameterName)) { + String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value") + paramsMap.put("${vnfParameterName}", "${vnfParameterValue}") } } - + } + // Parameters received from the request should overwrite any parameters received from SDNC if (vnfParamsMap != null) { for (Map.Entry entry : vnfParamsMap.entrySet()) { @@ -490,18 +520,18 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { String paramValue = entry.getValue() paramsXml = """ - ${paramName} - ${paramValue} - - """ - + ${paramName} + ${paramValue} + + """ + vfModuleParams = sbParams.append(paramsXml) } return vfModuleParams - + } - + /* * Parses VNF parameters passed in on the incoming requests and SDNC parameters returned from SDNC get response @@ -519,7 +549,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { */ protected String buildVfModuleParamsFromCombinedTopologies(Map vnfParamsMap, String vnfSdncGetResponse, String vfmoduleSdncGetResponse, String vnfId, String vnfName, - String vfModuleId, String vfModuleName, String vfModuleIndex) { + String vfModuleId, String vfModuleName, String vfModuleIndex, String environmentContext, String workloadContext) { // Set up initial parameters @@ -533,7 +563,9 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { paramsMap.put("vnf_id", "${vnfId}") paramsMap.put("vnf_name", "${vnfName}") paramsMap.put("vf_module_id", "${vfModuleId}") - paramsMap.put("vf_module_name", "${vfModuleName}") + paramsMap.put("vf_module_name", "${vfModuleName}") + paramsMap.put("environment_context","${environmentContext}") + paramsMap.put("workload_context", "${workloadContext}") //Get SDNC Response Data for VNF @@ -564,6 +596,40 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { paramsMap.put("availability_zone_${aZonePosition}", "${aZoneValue}") } } + + //Get SDNC Response Data for VF Module + + String vfModuleData = utils.getNodeXml(vfmoduleSdncGetResponse, "response-data") + vfModuleData = vfModuleData.replaceAll("<", "<") + vfModuleData = vfModuleData.replaceAll(">", ">") + + String vfModuleTopology = utils.getNodeXml(vfModuleData, "vf-module-topology") + vfModuleTopology = utils.removeXmlPreamble(vfModuleTopology) + vfModuleTopology = utils.removeXmlNamespaces(vfModuleTopology) + String vfModuleTopologyIdentifier = utils.getNodeXml(vfModuleTopology, "vf-module-topology-identifier") + + InputSource sourceVfModule = new InputSource(new StringReader(vfModuleData)); + DocumentBuilderFactory docFactoryVfModule = DocumentBuilderFactory.newInstance(); + docFactoryVfModule.setNamespaceAware(true) + DocumentBuilder docBuilderVfModule = docFactoryVfModule.newDocumentBuilder() + Document responseXmlVfModule = docBuilderVfModule.parse(sourceVfModule) + + // Map of network-roles and network-tags from vm-networks + + NodeList vmNetworksListGlobal = responseXmlVfModule.getElementsByTagNameNS("*", "vm-networks") + Map networkRoleMap = new HashMap() + for(int n = 0; n < vmNetworksListGlobal.getLength(); n++){ + Node nodeNetworkKey = vmNetworksListGlobal.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String networkRole = utils.getElementText(eElementNetworkKey, "network-role") + String networkRoleValue = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkRoleValue.isEmpty()) { + networkRoleValue = networkRole + } + networkRoleMap.put(networkRole, networkRoleValue) + } + } // VNF Networks Data @@ -573,8 +639,15 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { for (int x = 0; x < vnfNetworkList.getLength(); x++) { Node node = vnfNetworkList.item(x) if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - String vnfNetworkKey = utils.getElementText(eElement, "network-role") + Element eElement = (Element) node + String vnfNetworkKey = utils.getElementText(eElement, "network-role-tag") + String networkRole = utils.getElementText(eElement, "network-role") + if (vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRoleMap.get(networkRole) + if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRole + } + } String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") @@ -608,22 +681,7 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { } } - //Get SDNC Response Data for VF Module - - String vfModuleData = utils.getNodeXml(vfmoduleSdncGetResponse, "response-data") - vfModuleData = vfModuleData.replaceAll("<", "<") - vfModuleData = vfModuleData.replaceAll(">", ">") - - String vfModuleTopology = utils.getNodeXml(vfModuleData, "vf-module-topology") - vfModuleTopology = utils.removeXmlPreamble(vfModuleTopology) - vfModuleTopology = utils.removeXmlNamespaces(vfModuleTopology) - String vfModuleTopologyIdentifier = utils.getNodeXml(vfModuleTopology, "vf-module-topology-identifier") - InputSource sourceVfModule = new InputSource(new StringReader(vfModuleData)); - DocumentBuilderFactory docFactoryVfModule = DocumentBuilderFactory.newInstance(); - docFactoryVfModule.setNamespaceAware(true) - DocumentBuilder docBuilderVfModule = docFactoryVfModule.newDocumentBuilder() - Document responseXmlVfModule = docBuilderVfModule.parse(sourceVfModule) // VMS Data @@ -675,7 +733,10 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { StringBuilder sb2 = new StringBuilder() StringBuilder sb3 = new StringBuilder() StringBuilder sb4 = new StringBuilder() - networkKey = utils.getElementText(eElementNetworkKey, "network-role") + networkKey = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkKey.isEmpty()) { + networkKey = utils.getElementText(eElementNetworkKey, "network-role") + } floatingIPKey = key + '_' + networkKey + '_floating_ip' floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") if(!floatingIPKeyValue.isEmpty()){ @@ -886,6 +947,23 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { aZones = sbAZone.append(aZoneXml) } } + + // Map of network-roles and network-tags from vm-networks + + NodeList vmNetworksListGlobal = responseXml.getElementsByTagNameNS("*", "vm-networks") + Map networkRoleMap = new HashMap() + for(int n = 0; n < vmNetworksListGlobal.getLength(); n++){ + Node nodeNetworkKey = vmNetworksListGlobal.item(n) + if (nodeNetworkKey.getNodeType() == Node.ELEMENT_NODE) { + Element eElementNetworkKey = (Element) nodeNetworkKey + String networkRole = utils.getElementText(eElementNetworkKey, "network-role") + String networkRoleValue = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkRoleValue.isEmpty()) { + networkRoleValue = networkRole + } + networkRoleMap.put(networkRole, networkRoleValue) + } + } // VNF Networks Data String vnfNetworkNetId = "" @@ -905,7 +983,14 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { Node node = vnfNetworkList.item(x) if (node.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) node - String vnfNetworkKey = utils.getElementText(eElement, "network-role") + String vnfNetworkKey = utils.getElementText(eElement, "network-role-tag") + String networkRole = utils.getElementText(eElement, "network-role") + if (vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRoleMap.get(networkRole) + if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) { + vnfNetworkKey = networkRole + } + } String vnfNetworkNeutronIdValue = utils.getElementText(eElement, "neutron-id") String vnfNetworkNetNameValue = utils.getElementText(eElement, "network-name") String vnfNetworkSubNetIdValue = utils.getElementText(eElement, "subnet-id") @@ -1034,7 +1119,10 @@ public abstract class VfModuleBase extends AbstractServiceTaskProcessor { StringBuilder sb2 = new StringBuilder() StringBuilder sb3 = new StringBuilder() StringBuilder sb4 = new StringBuilder() - networkKey = utils.getElementText(eElementNetworkKey, "network-role") + networkKey = utils.getElementText(eElementNetworkKey, "network-role-tag") + if (networkKey.isEmpty()) { + networkKey = utils.getElementText(eElementNetworkKey, "network-role") + } floatingIPKey = key + '_' + networkKey + '_floating_ip' floatingIPKeyValue = utils.getElementText(eElementNetworkKey, "floating-ip") if(!floatingIPKeyValue.isEmpty()){ diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy index dbcab28df3..5f2a845ef2 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -22,7 +22,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.rest.APIResponse import org.openecomp.mso.rest.RESTClient import org.openecomp.mso.rest.RESTConfig @@ -32,7 +32,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() // VNF Response Processing - public void preProcessRequest (Execution execution) { + public void preProcessRequest (DelegateExecution execution) { def method = getClass().getSimpleName() + '.preProcessRequest(' + 'execution=' + execution.getId() + ')' @@ -58,6 +58,10 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String messageId = getChildText(root, 'messageId') + if ('rollbackVolumeGroupRequest'.equals(requestType)) { + messageId = getMessageIdForVolumeGroupRollback(root) + } + if (messageId == null || messageId.isEmpty()) { String msg = getProcessKey(execution) + ': no messageId in ' + requestType logError(msg) @@ -219,7 +223,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { vnfAdapterUrl = vnfAdapterEndpoint + '/volume-groups/' + URLEncoder.encode(volumeGroupId, 'UTF-8') } else if ('rollbackVolumeGroupRequest'.equals(requestType)) { - String volumeGroupId = getChildText(root, 'volumeGroupId') + String volumeGroupId = root.'volumeGroupRollback'.'volumeGroupId'.text() if (volumeGroupId == null || volumeGroupId.isEmpty()) { String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType @@ -274,11 +278,15 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { } } + public String getMessageIdForVolumeGroupRollback(Node root) { + return root.'volumeGroupRollback'.'messageId'.text() + } + /** * This method is used instead of an HTTP Connector task because the * connector does not allow DELETE with a body. */ - public void sendRequestToVnfAdapter(Execution execution) { + public void sendRequestToVnfAdapter(DelegateExecution execution) { def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' + 'execution=' + execution.getId() + ')' @@ -324,7 +332,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { } } - public void processCallback(Execution execution){ + public void processCallback(DelegateExecution execution){ def method = getClass().getSimpleName() + '.processCallback(' + 'execution=' + execution.getId() + ')' @@ -360,7 +368,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { * a WorkflowException. If the response cannot be parsed, a more generic * WorkflowException is created. */ - public void vnfAdapterWorkflowException(Execution execution, Object response) { + public void vnfAdapterWorkflowException(DelegateExecution execution, Object response) { try { Node root = new XmlParser().parseText(response) String category = getChildText(root, "category") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterUtils.groovy index cb173660cd..9c1a472a67 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/VnfAdapterUtils.groovy @@ -20,7 +20,7 @@ package org.openecomp.mso.bpmn.common.scripts import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.delegate.DelegateExecution; import org.openecomp.mso.bpmn.core.WorkflowException class VnfAdapterUtils { @@ -33,7 +33,7 @@ class VnfAdapterUtils { ExceptionUtil exceptionUtil = new ExceptionUtil() - public void validateVnfResponse(Execution execution, String responseVar, String responseCodeVar, String errorResponseVar) { + public void validateVnfResponse(DelegateExecution execution, String responseVar, String responseCodeVar, String errorResponseVar) { def method = getClass().getSimpleName() + '.validateVnfResponse(' + 'execution=' + execution.getId() + ', responseVar=' + responseVar + diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/PayloadClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/PayloadClient.java new file mode 100644 index 0000000000..5a0de6f5e9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/PayloadClient.java @@ -0,0 +1,109 @@ +/*- + * ============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.bpmn.appc.payload; + +import org.openecomp.mso.bpmn.appc.payload.beans.*; + +import java.util.Optional; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.openecomp.mso.bpmn.core.json.JsonUtils; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class PayloadClient { + + protected static ObjectMapper mapper = new ObjectMapper(); + + + public static Optional upgradeFormat(Optional payload, String vnfName) throws JsonProcessingException{ + UpgradeAction payloadResult = new UpgradeAction(); + ConfigurationParametersUpgrade configParams = new ConfigurationParametersUpgrade(); + String payloadString = payload.get(); + String existingSoftware = JsonUtils.getJsonValue(payloadString, "existing-software-version"); + String newSoftware = JsonUtils.getJsonValue(payloadString, "new-software-version"); + configParams.setExistingSoftwareVersion(existingSoftware); + configParams.setNewSoftwareVersion(newSoftware); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional resumeTrafficFormat(String vnfName) throws JsonProcessingException{ + ResumeTrafficAction payloadResult = new ResumeTrafficAction(); + ConfigurationParametersResumeTraffic configParams = new ConfigurationParametersResumeTraffic(); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional quiesceTrafficFormat(Optional payload, String vnfName) throws JsonProcessingException{ + QuiesceTrafficAction payloadResult = new QuiesceTrafficAction(); + ConfigurationParametersQuiesce configParams = new ConfigurationParametersQuiesce(); + String payloadString = payload.get(); + String operationsTimeout = JsonUtils.getJsonValue(payloadString, "operations-timeout"); + configParams.setOperationsTimeout(operationsTimeout); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional startStopFormat(String aicIdentity) throws JsonProcessingException{ + StartStopAction payloadResult = new StartStopAction(); + payloadResult.setAICIdentity(aicIdentity); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional healthCheckFormat(String vnfName, String vnfHostIpAddress) throws JsonProcessingException{ + HealthCheckAction payloadResult = new HealthCheckAction(); + RequestParametersHealthCheck requestParams = new RequestParametersHealthCheck(); + ConfigurationParametersHealthCheck configParams = new ConfigurationParametersHealthCheck(); + requestParams.setVnfName(vnfName); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + payloadResult.setRequestParameters(requestParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional snapshotFormat(String vmId, String identityUrl)throws JsonProcessingException{ + SnapshotAction payloadResult = new SnapshotAction(); + payloadResult.setVmId(vmId); + payloadResult.setIdentityUrl(identityUrl); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + /*public Optional verifySnapshotFormat(Optional payload) throws Exception, JsonProcessingException, JsonMappingException{ + final Snapshot check = mapper.readValue(payload.get(), Snapshot.class); + return Optional.of(mapper.writeValueAsString(check)); + } + + public Optional verifyUpgradeFormat(Optional payload) throws Exception, JsonProcessingException, JsonMappingException{ + final UpdateCheck check = mapper.readValue(payload.get(), UpdateCheck.class); + return Optional.of(mapper.writeValueAsString(check)); + } + + public Optional verifyQuiesceTrafficFormat(Optional payload)throws Exception, JsonProcessingException, JsonMappingException{ + final QuiesceTraffic check = mapper.readValue(payload.get(), QuiesceTraffic.class); + return Optional.of(mapper.writeValueAsString(check)); + } + */ + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigModifyAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigModifyAction.java new file mode 100644 index 0000000000..09ad2bf439 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigModifyAction.java @@ -0,0 +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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"request-parameters", +"configuration-parameters" +}) +public class ConfigModifyAction { + +@JsonProperty("request-parameters") +private RequestParametersConfigModify requestParameters; +@JsonProperty("configuration-parameters") +private ConfigurationParametersConfigModify configurationParameters; + +@JsonProperty("request-parameters") +public RequestParametersConfigModify getRequestParameters() { +return requestParameters; +} + +@JsonProperty("request-parameters") +public void setRequestParameters(RequestParametersConfigModify requestParameters) { +this.requestParameters = requestParameters; +} + +@JsonProperty("configuration-parameters") +public ConfigurationParametersConfigModify getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersConfigModify configurationParameters) { +this.configurationParameters = configurationParameters; +} + +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersConfigModify.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersConfigModify.java new file mode 100644 index 0000000000..dda7856168 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersConfigModify.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.openecomp.mso.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"node0_hostname", +"node0_backup_router_address" +}) +public class ConfigurationParametersConfigModify { + +@JsonProperty("node0_hostname") +private String node0Hostname; +@JsonProperty("node0_backup_router_address") +private String node0BackupRouterAddress; + +@JsonProperty("node0_hostname") +public String getNode0Hostname() { +return node0Hostname; +} + +@JsonProperty("node0_hostname") +public void setNode0Hostname(String node0Hostname) { +this.node0Hostname = node0Hostname; +} + +@JsonProperty("node0_backup_router_address") +public String getNode0BackupRouterAddress() { +return node0BackupRouterAddress; +} + +@JsonProperty("node0_backup_router_address") +public void setNode0BackupRouterAddress(String node0BackupRouterAddress) { +this.node0BackupRouterAddress = node0BackupRouterAddress; +} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersHealthCheck.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersHealthCheck.java new file mode 100644 index 0000000000..000b1bdbf7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersHealthCheck.java @@ -0,0 +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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf_name" +}) +public class ConfigurationParametersHealthCheck { + +@JsonProperty("vnf_name") +private String vnfName; + +@JsonProperty("vnf_name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf_name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersQuiesce.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersQuiesce.java new file mode 100644 index 0000000000..e354d9ca2e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersQuiesce.java @@ -0,0 +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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf_name", +"operations_timeout" +}) +public class ConfigurationParametersQuiesce { + +@JsonProperty("vnf_name") +private String vnfName; +@JsonProperty("operations_timeout") +private String operationsTimeout; + +@JsonProperty("vnf_name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf_name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} + +@JsonProperty("operations_timeout") +public String getOperationsTimeout() { +return operationsTimeout; +} + +@JsonProperty("operations_timeout") +public void setOperationsTimeout(String operationsTimeout) { +this.operationsTimeout = operationsTimeout; +} + +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersResumeTraffic.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersResumeTraffic.java new file mode 100644 index 0000000000..820618e828 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersResumeTraffic.java @@ -0,0 +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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf_name" +}) +public class ConfigurationParametersResumeTraffic { + +@JsonProperty("vnf_name") +private String vnfName; + +@JsonProperty("vnf_name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf_name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersUpgrade.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersUpgrade.java new file mode 100644 index 0000000000..0845e7c37d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ConfigurationParametersUpgrade.java @@ -0,0 +1,71 @@ +/*- + * ============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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf_name", +"existing-software-version", +"new-software-version" +}) +public class ConfigurationParametersUpgrade { +@JsonProperty("vnf_name") +private String vnfName; +@JsonProperty("existing-software-version") +private String existingSoftwareVersion; +@JsonProperty("new-software-version") +private String newSoftwareVersion; + +@JsonProperty("vnf_name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf_name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} + +@JsonProperty("existing-software-version") +public String getExistingSoftwareVersion() { +return existingSoftwareVersion; +} + +@JsonProperty("existing-software-version") +public void setExistingSoftwareVersion(String existingSoftwareVersion) { +this.existingSoftwareVersion = existingSoftwareVersion; +} + +@JsonProperty("new-software-version") +public String getNewSoftwareVersion() { +return newSoftwareVersion; +} + +@JsonProperty("new-software-version") +public void setNewSoftwareVersion(String newSoftwareVersion) { +this.newSoftwareVersion = newSoftwareVersion; +} + +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/HealthCheckAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/HealthCheckAction.java new file mode 100644 index 0000000000..53408f1ead --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/HealthCheckAction.java @@ -0,0 +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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"request-parameters", +"configuration-parameters" +}) +public class HealthCheckAction { + +@JsonProperty("request-parameters") +private RequestParametersHealthCheck requestParameters; +@JsonProperty("configuration-parameters") +private ConfigurationParametersHealthCheck configurationParameters; + +@JsonProperty("request-parameters") +public RequestParametersHealthCheck getRequestParameters() { +return requestParameters; +} + +@JsonProperty("request-parameters") +public void setRequestParameters(RequestParametersHealthCheck requestParameters) { +this.requestParameters = requestParameters; +} + +@JsonProperty("configuration-parameters") +public ConfigurationParametersHealthCheck getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersHealthCheck configurationParameters) { +this.configurationParameters = configurationParameters; +} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/QuiesceTrafficAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/QuiesceTrafficAction.java new file mode 100644 index 0000000000..cbe8ee0b91 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/QuiesceTrafficAction.java @@ -0,0 +1,46 @@ +/*- + * ============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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"configuration-parameters" +}) +public class QuiesceTrafficAction { + +@JsonProperty("configuration-parameters") +private ConfigurationParametersQuiesce configurationParameters; + +@JsonProperty("configuration-parameters") +public ConfigurationParametersQuiesce getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersQuiesce configurationParameters) { +this.configurationParameters = configurationParameters; +} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/RequestParametersConfigModify.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/RequestParametersConfigModify.java new file mode 100644 index 0000000000..41b3314e7c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/RequestParametersConfigModify.java @@ -0,0 +1,46 @@ +/*- + * ============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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf-host-ip-address" +}) +public class RequestParametersConfigModify { + +@JsonProperty("vnf-host-ip-address") +private String vnfHostIpAddress; + +@JsonProperty("vnf-host-ip-address") +public String getVnfHostIpAddress() { +return vnfHostIpAddress; +} + +@JsonProperty("vnf-host-ip-address") +public void setVnfHostIpAddress(String vnfHostIpAddress) { +this.vnfHostIpAddress = vnfHostIpAddress; +} + +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/RequestParametersHealthCheck.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/RequestParametersHealthCheck.java new file mode 100644 index 0000000000..dcdb4fb71e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/RequestParametersHealthCheck.java @@ -0,0 +1,47 @@ +/*- + * ============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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf-name" +}) +public class RequestParametersHealthCheck { + +@JsonProperty("vnf-name") +private String vnfName; + + +@JsonProperty("vnf-name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf-name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} + +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ResumeTrafficAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ResumeTrafficAction.java new file mode 100644 index 0000000000..de4fe25cd7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/ResumeTrafficAction.java @@ -0,0 +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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"configuration-parameters" +}) +public class ResumeTrafficAction { + +@JsonProperty("configuration-parameters") +private ConfigurationParametersResumeTraffic configurationParameters; + +@JsonProperty("configuration-parameters") +public ConfigurationParametersResumeTraffic getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersResumeTraffic configurationParameters) { +this.configurationParameters = configurationParameters; +} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/SnapshotAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/SnapshotAction.java new file mode 100644 index 0000000000..bb74798300 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/SnapshotAction.java @@ -0,0 +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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vm-id", +"identity-url" +}) +public class SnapshotAction { + +@JsonProperty("vm-id") +private String vmId; +@JsonProperty("identity-url") +private String identityUrl; + +@JsonProperty("vm-id") +public String getVmId() { +return vmId; +} + +@JsonProperty("vm-id") +public void setVmId(String vmId) { +this.vmId = vmId; +} + +@JsonProperty("identity-url") +public String getIdentityUrl() { +return identityUrl; +} + +@JsonProperty("identity-url") +public void setIdentityUrl(String identityUrl) { +this.identityUrl = identityUrl; +} + +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/StartStopAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/StartStopAction.java new file mode 100644 index 0000000000..6ef822fbe1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/StartStopAction.java @@ -0,0 +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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +" AICIdentity " +}) +public class StartStopAction { + +@JsonProperty(" AICIdentity ") +private String aICIdentity; + +@JsonProperty(" AICIdentity ") +public String getAICIdentity() { +return aICIdentity; +} + +@JsonProperty(" AICIdentity ") +public void setAICIdentity(String aICIdentity) { +this.aICIdentity = aICIdentity; +} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/UpgradeAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/UpgradeAction.java new file mode 100644 index 0000000000..3486fa73ba --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/appc/payload/beans/UpgradeAction.java @@ -0,0 +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.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"configuration-parameters" +}) +public class UpgradeAction { + +@JsonProperty("configuration-parameters") +private ConfigurationParametersUpgrade configurationParameters; + +@JsonProperty("configuration-parameters") +public ConfigurationParametersUpgrade getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersUpgrade configurationParameters) { +this.configurationParameters = configurationParameters; +} +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java index daca9fcf3f..f61c692775 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/AbstractCallbackService.java @@ -25,7 +25,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.camunda.bpm.BpmPlatform; import org.camunda.bpm.engine.MismatchingMessageCorrelationException; +import org.camunda.bpm.engine.OptimisticLockingException; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.Execution; import org.camunda.bpm.engine.runtime.MessageCorrelationResult; @@ -241,12 +243,64 @@ public abstract class AbstractCallbackService extends ProcessEngineAwareService .setVariables(variables) .processInstanceVariableEquals(correlationVariable, correlationValue) .correlateWithResult(); - + } catch (MismatchingMessageCorrelationException e) { // A correlation exception occurred even after we identified // one waiting process. Throw it back to the client. throw e; - } catch (Exception e) { + } catch (OptimisticLockingException ole) { + + String msg = "Caught " + ole.getClass().getSimpleName() + " after receiving " + messageEventName + + " with " + correlationVariable + " = '" + correlationValue + + "': " + ole; + LOGGER.debug(msg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN CORRELATION ERROR -", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, msg, ole); + + //Retry for OptimisticLocking Exceptions + int retryCount = 0; + String retryStr = properties.get("mso.bpmn.optimisticlockingexception.retrycount"); + if (retryStr != null) { + try { + retryCount = Integer.parseInt(retryStr); + } catch (NumberFormatException e) { + // Ignore + } + } + + LOGGER.debug("Retry correlate for OptimisticLockingException, retryCount:" + retryCount); + + for (; retryCount >0 ; retryCount--) { + + try{ + Thread.sleep(SLOW_POLL_INT_MS); + + @SuppressWarnings("unused") + MessageCorrelationResult result = runtimeService + .createMessageCorrelation(messageEventName) + .setVariables(variables) + .processInstanceVariableEquals(correlationVariable, correlationValue) + .correlateWithResult(); + retryCount = 0; + LOGGER.debug("OptimisticLockingException retry was successful, seting retryCount: " + retryCount); + } catch (OptimisticLockingException olex) { + //oleFlag = ex instanceof org.camunda.bpm.engine.OptimisticLockingException; + String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + retryCount + " | exception returned: " + olex; + LOGGER.debug(strMsg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, strMsg, olex); + } catch (Exception excep) { + retryCount = 0; + //oleFlag = ex instanceof org.camunda.bpm.engine.OptimisticLockingException; + String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + retryCount + " | exception returned: " + excep; + LOGGER.debug(strMsg); + LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, strMsg, excep); + } + + } + + }catch (Exception e) { // This must be an exception from the flow itself. Log it, but don't // report it back to the client. String msg = "Caught " + e.getClass().getSimpleName() + " running " diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java new file mode 100644 index 0000000000..cd98860efe --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java @@ -0,0 +1,33 @@ +/*- + * ============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.bpmn.common.workflow.service; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.ProcessEngines; + + +public class WorkflowAsyncCommonResource extends WorkflowAsyncResource { + + @Override + public String getProcessEngineName() { + return "default"; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java index 608adcf756..db11db59f7 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -273,7 +273,6 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null; } - private static Map getInputVariables(VariableMapImpl variableMap) { Map inputVariables = new HashMap<>(); @SuppressWarnings("unchecked") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java deleted file mode 100644 index df28baac74..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/PreconditionFailedException.java +++ /dev/null @@ -1,35 +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.client; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - -public class PreconditionFailedException extends WebApplicationException { - /** - * - */ - private static final long serialVersionUID = 1L; - - public PreconditionFailedException(String message) { - super(message, Response.Status.PRECONDITION_FAILED); - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java deleted file mode 100644 index e0e3e936be..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapper.java +++ /dev/null @@ -1,98 +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.client; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; - -import javax.annotation.Priority; -import javax.ws.rs.BadRequestException; -import javax.ws.rs.ForbiddenException; -import javax.ws.rs.InternalServerErrorException; -import javax.ws.rs.NotAcceptableException; -import javax.ws.rs.NotAllowedException; -import javax.ws.rs.NotAuthorizedException; -import javax.ws.rs.NotFoundException; -import javax.ws.rs.NotSupportedException; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.client.ClientRequestContext; -import javax.ws.rs.client.ClientResponseContext; -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.Provider; - -@Provider -@Priority(value = 1) -public abstract class ResponseExceptionMapper implements ClientResponseFilter { - - @Override - public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { - if (responseContext.getStatus() >= 300) { - String message = "empty message"; - if (responseContext.hasEntity()) { - Optional result = this.extractMessage(responseContext.getEntityStream()); - if (result.isPresent()) { - message = result.get(); - } - } - Response.Status status = Response.Status.fromStatusCode(responseContext.getStatus()); - WebApplicationException webAppException; - switch (status) { - case BAD_REQUEST: - webAppException = new BadRequestException(message); - break; - case UNAUTHORIZED: - webAppException = new NotAuthorizedException(message); - break; - case FORBIDDEN: - webAppException = new ForbiddenException(message); - break; - case NOT_FOUND: - webAppException = new NotFoundException(message); - break; - case METHOD_NOT_ALLOWED: - webAppException = new NotAllowedException(message); - break; - case NOT_ACCEPTABLE: - webAppException = new NotAcceptableException(message); - break; - case PRECONDITION_FAILED: - webAppException = new PreconditionFailedException(message); - break; - case UNSUPPORTED_MEDIA_TYPE: - webAppException = new NotSupportedException(message); - break; - case INTERNAL_SERVER_ERROR: - webAppException = new InternalServerErrorException(message); - break; - case SERVICE_UNAVAILABLE: - webAppException = new WebApplicationException(message); - break; - default: - webAppException = new WebApplicationException(message); - } - throw webAppException; - } - } - - public abstract Optional extractMessage(InputStream stream) throws IOException; -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java deleted file mode 100644 index 0845a2fbcd..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/ResponseExceptionMapperImpl.java +++ /dev/null @@ -1,39 +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.client; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; - -import org.apache.commons.io.IOUtils; - -public class ResponseExceptionMapperImpl extends ResponseExceptionMapper { - - @Override - public Optional extractMessage(InputStream stream) throws IOException { - final String input = IOUtils.toString(stream, "UTF-8"); - IOUtils.closeQuietly(stream); - return Optional.of(input); - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestProperties.java deleted file mode 100644 index ae8862de5e..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestProperties.java +++ /dev/null @@ -1,30 +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.client; - -import java.net.MalformedURLException; -import java.net.URL; - -public interface RestProperties { - - public URL getEndpoint() throws MalformedURLException; - public String getSystemName(); -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java deleted file mode 100644 index 6d49d9800f..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/RestPropertiesLoader.java +++ /dev/null @@ -1,55 +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.client; - -import java.util.Iterator; -import java.util.ServiceLoader; - -public class RestPropertiesLoader { - - private final ServiceLoader services; - private RestPropertiesLoader() { - services = ServiceLoader.load(RestProperties.class); - } - - private static class Helper { - private static final RestPropertiesLoader INSTANCE = new RestPropertiesLoader(); - } - - public static RestPropertiesLoader getInstance() { - return Helper.INSTANCE; - } - - public T getImpl(Class clazz) { - T result = null; - Iterator propertyImpls = services.iterator(); - RestProperties item; - while (propertyImpls.hasNext()) { - item = propertyImpls.next(); - if (clazz.isAssignableFrom(item.getClass())) { - result = (T)item; - break; - } - } - - return result; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java deleted file mode 100644 index 4d97c4df71..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIClientResponseExceptionMapper.java +++ /dev/null @@ -1,91 +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.client.aai; - -import java.io.IOException; - -import javax.annotation.Priority; -import javax.ws.rs.BadRequestException; -import javax.ws.rs.ForbiddenException; -import javax.ws.rs.InternalServerErrorException; -import javax.ws.rs.NotAcceptableException; -import javax.ws.rs.NotAllowedException; -import javax.ws.rs.NotAuthorizedException; -import javax.ws.rs.NotFoundException; -import javax.ws.rs.NotSupportedException; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.client.ClientRequestContext; -import javax.ws.rs.client.ClientResponseContext; -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.Provider; - -import org.openecomp.mso.client.aai.entities.AAIError; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@Provider -@Priority(value = 1) -public class AAIClientResponseExceptionMapper implements ClientResponseFilter { - - @Override - public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { - if (responseContext.getStatus() != Response.Status.OK.getStatusCode() && responseContext.hasEntity()) { - AAIError error = new ObjectMapper().readValue(responseContext.getEntityStream(), AAIError.class); - String message = error.getRequestError().getServiceException().getText(); - - Response.Status status = Response.Status.fromStatusCode(responseContext.getStatus()); - WebApplicationException webAppException; - switch (status) { - case BAD_REQUEST: - webAppException = new BadRequestException(message); - break; - case UNAUTHORIZED: - webAppException = new NotAuthorizedException(message); - break; - case FORBIDDEN: - webAppException = new ForbiddenException(message); - break; - case NOT_FOUND: - webAppException = new NotFoundException(message); - break; - case METHOD_NOT_ALLOWED: - webAppException = new NotAllowedException(message); - break; - case NOT_ACCEPTABLE: - webAppException = new NotAcceptableException(message); - break; - case UNSUPPORTED_MEDIA_TYPE: - webAppException = new NotSupportedException(message); - break; - case INTERNAL_SERVER_ERROR: - webAppException = new InternalServerErrorException(message); - break; - case SERVICE_UNAVAILABLE: - webAppException = new WebApplicationException(message); - break; - default: - webAppException = new WebApplicationException(message); - } - throw webAppException; - } - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java deleted file mode 100644 index b15059e87b..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAICommonObjectMapperProvider.java +++ /dev/null @@ -1,49 +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.client.aai; - -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -@Provider -public class AAICommonObjectMapperProvider implements ContextResolver { - - final ObjectMapper mapper; - - public AAICommonObjectMapperProvider() { - mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - mapper.enable(MapperFeature.USE_ANNOTATIONS); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); - } - - @Override - public ObjectMapper getContext(Class type) { - return mapper; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java deleted file mode 100644 index f261408c83..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIQueryObjectMapperProvider.java +++ /dev/null @@ -1,47 +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.client.aai; - -import javax.ws.rs.ext.Provider; - -import com.fasterxml.jackson.databind.AnnotationIntrospector; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; -import com.fasterxml.jackson.databind.type.TypeFactory; -import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; - -@Provider -public class AAIQueryObjectMapperProvider extends AAICommonObjectMapperProvider { - - public AAIQueryObjectMapperProvider() { - super(); - AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()); - AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector(); - // first Jaxb, second Jackson annotations - mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson)); - - } - - @Override - public ObjectMapper getContext(Class type) { - return mapper; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java deleted file mode 100644 index a10225956b..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIResourcesObjectMapperProvider.java +++ /dev/null @@ -1,38 +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.client.aai; - -import javax.ws.rs.ext.Provider; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@Provider -public class AAIResourcesObjectMapperProvider extends AAICommonObjectMapperProvider { - - public AAIResourcesObjectMapperProvider() { - super(); - } - - @Override - public ObjectMapper getContext(Class type) { - return mapper; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java deleted file mode 100644 index 214be060e3..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClient.java +++ /dev/null @@ -1,40 +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.client.aai; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.List; - -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Pserver; -import org.onap.aai.domain.yang.Pservers; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -public interface AAIRestClient { - -Pservers getPhysicalServers(String hostName, String uuid); -List getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) throws UnsupportedEncodingException, JsonParseException, JsonMappingException, IOException; -void updateMaintenceFlag(String vnfId,boolean inMaint, String transactionLoggingUuid) throws JsonParseException, JsonMappingException, IOException; -void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws JsonParseException, JsonMappingException , IOException; -GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws JsonParseException, JsonMappingException , IOException; -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java deleted file mode 100644 index af1eddf491..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIRestClientImpl.java +++ /dev/null @@ -1,179 +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.client.aai; - -import java.io.File; -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import javax.net.ssl.SSLContext; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; - -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.GenericVnfs; -import org.onap.aai.domain.yang.Pserver; -import org.onap.aai.domain.yang.Pservers; -import org.openecomp.mso.bpmn.core.PropertyConfiguration; -import org.openecomp.mso.client.aai.entities.CustomQuery; -import org.openecomp.mso.client.aai.entities.Results; -import org.springframework.stereotype.Service; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -@Service -public class AAIRestClientImpl implements AAIRestClient { - - private final WebTarget webTarget; - - private static final String ENDPOINT_VERSION = "v10"; - private static final String ENDPOINT_GET_ALL = ENDPOINT_VERSION + "/cloud-infrastructure/pservers"; - private static final String ENDPOINT_GET_ALL_VNFS = ENDPOINT_VERSION + "/network/generic-vnfs"; - private static final String ENDPOINT_CUSTOM_QUERY = ENDPOINT_VERSION + "/query"; - private static final String PSERVER_VNF_QUERY = "pservers-fromVnf"; - private static final String GENERIC_VNF_PATH = ENDPOINT_VERSION + "/network/generic-vnfs/generic-vnf"; - private static final String SERVICE_TOPOLOGY_BY_SERVICE_INSTANCE_ID = "store(‘x’).union(__.in(‘subscribesTo’).has(‘aai-node-type’,’customer’).store(‘x’),__.out(‘uses’).has(‘aai-node-type’,’allotted-resource’).store(‘x’),__.in(‘hasInstance’).has(‘aai-node-type’,’generic-vnf’).store(‘x’).union(" - + ".out(‘has’).has(‘aai-node-type’,’vf-module’).store(‘x’),out(‘uses’).has(‘aai-node-type’,’volume-group’).store(‘x’)," - + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" - + ")," + ".out(‘runsOnVserver’).has(‘aai-node-type’,’vserver’).store(‘x’).union(" - + ".in(‘owns’).has(‘aai-node-type’,’tenant’).store(‘x’).in(‘has’).has(‘aai-node-type’,’cloud-region’).store(‘x’)," - + ".out(‘runsOnPserver’).has(‘aai-node-type’,’pserver’).store(‘x’)," - + ".out(‘hasLInterface’).has(‘aai-node-type’,’l-interface’).union(" - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv4-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)," - + ".out(‘hasIpAddress’).has(‘aai-node-type’,’l3-interface-ipv6-address’).store(‘x’).out(‘isMemberOf’).has(‘aai-node-type’,’l3-network’).store(‘x’)" - + ")" + ")" + ")" + ").cap(‘x’).unfold().dedup()"; - - public AAIRestClientImpl() throws NoSuchAlgorithmException { - - Logger logger = Logger.getLogger(getClass().getName()); - Map properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); - Client client = this.getSSLClient(); - webTarget = client.register(logger).register(new AAIClientResponseExceptionMapper()) - .target(properties.get("aai.endpoint") + "/aai"); - } - - public AAIRestClientImpl(final String host) throws NoSuchAlgorithmException { - Logger logger = Logger.getLogger(getClass().getName()); - Client client = this.getSSLClient(); - webTarget = client.register(logger).register(new AAIClientResponseExceptionMapper()).target(host + "/aai"); - } - - @Override - public Pservers getPhysicalServers(String hostName, String uuid) { - return webTarget.register(AAIResourcesObjectMapperProvider.class).path(ENDPOINT_GET_ALL).request() - .header("X-FromAppId", "MSO").header("X-TransactionId", uuid) - .header("Content-Type", MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE).get() - .readEntity(Pservers.class); - } - - @Override - public List getPhysicalServerByVnfId(String vnfId, String transactionLoggingUuid) - throws JsonParseException, JsonMappingException, IOException { - List startNodes = new ArrayList<>(); - startNodes.add("network/generic-vnfs/generic-vnf/" + vnfId); - String jsonInput = webTarget.register(AAIQueryObjectMapperProvider.class).path(ENDPOINT_CUSTOM_QUERY) - .queryParam("format", "resource").request().header("X-FromAppId", "MSO") - .header("X-TransactionId", transactionLoggingUuid) - .header("Content-Type", MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE) - .put(Entity.entity(new CustomQuery(startNodes, PSERVER_VNF_QUERY), MediaType.APPLICATION_JSON)) - .readEntity(String.class); - - - return this.getListOfPservers(jsonInput); - } - - protected List getListOfPservers(String jsonInput) throws JsonParseException, JsonMappingException, IOException - { - ObjectMapper mapper = new AAIQueryObjectMapperProvider().getContext(Object.class); - Results> resultsFromJson = mapper.readValue(jsonInput, - new TypeReference>>() { - }); - List results = new ArrayList<>(); - for (Map m : resultsFromJson.getResult()) { - results.add(m.get("pserver")); - } - return results; - } - - protected List getListOfPservers(File jsonInput) throws JsonParseException, JsonMappingException, IOException - { - ObjectMapper mapper = new AAIQueryObjectMapperProvider().getContext(Object.class); - Results> resultsFromJson = mapper.readValue(jsonInput, - new TypeReference>>() { - }); - List results = new ArrayList<>(); - for (Map m : resultsFromJson.getResult()) { - results.add(m.get("pserver")); - } - return results; - } - - @Override - public void updateMaintenceFlag(String vnfName, boolean inMaint, String transactionLoggingUuid) throws JsonParseException, JsonMappingException, IOException { - GenericVnfs genericVnfs = webTarget.register(AAIResourcesObjectMapperProvider.class).path(ENDPOINT_GET_ALL_VNFS) - .queryParam("vnf-name", vnfName).request().header("X-FromAppId", "MSO") - .header("X-TransactionId", transactionLoggingUuid).header("Content-Type", "application/json") - .accept(MediaType.APPLICATION_JSON_TYPE).get().readEntity(GenericVnfs.class); - - if (genericVnfs.getGenericVnf().size() > 1) - throw new IndexOutOfBoundsException ("Multiple Generic Vnfs Returned"); - - GenericVnf genericVnf = genericVnfs.getGenericVnf().get(0); - updateMaintenceFlagVnfId(genericVnf.getVnfId(), inMaint, transactionLoggingUuid); - } - - @Override - public void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) - throws JsonParseException, JsonMappingException, IOException { - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setInMaint(inMaint); - webTarget.register(AAIResourcesObjectMapperProvider.class).path(GENERIC_VNF_PATH + "/" + vnfId).request() - .header("X-FromAppId", "MSO").header("X-TransactionId", transactionLoggingUuid) - .header("Content-Type", "application/merge-patch+json") - .header("Accept", MediaType.APPLICATION_JSON_TYPE).header("X-HTTP-Method-Override", "PATCH") - .put(Entity.entity(genericVnf, MediaType.valueOf("application/merge-patch+json"))); - } - - @Override - public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws JsonParseException, JsonMappingException, IOException { - return webTarget.register(AAIResourcesObjectMapperProvider.class).path(GENERIC_VNF_PATH + "/" + vnfId).request() - .header("X-FromAppId", "MSO").header("X-TransactionId", transactionLoggingUuid) - .header("Content-Type", "application/json").accept(MediaType.APPLICATION_JSON_TYPE).get() - .readEntity(GenericVnf.class); - } - - protected Client getSSLClient() throws NoSuchAlgorithmException { - return ClientBuilder.newBuilder().sslContext(SSLContext.getDefault()).build(); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java deleted file mode 100644 index 3bdcdc56a3..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdator.java +++ /dev/null @@ -1,31 +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.client.aai; - -import java.io.IOException; - -public interface AAIUpdator { - - void updateVnfToLocked(String vnfName, String uuid) throws IOException, Exception; - - void updateVnfToUnLocked(String vnfName, String uuid) throws IOException, Exception; - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java deleted file mode 100644 index 575a65fa0f..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIUpdatorImpl.java +++ /dev/null @@ -1,49 +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.client.aai; - -import org.springframework.beans.factory.annotation.Autowired; - -public class AAIUpdatorImpl implements AAIUpdator { - - @Autowired - protected AAIRestClient client; - - public AAIRestClient getClient() { - return client; - } - - - public void setClient(AAIRestClient client) { - this.client = client; - } - - @Override - public void updateVnfToLocked(String vnfId, String uuid) throws Exception { - client.updateMaintenceFlagVnfId(vnfId, true, uuid); - } - - @Override - public void updateVnfToUnLocked(String vnfId, String uuid) throws Exception { - client.updateMaintenceFlagVnfId(vnfId, false, uuid); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java deleted file mode 100644 index 117ec42a36..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidator.java +++ /dev/null @@ -1,32 +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.client.aai; - -import java.io.IOException; - -public interface AAIValidator { - - boolean isPhysicalServerLocked(String hostName, String transactionLoggingUuid) throws IOException; - - boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws IOException, Exception; - - -} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java deleted file mode 100644 index ce248f010c..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/AAIValidatorImpl.java +++ /dev/null @@ -1,71 +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.client.aai; - -import java.io.IOException; -import java.util.List; - -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Pserver; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - - -@Service -public class AAIValidatorImpl implements AAIValidator { - - - @Autowired - protected AAIRestClient client; - - public AAIRestClient getClient() { - return client; - } - - - public void setClient(AAIRestClient client) { - this.client = client; - } - - @Override - public boolean isPhysicalServerLocked(String vnfId, String transactionLoggingUuid) throws IOException { - List pservers; - boolean isLocked = false; - pservers = client.getPhysicalServerByVnfId(vnfId, transactionLoggingUuid); - for (Pserver pserver : pservers) - if (pserver.isInMaint()) - isLocked = true; - - return isLocked; - } - - @Override - public boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws Exception { - boolean isLocked = false; - GenericVnf genericVnf = client.getVnfByName(vnfId, transactionLoggingUuid); - if (genericVnf.isInMaint()) - isLocked = true; - - return isLocked; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java deleted file mode 100644 index eb0fb48678..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIEntity.java +++ /dev/null @@ -1,25 +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.client.aai.entities; - -public class AAIEntity { - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java deleted file mode 100644 index 5f895ef862..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/AAIError.java +++ /dev/null @@ -1,46 +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.client.aai.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "requestError" -}) -public class AAIError { - - @JsonProperty("requestError") - private RequestError requestError; - - @JsonProperty("requestError") - public RequestError getRequestError() { - return requestError; - } - - @JsonProperty("requestError") - public void setRequestError(RequestError requestError) { - this.requestError = requestError; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java deleted file mode 100644 index fab8d64e09..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/CustomQuery.java +++ /dev/null @@ -1,68 +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.client.aai.entities; - -import java.io.UnsupportedEncodingException; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonInclude; - - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class CustomQuery { - - List start; - - public String getGremlin() { - return gremlin; - } - - public void setGremlin(String gremlin) { - this.gremlin = gremlin; - } - String query; - String gremlin; - - public CustomQuery(Liststart, String query){ - this.start=start; - this.query= "query/" + query; - } - - public CustomQuery(String gremlin) throws UnsupportedEncodingException{ - this.gremlin=gremlin; - } - - public List getStart() { - return start; - } - - public void setStart(List start) { - this.start = start; - } - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java deleted file mode 100644 index 2fd3572401..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/RequestError.java +++ /dev/null @@ -1,46 +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.client.aai.entities; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "serviceException" -}) -public class RequestError { - - @JsonProperty("serviceException") - private ServiceException serviceException; - - @JsonProperty("serviceException") - public ServiceException getServiceException() { - return serviceException; - } - - @JsonProperty("serviceException") - public void setServiceException(ServiceException serviceException) { - this.serviceException = serviceException; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java deleted file mode 100644 index aea223da56..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/Results.java +++ /dev/null @@ -1,53 +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.client.aai.entities; - -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; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "results" -}) -@XmlRootElement(name = "results") -public class Results { - - @XmlElement(name="results") - protected List result; - - public List getResult() { - if (result == null) { - result = new ArrayList<>(); - } - return this.result; - } - - public void setResult(List result) { - this.result=result; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java deleted file mode 100644 index 5ae1d5242b..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/aai/entities/ServiceException.java +++ /dev/null @@ -1,73 +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.client.aai.entities; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "messageId", - "text", - "variables" -}) -public class ServiceException { - - @JsonProperty("messageId") - private String messageId; - @JsonProperty("text") - private String text; - @JsonProperty("variables") - private List variables = null; - - @JsonProperty("messageId") - public String getMessageId() { - return messageId; - } - - @JsonProperty("messageId") - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - @JsonProperty("text") - public String getText() { - return text; - } - - @JsonProperty("text") - public void setText(String text) { - this.text = text; - } - - @JsonProperty("variables") - public List getVariables() { - return variables; - } - - @JsonProperty("variables") - public void setVariables(List variables) { - this.variables = variables; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.java new file mode 100644 index 0000000000..5e3aca5613 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClient.java @@ -0,0 +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.client.adapter.network; + +import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest; +import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse; +import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest; +import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse; +import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse; +import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest; +import org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse; +import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest; +import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse; + +public interface NetworkAdapterClient { + + CreateNetworkResponse createNetwork(CreateNetworkRequest req); + + DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req); + + RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req); + + QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId, String networkStackId, boolean skipAAI, String requestId, String serviceInstanceId); + + UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java new file mode 100644 index 0000000000..6a1c862a66 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientImpl.java @@ -0,0 +1,97 @@ +/*- + * ============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.client.adapter.network; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; + +import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest; +import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse; +import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest; +import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse; +import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse; +import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest; +import org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse; +import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest; +import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse; +import org.openecomp.mso.client.adapter.vnf.AdapterRestClient; + +public class NetworkAdapterClientImpl implements NetworkAdapterClient { + + private final NetworkAdapterRestProperties props; + public NetworkAdapterClientImpl() { + this.props = new NetworkAdapterRestProperties(); + } + @Override + public CreateNetworkResponse createNetwork(CreateNetworkRequest req) { + return new AdapterRestClient(this.props, this.getUri("").build()).post(req, + CreateNetworkResponse.class); + } + + @Override + public DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req) { + return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req, + DeleteNetworkResponse.class); + } + + @Override + public RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req) { + return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req, + RollbackNetworkResponse.class); + } + + @Override + public QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId, + String networkStackId, boolean skipAAI, String requestId, String serviceInstanceId) { + UriBuilder builder = this.getUri("/" + aaiNetworkId); + if (cloudSiteId != null) { + builder.queryParam("cloudSiteId", cloudSiteId); + } + if (tenantId != null) { + builder.queryParam("tenantId", tenantId); + } + if (networkStackId != null) { + builder.queryParam("networkStackId", networkStackId); + } + + builder.queryParam("skipAAI", skipAAI); + + if (requestId != null) { + builder.queryParam("msoRequest.requestId", requestId); + } + if (serviceInstanceId != null) { + builder.queryParam("msoRequest.serviceInstanceId", serviceInstanceId); + } + return new AdapterRestClient(this.props, builder.build(), MediaType.TEXT_XML, MediaType.TEXT_XML) + .get(QueryNetworkResponse.class); + } + + @Override + public UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req) { + return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).put(req, + UpdateNetworkResponse.class); + } + + protected UriBuilder getUri(String path) { + return UriBuilder.fromPath(path); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java new file mode 100644 index 0000000000..62d78d423c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/network/NetworkAdapterRestProperties.java @@ -0,0 +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.client.adapter.network; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Map; + +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.client.adapter.vnf.AdapterRestProperties; + +public class NetworkAdapterRestProperties implements AdapterRestProperties { + + private final Map props; + + public NetworkAdapterRestProperties() { + this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); + } + + @Override + public String getAuth() { + return props.get("mso.adapters.po.auth"); + } + @Override + public String getKey() { + return props.get("mso.msoKey"); + } + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(props.get("mso.adapters.network.rest.endpoint")); + } + + @Override + public String getSystemName() { + return "MSO"; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java new file mode 100644 index 0000000000..c3ba8e16ea --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapter.java @@ -0,0 +1,35 @@ +/*- + * ============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.client.adapter.requests.db; + +import org.openecomp.mso.client.adapter.requests.db.entities.MsoRequestsDbException; +import org.openecomp.mso.client.adapter.requests.db.entities.UpdateInfraRequest; +import org.openecomp.mso.requestsdb.InfraActiveRequests; + +public interface MsoRequestsDbAdapter { + + public void updateInfraRequest(UpdateInfraRequest request) throws MsoRequestsDbException; + + public InfraActiveRequests getInfraRequest(String requestId) throws MsoRequestsDbException; + + public boolean getSiteStatus(String siteName); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java new file mode 100644 index 0000000000..109da17ea2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.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.openecomp.mso.client.adapter.requests.db; + +import java.sql.Timestamp; + +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.openecomp.mso.client.adapter.requests.db.entities.MsoRequestsDbException; +import org.openecomp.mso.client.adapter.requests.db.entities.RequestStatusType; +import org.openecomp.mso.client.adapter.requests.db.entities.UpdateInfraRequest; +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.RequestsDbSessionFactoryManager; +import org.openecomp.mso.requestsdb.SiteStatus; +import org.openecomp.mso.utils.UUIDChecker; + +public class MsoRequestsDbAdapterClient implements MsoRequestsDbAdapter { + + protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager(); + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + @Override + public void updateInfraRequest(UpdateInfraRequest request) throws MsoRequestsDbException { + Session session = requestsDbSessionFactoryManager.getSessionFactory().openSession(); + int result = 0; + long startTime = System.currentTimeMillis(); + if (request.getRequestId() != null && request.getLastModifiedBy() != null) { + MsoLogger.setLogContext(request.getRequestId(), null); + try { + session.beginTransaction(); + String queryString = "update InfraActiveRequests set "; + String statusMessage = null; + String responseBody = null; + RequestStatusType requestStatus = null; + String progress = null; + String vnfOutputs = null; + String serviceInstanceId = null; + String networkId = null; + String vnfId = null; + String vfModuleId = null; + String volumeGroupId = null; + String serviceInstanceName = null; + String vfModuleName = null; + String configurationId = null; + String configurationName = null; + if (request.getStatusMessage() != null) { + queryString += "statusMessage = :statusMessage, "; + statusMessage = request.getStatusMessage(); + } + if (request.getResponseBody() != null) { + queryString += "responseBody = :responseBody, "; + responseBody = request.getResponseBody(); + } + if (request.getRequestStatus() != null) { + queryString += "requestStatus = :requestStatus, "; + requestStatus = request.getRequestStatus(); + } + if (request.getProgress() != null) { + queryString += "progress = :progress, "; + progress = request.getProgress(); + } + if (request.getVnfOutputs() != null) { + queryString += "vnfOutputs = :vnfOutputs, "; + vnfOutputs = request.getVnfOutputs(); + } + if (request.getServiceInstanceId() != null) { + queryString += "serviceInstanceId = :serviceInstanceId, "; + serviceInstanceId = request.getServiceInstanceId(); + } + if (request.getNetworkId() != null) { + queryString += "networkId = :networkId, "; + networkId = request.getNetworkId(); + } + if (request.getVnfId() != null) { + queryString += "vnfId = :vnfId, "; + vnfId = request.getVnfId(); + } + if (request.getVfModuleId() != null) { + queryString += "vfModuleId = :vfModuleId, "; + vfModuleId = request.getVfModuleId(); + } + if (request.getVolumeGroupId() != null) { + queryString += "volumeGroupId = :volumeGroupId, "; + volumeGroupId = request.getVolumeGroupId(); + } + if (request.getServiceInstanceName() != null) { + queryString += "serviceInstanceName = :serviceInstanceName, "; + serviceInstanceName = request.getServiceInstanceName(); + } + if (request.getVfModuleName() != null) { + queryString += "vfModuleName = :vfModuleName, "; + vfModuleName = request.getVfModuleName(); + } + if (request.getConfigurationId() != null) { + queryString += "configurationId = :configurationId, "; + configurationId = request.getConfigurationId(); + } + if (request.getConfigurationName() != null) { + queryString += "configurationName = :configurationName, "; + configurationName = request.getConfigurationName(); + } + if (request.getRequestStatus() == RequestStatusType.COMPLETE + || request.getRequestStatus() == RequestStatusType.FAILED) { + queryString += "endTime = :endTime, "; + } else { + queryString += "modifyTime = :modifyTime, "; + } + queryString += "lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId"; + + LOGGER.debug("Executing update: " + queryString); + + Query query = session.createQuery(queryString); + query.setParameter("requestId", request.getRequestId()); + if (statusMessage != null) { + query.setParameter("statusMessage", statusMessage); + LOGGER.debug("StatusMessage in updateInfraRequest is set to: " + statusMessage); + } + if (responseBody != null) { + query.setParameter("responseBody", responseBody); + LOGGER.debug("ResponseBody in updateInfraRequest is set to: " + responseBody); + } + if (requestStatus != null) { + query.setParameter("requestStatus", requestStatus.toString()); + LOGGER.debug("RequestStatus in updateInfraRequest is set to: " + requestStatus.toString()); + } + + if (progress != null) { + query.setParameter("progress", Long.parseLong(progress)); + LOGGER.debug("Progress in updateInfraRequest is set to: " + progress); + } + if (vnfOutputs != null) { + query.setParameter("vnfOutputs", vnfOutputs); + LOGGER.debug("VnfOutputs in updateInfraRequest is set to: " + vnfOutputs); + } + if (serviceInstanceId != null) { + query.setParameter("serviceInstanceId", serviceInstanceId); + LOGGER.debug("ServiceInstanceId in updateInfraRequest is set to: " + serviceInstanceId); + } + if (networkId != null) { + query.setParameter("networkId", networkId); + LOGGER.debug("NetworkId in updateInfraRequest is set to: " + networkId); + } + if (vnfId != null) { + query.setParameter("vnfId", vnfId); + LOGGER.debug("VnfId in updateInfraRequest is set to: " + vnfId); + } + if (vfModuleId != null) { + query.setParameter("vfModuleId", vfModuleId); + LOGGER.debug("vfModuleId in updateInfraRequest is set to: " + vfModuleId); + } + if (volumeGroupId != null) { + query.setParameter("volumeGroupId", volumeGroupId); + LOGGER.debug("VolumeGroupId in updateInfraRequest is set to: " + volumeGroupId); + } + if (serviceInstanceName != null) { + query.setParameter("serviceInstanceName", serviceInstanceName); + LOGGER.debug("ServiceInstanceName in updateInfraRequest is set to: " + serviceInstanceName); + } + if (configurationId != null) { + query.setParameter("configurationId", configurationId); + LOGGER.debug("configurationId in updateInfraRequest is set to: " + configurationId); + } + if (configurationName != null) { + query.setParameter("configurationName", configurationName); + LOGGER.debug("configurationName in updateInfraRequest is set to: " + configurationName); + } + if (vfModuleName != null) { + query.setParameter("vfModuleName", vfModuleName); + LOGGER.debug("vfModuleName in updateInfraRequest is set to: " + vfModuleName); + } + Timestamp nowTimeStamp = new Timestamp(System.currentTimeMillis()); + if (request.getRequestStatus() == RequestStatusType.COMPLETE + || request.getRequestStatus() == RequestStatusType.FAILED) { + query.setParameter("endTime", nowTimeStamp); + LOGGER.debug("EndTime in updateInfraRequest is set to: " + nowTimeStamp); + } else { + query.setParameter("modifyTime", nowTimeStamp); + LOGGER.debug("ModifyTime in updateInfraRequest is set to: " + nowTimeStamp); + } + query.setParameter("lastModifiedBy", request.getLastModifiedBy()); + LOGGER.debug("LastModifiedBy in updateInfraRequest is set to: " + request.getLastModifiedBy()); + result = query.executeUpdate(); + checkIfExists(result, request.getRequestId(), startTime); + session.getTransaction().commit(); + } catch (HibernateException e) { + String error = "Unable to update MSO Requests DB: " + e.getMessage(); + LOGGER.error(MessageEnum.RA_CANT_UPDATE_REQUEST, "infra request parameters", request.getRequestId(), "", + "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, + error); + throw new MsoRequestsDbException(error, e); + } finally { + if (session != null && session.isOpen()) { + session.close(); + } + } + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + } else { + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, + "Required fields: requestId and lastModifiedBy"); + } + } + + private void checkIfExists(int result, String requestId, long startTime) throws MsoRequestsDbException { + if (result == 0) { + String error = "Request ID does not exist in MSO Requests DB: " + requestId; + LOGGER.error(MessageEnum.RA_DB_REQUEST_NOT_EXIST, requestId, "", "", MsoLogger.ErrorCode.DataError, error); + throw new MsoRequestsDbException(error); + } + } + + @Override + public InfraActiveRequests getInfraRequest(String requestId) throws MsoRequestsDbException { + long startTime = System.currentTimeMillis(); + MsoLogger.setLogContext(requestId, null); + Session session = requestsDbSessionFactoryManager.getSessionFactory().openSession(); + + LOGGER.debug("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId); + + InfraActiveRequests request = null; + try { + session.beginTransaction(); + Query query = session.createQuery( + "FROM InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId"); + query.setParameter("requestId", requestId); + request = (InfraActiveRequests) query.uniqueResult(); + } catch (HibernateException e) { + String error = "Unable to retrieve MSO Infra Requests DB for Request ID " + requestId; + LOGGER.error(MessageEnum.RA_DB_REQUEST_NOT_EXIST, "Get Infra request", requestId, "", "", + MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e); + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error); + throw new MsoRequestsDbException(error, e); + } finally { + if (session != null && session.isOpen()) { + session.close(); + } + } + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return request; + } + + /** + * Get SiteStatus by SiteName. + * + * @param siteName + * The unique name of the site + * @return Status of that site + */ + public boolean getSiteStatus(String siteName) { + UUIDChecker.generateUUID(LOGGER); + Session session = requestsDbSessionFactoryManager.getSessionFactory().openSession(); + + long startTime = System.currentTimeMillis(); + SiteStatus siteStatus = null; + LOGGER.debug("Request database - get Site Status with Site name:" + siteName); + try { + String hql = "FROM SiteStatus WHERE siteName = :site_name"; + Query query = session.createQuery(hql); + query.setParameter("site_name", siteName); + + siteStatus = (SiteStatus) query.uniqueResult(); + } finally { + if (session != null && session.isOpen()) { + session.close(); + } + } + if (siteStatus == null) { + // if not exist in DB, it means the site is not disabled, thus + // return true + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return true; + } else { + LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return siteStatus.getStatus(); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java new file mode 100644 index 0000000000..a495d0eac1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbException.java @@ -0,0 +1,62 @@ +/*- + * ============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.client.adapter.requests.db.entities; + + + +import javax.xml.ws.WebFault; + +/** + * This class simply extends Exception (without addition additional functionality) + * to provide an identifier for RequestsDB related exceptions on create, delete, query. + * + * + */ +@WebFault (name="MsoRequestsDbException", faultBean="org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://org.openecomp.mso/requestsdb") +public class MsoRequestsDbException extends Exception { + + private static final long serialVersionUID = 1L; + + private MsoRequestsDbExceptionBean faultInfo; + + public MsoRequestsDbException (String msg) { + super(msg); + faultInfo = new MsoRequestsDbExceptionBean (msg); + } + + public MsoRequestsDbException (Throwable e) { + super(e); + faultInfo = new MsoRequestsDbExceptionBean (e.getMessage()); + } + + public MsoRequestsDbException (String msg, Throwable e) { + super (msg, e); + faultInfo = new MsoRequestsDbExceptionBean (msg); + } + + public MsoRequestsDbExceptionBean getFaultInfo() { + return faultInfo; + } + + public void setFaultInfo(MsoRequestsDbExceptionBean faultInfo) { + this.faultInfo = faultInfo; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.java new file mode 100644 index 0000000000..f566418ade --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBean.java @@ -0,0 +1,48 @@ +/*- + * ============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.client.adapter.requests.db.entities; + + +import java.io.Serializable; + +/** + * Jax-WS Fault Bean for MsoRequestsDB Exception + */ +public class MsoRequestsDbExceptionBean implements Serializable { + + private static final long serialVersionUID = 1360000062602372639L; + + private String message; + + public MsoRequestsDbExceptionBean () {} + + public MsoRequestsDbExceptionBean (String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java new file mode 100644 index 0000000000..2fa6f2b6a2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/RequestStatusType.java @@ -0,0 +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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.07.24 at 11:49:17 AM EDT +// + + +package org.openecomp.mso.client.adapter.requests.db.entities; + + + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for request-status-type. + * + *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <simpleType name="request-status-type">
+ *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ *     <enumeration value="COMPLETE"/>
+ *     <enumeration value="FAILED"/>
+ *     <enumeration value="IN_PROGRESS"/>
+ *   </restriction>
+ * </simpleType>
+ * 
+ * + */ +@XmlType(name = "request-status-type") +@XmlEnum +public enum RequestStatusType { + + COMPLETE, + FAILED, + IN_PROGRESS; + + public String value() { + return name(); + } + + public static RequestStatusType fromValue(String v) { + return valueOf(v); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java new file mode 100644 index 0000000000..cc00fd1ff2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/ResponseStatus.java @@ -0,0 +1,33 @@ +/*- + * ============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.client.adapter.requests.db.entities; + + + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum ResponseStatus { + SENDING_FINAL_NOTIFY, + SUCCESS, + FAILED, + TIMEOUT +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java new file mode 100644 index 0000000000..e9750a2b3b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/Status.java @@ -0,0 +1,40 @@ +/*- + * ============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.client.adapter.requests.db.entities; + + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum Status { + PENDING, INPROGRESS, COMPLETED, FAILED, TIMEOUT; + + public boolean isFinished () { + switch (this) { + case COMPLETED: + case FAILED: + case TIMEOUT: + return true; + default: + return false; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java new file mode 100644 index 0000000000..15c57253f3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequest.java @@ -0,0 +1,138 @@ +/*- + * ============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.client.adapter.requests.db.entities; + +public class UpdateInfraRequest { + + private String requestId; + private String lastModifiedBy; + private String statusMessage; + private String responseBody; + private RequestStatusType requestStatus; + private String progress; + private String vnfOutputs; + private String serviceInstanceId; + private String networkId; + private String vnfId; + private String vfModuleId; + private String volumeGroupId; + private String serviceInstanceName; + private String configurationId; + private String configurationName; + private String vfModuleName; + + public String getRequestId() { + return requestId; + } + public void setRequestId(String requestId) { + this.requestId = requestId; + } + public String getLastModifiedBy() { + return lastModifiedBy; + } + public void setLastModifiedBy(String lastModifiedBy) { + this.lastModifiedBy = lastModifiedBy; + } + public String getStatusMessage() { + return statusMessage; + } + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + public String getResponseBody() { + return responseBody; + } + public void setResponseBody(String responseBody) { + this.responseBody = responseBody; + } + public RequestStatusType getRequestStatus() { + return requestStatus; + } + public void setRequestStatus(RequestStatusType requestStatus) { + this.requestStatus = requestStatus; + } + public String getProgress() { + return progress; + } + public void setProgress(String progress) { + this.progress = progress; + } + public String getVnfOutputs() { + return vnfOutputs; + } + public void setVnfOutputs(String vnfOutputs) { + this.vnfOutputs = vnfOutputs; + } + public String getServiceInstanceId() { + return serviceInstanceId; + } + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + public String getNetworkId() { + return networkId; + } + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + public String getVnfId() { + return vnfId; + } + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + public String getVfModuleId() { + return vfModuleId; + } + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + public String getVolumeGroupId() { + return volumeGroupId; + } + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + public String getServiceInstanceName() { + return serviceInstanceName; + } + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + public String getConfigurationId() { + return configurationId; + } + public void setConfigurationId(String configurationId) { + this.configurationId = configurationId; + } + public String getConfigurationName() { + return configurationName; + } + public void setConfigurationName(String configurationName) { + this.configurationName = configurationName; + } + public String getVfModuleName() { + return vfModuleName; + } + public void setVfModuleName(String vfModuleName) { + this.vfModuleName = vfModuleName; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.java new file mode 100644 index 0000000000..3e315a5f04 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestClient.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.openecomp.mso.client.adapter.vnf; + +import java.net.URI; +import java.security.GeneralSecurityException; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; + +import javax.ws.rs.client.ClientResponseFilter; +import javax.ws.rs.ext.ContextResolver; + +import org.apache.commons.codec.binary.Base64; +import org.openecomp.mso.bpmn.common.util.CryptoUtils; +import org.openecomp.mso.client.ResponseExceptionMapperImpl; +import org.openecomp.mso.client.policy.JettisonStyleMapperProvider; +import org.openecomp.mso.client.policy.RestClient; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class AdapterRestClient extends RestClient { + + private final AdapterRestProperties props; + public AdapterRestClient(AdapterRestProperties props, URI uri) { + super(props, UUID.randomUUID(), Optional.of(uri)); + this.props = props; + } + + public AdapterRestClient(AdapterRestProperties props, URI uri, String accept, String contentType) { + super(props, UUID.randomUUID(), Optional.of(uri), accept, contentType); + this.props = props; + } + + @Override + protected void initializeHeaderMap(Map headerMap) { + headerMap.put("Authorization", + this.getBasicAuth(props.getAuth(), props.getKey())); + } + + @Override + protected Optional addResponseFilter() { + return Optional.of(new ResponseExceptionMapperImpl()); + } + + @Override + public RestClient addRequestId(UUID requestId) { + return null; + } + + @Override + protected ContextResolver getMapper() { + return new JettisonStyleMapperProvider(); + } + + private String getBasicAuth(String encryptedAuth, String msoKey) { + if ((encryptedAuth == null || encryptedAuth.isEmpty()) || (msoKey == null || msoKey.isEmpty())) { + return null; + } + try { + String auth = CryptoUtils.decrypt(encryptedAuth, msoKey); + byte[] encoded = Base64.encodeBase64(auth.getBytes()); + String encodedString = new String(encoded); + encodedString = "Basic " + encodedString; + return encodedString; + } catch (GeneralSecurityException e) { + this.logger.warn(e.getMessage(), e); + return null; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java new file mode 100644 index 0000000000..af429db1f2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/AdapterRestProperties.java @@ -0,0 +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========================================================= + */ + +package org.openecomp.mso.client.adapter.vnf; + +import org.openecomp.mso.client.RestProperties; + +public interface AdapterRestProperties extends RestProperties { + + public String getAuth(); + public String getKey(); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.java new file mode 100644 index 0000000000..5ee38fe0fb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClient.java @@ -0,0 +1,48 @@ +/*- + * ============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.client.adapter.vnf; + +import org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest; +import org.openecomp.mso.adapters.vnfrest.CreateVfModuleResponse; +import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest; +import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleResponse; +import org.openecomp.mso.adapters.vnfrest.QueryVfModuleResponse; +import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest; +import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleResponse; +import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest; +import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleResponse; + +public interface VnfAdapterClient { + + CreateVfModuleResponse createVfModule(String aaiVnfId, CreateVfModuleRequest req); + + RollbackVfModuleResponse rollbackVfModule(String aaiVnfId, String aaiVfModuleId, RollbackVfModuleRequest req); + + DeleteVfModuleResponse deleteVfModule(String aaiVnfId, String aaiVfModuleId, DeleteVfModuleRequest req); + + UpdateVfModuleResponse updateVfModule(String aaiVnfId, String aaiVfModuleId, UpdateVfModuleRequest req); + + QueryVfModuleResponse queryVfModule(String aaiVnfId, String aaiVfModuleId, String cloudSiteId, String tenantId, + String vfModuleName, boolean skipAAI, String requestId, String serviceInstanceId); + + String healthCheck(); + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java new file mode 100644 index 0000000000..2b391d302d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientImpl.java @@ -0,0 +1,106 @@ +/*- + * ============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.client.adapter.vnf; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; + +import org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest; +import org.openecomp.mso.adapters.vnfrest.CreateVfModuleResponse; +import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest; +import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleResponse; +import org.openecomp.mso.adapters.vnfrest.QueryVfModuleResponse; +import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest; +import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleResponse; +import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest; +import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleResponse; + +public class VnfAdapterClientImpl implements VnfAdapterClient { + + private static final String VF_MODULES = "/vf-modules/"; + + private final VnfAdapterRestProperties props; + public VnfAdapterClientImpl() { + this.props = new VnfAdapterRestProperties(); + } + + @Override + public CreateVfModuleResponse createVfModule(String aaiVnfId, CreateVfModuleRequest req) { + return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + "/vf-modules").build()).post(req, + CreateVfModuleResponse.class); + } + + @Override + public RollbackVfModuleResponse rollbackVfModule(String aaiVnfId, String aaiVfModuleId, + RollbackVfModuleRequest req) { + return new AdapterRestClient(this.props, + this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId + "/rollback").build()).delete(req, + RollbackVfModuleResponse.class); + } + + @Override + public DeleteVfModuleResponse deleteVfModule(String aaiVnfId, String aaiVfModuleId, DeleteVfModuleRequest req) { + return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build()) + .delete(req, DeleteVfModuleResponse.class); + } + + @Override + public UpdateVfModuleResponse updateVfModule(String aaiVnfId, String aaiVfModuleId, UpdateVfModuleRequest req) { + return new AdapterRestClient(this.props, this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId).build()) + .put(req, UpdateVfModuleResponse.class); + } + + @Override + public QueryVfModuleResponse queryVfModule(String aaiVnfId, String aaiVfModuleId, String cloudSiteId, + String tenantId, String vfModuleName, boolean skipAAI, String requestId, String serviceInstanceId) { + UriBuilder builder = this.getUri("/" + aaiVnfId + VF_MODULES + aaiVfModuleId); + if (cloudSiteId != null) { + builder.queryParam("cloudSiteId", cloudSiteId); + } + if (tenantId != null) { + builder.queryParam("tenantId", tenantId); + } + if (vfModuleName != null) { + builder.queryParam("vfModuleName", vfModuleName); + } + + builder.queryParam("skipAAI", skipAAI); + + if (requestId != null) { + builder.queryParam("msoRequest.requestId", requestId); + } + if (serviceInstanceId != null) { + builder.queryParam("msoRequest.serviceInstanceId", serviceInstanceId); + } + return new AdapterRestClient(this.props, builder.build(), MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON) + .get(QueryVfModuleResponse.class); + } + + @Override + public String healthCheck() { + return new AdapterRestClient(this.props, this.getUri("/healthcheck").build()).get(String.class); + } + + public UriBuilder getUri(String path) { + return UriBuilder.fromPath(path); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java new file mode 100644 index 0000000000..e342aeedac --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterRestProperties.java @@ -0,0 +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.client.adapter.vnf; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Map; + +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.client.adapter.vnf.AdapterRestProperties; + +public class VnfAdapterRestProperties implements AdapterRestProperties { + + private final Map props; + + public VnfAdapterRestProperties() { + this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); + } + + @Override + public String getAuth() { + return props.get("mso.adapters.po.auth"); + } + @Override + public String getKey() { + return props.get("mso.msoKey"); + } + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(props.get("mso.adapters.vnf.rest.endpoint")); + } + + @Override + public String getSystemName() { + return "MSO"; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java new file mode 100644 index 0000000000..8b870889ac --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java @@ -0,0 +1,178 @@ +/*- + * ============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.client.appc; + +import java.util.HashMap; +import java.util.List; + +import org.openecomp.mso.client.appc.ApplicationControllerSupport.StatusCategory; +import org.openecomp.mso.bpmn.appc.payload.PayloadClient; +import org.openecomp.mso.bpmn.core.json.JsonUtils; +import org.openecomp.mso.client.appc.ApplicationControllerOrchestrator; +import java.util.Optional; +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.Status; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.att.eelf.configuration.EELFLogger.Level; +import java.lang.NoSuchMethodError; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + + +public class ApplicationControllerAction { + protected ApplicationControllerOrchestrator client = new ApplicationControllerOrchestrator(); + private String errorCode = "1002"; + private String errorMessage = "Unable to reach App C Servers"; + protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + public void runAppCCommand(Action action, String msoRequestId, String vnfId, Optional payload, HashMap payloadInfo){ + Status appCStatus = null; + try{ + String vnfName = payloadInfo.getOrDefault("vnfName", ""); + String aicIdentity = payloadInfo.getOrDefault("vnfName",""); + String vnfHostIpAddress = payloadInfo.getOrDefault("vnfHostIpAddress",""); + String vmIdList = payloadInfo.getOrDefault("vmIdList", ""); + String identityUrl = payloadInfo.getOrDefault("identityUrl", ""); + switch(action){ + case ResumeTraffic: + appCStatus = resumeTrafficAction(msoRequestId, vnfId, vnfName); + break; + case Start: + case Stop: + appCStatus = startStopAction(action, msoRequestId, vnfId, aicIdentity); + break; + case Unlock: + case Lock: + appCStatus = client.vnfCommand(action, msoRequestId, vnfId, Optional.empty()); + break; + case QuiesceTraffic: + appCStatus = quiesceTrafficAction(msoRequestId, vnfId, payload, vnfName); + break; + case HealthCheck: + appCStatus = healthCheckAction(msoRequestId, vnfId, vnfName, vnfHostIpAddress); + break; + case Snapshot: + String vmIds = JsonUtils.getJsonValue(vmIdList, "vmIds"); + String vmId = ""; + ObjectMapper mapper = new ObjectMapper(); + List vmIdJsonList = mapper.readValue(vmIds, new TypeReference>(){}); + int i = 0; + while(i < vmIdJsonList.size()){ + vmId = vmIdJsonList.get(i); + appCStatus = snapshotAction(msoRequestId, vnfId, vmId, identityUrl); + i++; + } + break; + case ConfigModify: + appCStatus = payloadAction(action, msoRequestId, vnfId, payload); + break; + case UpgradePreCheck: + case UpgradePostCheck: + case UpgradeSoftware: + case UpgradeBackup: + appCStatus = upgradeAction(action,msoRequestId, vnfId, payload, vnfName); + break; + default: + errorMessage = "Unable to idenify Action request for AppCClient"; + break; + } + if(appCStatus != null){ + errorCode = Integer.toString(appCStatus.getCode()); + errorMessage = appCStatus.getMessage(); + + } + if(ApplicationControllerSupport.getCategoryOf(appCStatus).equals(StatusCategory.NORMAL)){ + errorCode = "0"; + } + } + catch(JsonProcessingException e){ + auditLogger.log(Level.ERROR, "Incorrect Payload format for action request" + action.toString(),e, e.getMessage()); + errorMessage = e.getMessage(); + } + catch(ApplicationControllerOrchestratorException e){ + auditLogger.log(Level.ERROR, "Error building Appc request: ", e, e.getMessage()); + errorCode = "1002"; + errorMessage = e.getMessage(); + } + catch (NoSuchMethodError e) { + auditLogger.log(Level.ERROR, "Error building Appc request: ", e, e.getMessage()); + errorMessage = e.getMessage(); + } + catch(Exception e){ + auditLogger.log(Level.ERROR, "Error building Appc request: ", e, e.getMessage()); + errorMessage = e.getMessage(); + } + } + + private Status payloadAction(Action action, String msoRequestId, String vnfId, Optional payload) throws JsonProcessingException, Exception{ + if(!(payload.isPresent())){ + throw new IllegalArgumentException("Payload is not present for " + action.toString()); + } + return client.vnfCommand(action, msoRequestId, vnfId, payload); + } + + private Status quiesceTrafficAction(String msoRequestId, String vnfId, Optional payload, String vnfName) throws JsonProcessingException, Exception{ + if(!(payload.isPresent())){ + throw new IllegalArgumentException("Payload is not present for " + Action.QuiesceTraffic.toString()); + } + payload = PayloadClient.quiesceTrafficFormat(payload, vnfName); + return client.vnfCommand(Action.QuiesceTraffic, msoRequestId, vnfId, payload); + } + + private Status upgradeAction(Action action, String msoRequestId, String vnfId, Optional payload, String vnfName) throws JsonProcessingException, Exception{ + if(!(payload.isPresent())){ + throw new IllegalArgumentException("Payload is not present for " + action.toString()); + } + payload = PayloadClient.upgradeFormat(payload, vnfName); + return client.vnfCommand(action, msoRequestId, vnfId, payload); + } + + private Status resumeTrafficAction(String msoRequestId, String vnfId, String vnfName)throws JsonProcessingException, Exception{ + Optional payload = PayloadClient.resumeTrafficFormat(vnfName); + return client.vnfCommand(Action.ResumeTraffic, msoRequestId, vnfId, payload); + } + + private Status startStopAction(Action action, String msoRequestId, String vnfId, String aicIdentity)throws JsonProcessingException, Exception{ + Optional payload = PayloadClient.startStopFormat(aicIdentity); + return client.vnfCommand(action, msoRequestId, vnfId, payload); + } + + private Status healthCheckAction(String msoRequestId, String vnfId, String vnfName, String vnfHostIpAddress)throws JsonProcessingException, Exception{ + Optional payload = PayloadClient.healthCheckFormat(vnfName, vnfHostIpAddress); + return client.vnfCommand(Action.HealthCheck, msoRequestId, vnfId, payload); + } + + private Status snapshotAction(String msoRequestId, String vnfId, String vmId, String identityUrl) throws JsonProcessingException, Exception{ + Optional payload = PayloadClient.snapshotFormat(vmId, identityUrl); + return client.vnfCommand(Action.Snapshot, msoRequestId, vnfId, payload); + } + + public String getErrorMessage(){ + return errorMessage; + } + + public String getErrorCode(){ + return errorCode; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java index c84e5903c5..1bb4dc7eed 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerCallback.java @@ -19,8 +19,9 @@ */ package org.openecomp.mso.client.appc; -import org.openecomp.appc.client.lcm.api.ResponseHandler; -import org.openecomp.appc.client.lcm.exceptions.AppcClientException; + +import org.onap.appc.client.lcm.api.ResponseHandler; +import org.onap.appc.client.lcm.exceptions.AppcClientException; public class ApplicationControllerCallback implements ResponseHandler { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java index f66034f5e9..c383408488 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java @@ -20,88 +20,79 @@ package org.openecomp.mso.client.appc; -import java.beans.BeanInfo; - -import java.util.Map; - -import org.openecomp.mso.bpmn.core.PropertyConfiguration; - -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.time.Instant; +import java.util.Map; import java.util.Properties; import java.util.UUID; +import org.openecomp.mso.bpmn.core.PropertyConfiguration; import org.springframework.beans.factory.annotation.Autowired; -import org.openecomp.appc.client.lcm.api.AppcClientServiceFactoryProvider; -import org.openecomp.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; -import org.openecomp.appc.client.lcm.api.ApplicationContext; -import org.openecomp.appc.client.lcm.api.LifeCycleManagerStateful; -import org.openecomp.appc.client.lcm.api.ResponseHandler; -import org.openecomp.appc.client.lcm.exceptions.AppcClientException; -import org.openecomp.appc.client.lcm.model.Action; -import org.openecomp.appc.client.lcm.model.ActionIdentifiers; -import org.openecomp.appc.client.lcm.model.AuditOutput; -import org.openecomp.appc.client.lcm.model.CommonHeader; -import org.openecomp.appc.client.lcm.model.Flags; -import org.openecomp.appc.client.lcm.model.Flags.Force; -import org.openecomp.appc.client.lcm.model.Flags.Mode; -import org.openecomp.appc.client.lcm.model.Payload; -import org.openecomp.appc.client.lcm.model.Status; -import org.openecomp.appc.client.lcm.model.ZULU; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.ObjectWriter; -import org.openecomp.mso.logger.MsoLogger; +import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider; +import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; +import org.onap.appc.client.lcm.api.ApplicationContext; +import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.ActionIdentifiers; +import org.onap.appc.client.lcm.model.CommonHeader; +import org.onap.appc.client.lcm.model.Flags; +import org.onap.appc.client.lcm.model.Flags.Force; +import org.onap.appc.client.lcm.model.Flags.Mode; +import org.onap.appc.client.lcm.model.Payload; +import org.onap.appc.client.lcm.model.Status; +import org.onap.appc.client.lcm.model.ZULU; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFLogger.Level; +import com.att.eelf.configuration.EELFManager; public class ApplicationControllerClient { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - - private static final int PARTIAL_SERIES = 500; + private static final String CLIENT_NAME = "MSO"; - private final String apiVer = "2.00"; - private final String originatorId = "MSO"; - private final int flagsTTL = 65000; - private final static String clientName = "MSO"; + private static final String API_VER = "2.00"; + private static final String ORIGINATOR_ID = "MSO"; + private static final int FLAGS_TTL = 65000; + protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); @Autowired public ApplicationControllerSupport appCSupport; - private LifeCycleManagerStateful client; + private static LifeCycleManagerStateful client; - public Status runCommand(Action action, ActionIdentifiers identifier, Flags flags, Payload payload, - String requestID) throws IllegalAccessException,NoSuchMethodException,AppcClientException,JsonProcessingException,InvocationTargetException { - Object requestObject = createRequest(action, identifier, flags, payload, requestID); - client = getAppCClient(); - Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false); - appCSupport.logLCMMessage(requestObject); - Object response = lcmMethod.invoke(client, requestObject); - return appCSupport.getStatusFromGenericResponse(response); + public ApplicationControllerClient() { + appCSupport = new ApplicationControllerSupport(); + client = this.getAppCClient(); } - public void shutdownclient() { - AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) - .shutdownLifeCycleManager(false); + public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, org.onap.appc.client.lcm.model.Payload payload, String requestID) + throws ApplicationControllerOrchestratorException { + Object requestObject; + requestObject = createRequest(action, actionIdentifiers, payload, requestID); + appCSupport.logLCMMessage(requestObject); + Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false); + try { + Object response = lcmMethod.invoke(client, requestObject); + return appCSupport.getStatusFromGenericResponse(response); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e); + } } - public LifeCycleManagerStateful getAppCClient() throws AppcClientException { + public LifeCycleManagerStateful getAppCClient() { if (client == null) - client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) - .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties()); + try { + client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) + .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties()); + } catch (AppcClientException e) { + auditLogger.log(Level.ERROR, "Error in getting LifeCycleManagerStateful: ", e, e.getMessage()); + } return client; } - private Properties getLCMProperties() { - return getLCMPropertiesHelper(); - } - - protected Properties getLCMPropertiesHelper() { + protected Properties getLCMProperties() { Properties properties = new Properties(); Map globalProperties = PropertyConfiguration.getInstance() .getProperties("mso.bpmn.urn.properties"); @@ -110,44 +101,46 @@ public class ApplicationControllerClient { properties.put("topic.read.timeout", globalProperties.get("appc.topic.read.timeout")); properties.put("client.response.timeout", globalProperties.get("appc.client.response.timeout")); properties.put("topic.write", globalProperties.get("appc.topic.write")); - properties.put("poolMembers", globalProperties.get("appc.pool.members")); + properties.put("poolMembers", globalProperties.get("appc.poolMembers")); properties.put("client.key", globalProperties.get("appc.client.key")); properties.put("client.secret", globalProperties.get("appc.client.secret")); - properties.put("client.name", clientName); + properties.put("client.name", CLIENT_NAME); + properties.put("service", globalProperties.get("appc.service")); return properties; } - public Object createRequest(Action action, ActionIdentifiers identifier, Flags flags, Payload payload, - String requestId) throws IllegalAccessException,NoSuchMethodException,InvocationTargetException { + public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { Object requestObject = appCSupport.getInput(action.name()); try { - org.openecomp.appc.client.lcm.model.CommonHeader commonHeader = buildCommonHeader(requestId); + CommonHeader commonHeader = buildCommonHeader(requestId); requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, commonHeader); requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class) .invoke(requestObject, identifier); + if (payload != null) { + requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload); + } } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { - LOGGER.debug("Exception:", e); - throw new IllegalAccessException("Error Building AppC Request: " + e.getMessage()); + auditLogger.log(Level.ERROR, "Error building Appc request: ", e, e.getMessage()); } return requestObject; } - private org.openecomp.appc.client.lcm.model.CommonHeader buildCommonHeader(String requestId) { - org.openecomp.appc.client.lcm.model.CommonHeader commonHeader = new org.openecomp.appc.client.lcm.model.CommonHeader(); - commonHeader.setApiVer(apiVer); - commonHeader.setOriginatorId(originatorId); + private CommonHeader buildCommonHeader(String requestId) { + CommonHeader commonHeader = new CommonHeader(); + commonHeader.setApiVer(API_VER); + commonHeader.setOriginatorId(ORIGINATOR_ID); commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); commonHeader.setSubRequestId(requestId); - org.openecomp.appc.client.lcm.model.Flags flags = new org.openecomp.appc.client.lcm.model.Flags(); + Flags flags = new Flags(); String flagsMode = "NORMAL"; Mode mode = Mode.valueOf(flagsMode); flags.setMode(mode); String flagsForce = "FALSE"; Force force = Force.valueOf(flagsForce); flags.setForce(force); - flags.setTtl(flagsTTL); + flags.setTtl(FLAGS_TTL); commonHeader.setFlags(flags); Instant timestamp = Instant.now(); ZULU zulu = new ZULU(timestamp.toString()); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java new file mode 100644 index 0000000000..217525e56a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java @@ -0,0 +1,50 @@ +/*- + * ============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.client.appc; + +import java.util.Optional; + +import org.openecomp.mso.client.appc.ApplicationControllerSupport.StatusCategory; + +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.ActionIdentifiers; +import org.onap.appc.client.lcm.model.Payload; +import org.onap.appc.client.lcm.model.Status; + +public class ApplicationControllerOrchestrator { + + public Status vnfCommand(Action action, String requestId, String vnfId, Optional request) throws ApplicationControllerOrchestratorException { + ApplicationControllerClient client = new ApplicationControllerClient(); + Status status; + ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); + actionIdentifiers.setVnfId(vnfId); + Payload payload = null; + if (request.isPresent()) { + payload = new Payload(request.get()); + } + status = client.runCommand(action, actionIdentifiers, payload, requestId); + if (ApplicationControllerSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) { + throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode()); + } else { + return status; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorException.java new file mode 100644 index 0000000000..4692f1dcc2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorException.java @@ -0,0 +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.client.appc; + +public class ApplicationControllerOrchestratorException extends Exception { + + private final int appcCode; + + public ApplicationControllerOrchestratorException(String message, int code) { + super(message); + appcCode = code; + } + + public int getAppcCode() + { + return appcCode; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java index f7db52b1c0..e3ed432dfc 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerSupport.java @@ -20,35 +20,26 @@ package org.openecomp.mso.client.appc; - import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.Properties; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PropertiesLoaderUtils; import org.springframework.stereotype.Component; -import org.openecomp.appc.client.lcm.api.AppcClientServiceFactoryProvider; -import org.openecomp.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; -import org.openecomp.appc.client.lcm.api.ApplicationContext; -import org.openecomp.appc.client.lcm.api.LifeCycleManagerStateful; -import org.openecomp.appc.client.lcm.api.ResponseHandler; -import org.openecomp.appc.client.lcm.exceptions.AppcClientException; -import org.openecomp.appc.client.lcm.model.Status; +import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; +import org.onap.appc.client.lcm.api.ResponseHandler; +import org.onap.appc.client.lcm.model.Status; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.att.eelf.configuration.EELFLogger.Level; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; - @Component public class ApplicationControllerSupport { @@ -61,14 +52,8 @@ public class ApplicationControllerSupport { private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES; private static final int PARTIAL_FAILURE_STATUS = PARTIAL_SERIES + 1; - @Value("${lcm.model.package:org.openecomp.appc.client.lcm.model}") - private String lcmModelPackage; - - public LifeCycleManagerStateful createService() throws AppcClientException, IOException { - AppcLifeCycleManagerServiceFactory factory = AppcClientServiceFactoryProvider - .getFactory(AppcLifeCycleManagerServiceFactory.class); - return factory.createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties()); - } + protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + private String lcmModelPackage = "org.onap.appc.client.lcm.model"; /** * @param action @@ -114,26 +99,18 @@ public class ApplicationControllerSupport { "Unable to derive viable LCM Kit API method for action", action, async)); } - public Method getCommonHeaderSetterMethod(String action) { - return getBeanPropertyMethodFor(getInputClass(action), "commonHeader", true); - } - - public Method getPayloadSetterMethod(String action) { - return getBeanPropertyMethodFor(getInputClass(action), "payload", true); - } - public Status getStatusFromGenericResponse(Object response) { Method statusReader = getBeanPropertyMethodFor(response.getClass(), "status", false); if (statusReader != null) { try { return (Status) statusReader.invoke(response); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException("Unable to obtain status from LCM Kit response", e); + auditLogger.log(Level.ERROR, "Unable to obtain status from LCM Kit response", e, e.getMessage()); } } return new Status(); } - + public static StatusCategory getCategoryOf(Status status) { int codeSeries = status.getCode() - (status.getCode() % 100); switch (codeSeries) { @@ -157,7 +134,7 @@ public class ApplicationControllerSupport { return StatusCategory.WARNING; } } - + public static boolean getFinalityOf(Status status) { int codeSeries = status.getCode() - (status.getCode() % 100); switch (codeSeries) { @@ -173,16 +150,6 @@ public class ApplicationControllerSupport { } } - /** - * @return - * @throws IOException - */ - private Properties getLCMProperties() throws IOException { - Resource resource = new ClassPathResource("/lcm.properties"); - Properties properties = PropertiesLoaderUtils.loadProperties(resource); - return properties; - } - private Method getBeanPropertyMethodFor(Class clazz, String propertyName, boolean isWriter) { BeanInfo beanInfo; try { @@ -213,34 +180,36 @@ public class ApplicationControllerSupport { try { return Class.forName(lcmModelPackage + '.' + action + "Input"); } catch (ClassNotFoundException e) { - throw new RuntimeException(String.format("%s : %s using package : ", + throw new RuntimeException(String.format("%s : %s using package : %s", "Unable to identify viable LCM Kit input class for action", action, lcmModelPackage), e); } } - - public static enum StatusCategory { - NORMAL("normal"), - WARNING("warning"), - ERROR("error"); - - private final String category; - - private StatusCategory(final String category) { - this.category = category; - } - - @Override - public String toString() { - return category; - } + + public enum StatusCategory { + NORMAL("normal"), WARNING("warning"), ERROR("error"); + + private final String category; + + private StatusCategory(final String category) { + this.category = category; + } + + @Override + public String toString() { + return category; + } } - - public void logLCMMessage(Object message) throws JsonProcessingException { + + public void logLCMMessage(Object message) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(Include.NON_NULL); ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter(); - String inputAsJSON = writer.writeValueAsString(message); - System.out.println("LCM Kit input message follows."); - System.out.println(inputAsJSON); + String inputAsJSON; + try { + inputAsJSON = writer.writeValueAsString(message); + auditLogger.log(Level.INFO, "\nLCM Kit input message follows: \n" + inputAsJSON, null); + } catch (JsonProcessingException e) { + auditLogger.log(Level.ERROR, "Error in logging LCM Message: ", e, e.getMessage()); + } } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java deleted file mode 100644 index 0e00ae5da8..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Consumer.java +++ /dev/null @@ -1,26 +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.client.dmaap; - -public interface Consumer { - - public Iterable fetch(); -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DefaultDmaapPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DefaultDmaapPropertiesImpl.java deleted file mode 100644 index 9af1fd3f7e..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DefaultDmaapPropertiesImpl.java +++ /dev/null @@ -1,38 +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.client.dmaap; - -import java.util.Map; - -import org.openecomp.mso.bpmn.core.PropertyConfiguration; - -public class DefaultDmaapPropertiesImpl implements DmaapProperties { - - private final Map properties; - public DefaultDmaapPropertiesImpl() { - this.properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); - } - @Override - public Map getProperties() { - return this.properties; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java deleted file mode 100644 index 7862c9d41d..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapClient.java +++ /dev/null @@ -1,68 +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.client.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Base64; -import java.util.Map; -import java.util.Properties; - -import org.openecomp.mso.bpmn.core.PropertyConfiguration; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public abstract class DmaapClient { - - protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - protected final Map msoProperties; - protected final Properties properties; - public DmaapClient(String filepath) throws FileNotFoundException, IOException { - Resource resource = new ClassPathResource(filepath); - DmaapProperties dmaapProperties = DmaapPropertiesLoader.getInstance().getImpl(); - if (dmaapProperties == null) { - dmaapProperties = new DefaultDmaapPropertiesImpl(); - } - this.msoProperties = dmaapProperties.getProperties(); - this.properties = new Properties(); - this.properties.load(resource.getInputStream()); - this.properties.put("password", this.deobfuscatePassword(this.getPassword())); - this.properties.put("username", this.getUserName()); - this.properties.put("topic", this.getTopic()); - } - protected String deobfuscatePassword(String password) { - - try { - return new String(Base64.getDecoder().decode(password.getBytes())); - } catch(IllegalArgumentException iae) { - - return password; - } - } - - - public abstract String getUserName(); - public abstract String getPassword(); - public abstract String getTopic(); -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java deleted file mode 100644 index 033951612d..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapConsumer.java +++ /dev/null @@ -1,131 +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.client.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.concurrent.TimeUnit; - -import org.openecomp.mso.client.dmaap.exceptions.DMaaPConsumerFailure; -import org.openecomp.mso.client.dmaap.exceptions.ExceededMaximumPollingTime; -import org.openecomp.mso.client.dmaap.rest.RestConsumer; - -import com.google.common.base.Stopwatch; - -public abstract class DmaapConsumer extends DmaapClient { - - public DmaapConsumer() throws FileNotFoundException, IOException { - super("dmaap/default-consumer.properties"); - } - - public Consumer getConsumer() throws FileNotFoundException, IOException { - return new RestConsumer(this.properties); - } - public boolean consume() throws Exception { - - Consumer mrConsumer = this.getConsumer(); - int iterations = 0; - boolean accepted = false; - Stopwatch stopwatch = Stopwatch.createUnstarted(); - try { - while (this.continuePolling()) { - if (stopwatch.elapsed(TimeUnit.MILLISECONDS) >= this.getMaximumElapsedTime()) { - final String message = "exceeded maximum retries on " + this.getRequestId() + " on " + this.getTopic(); - auditLogger.error(message); - throw new ExceededMaximumPollingTime(message); - } - stopwatch.start(); - Iterable itr = mrConsumer.fetch(); - stopwatch.stop(); - for (String message : itr) { - if (!accepted && this.isAccepted(message)) { - auditLogger.info("accepted message found for " + this.getRequestId() + " on " + this.getTopic()); - accepted = true; - } - if (accepted) { - if (this.isFailure(message)) { - this.stopProcessingMessages(); - auditLogger.info("received dmaap message: " + message); - final String errorMsg = "failure received from dmaap topic " + this.getTopic(); - auditLogger.error(errorMsg); - throw new DMaaPConsumerFailure(errorMsg); - } else { - auditLogger.info("received dmaap message: " + message); - this.processMessage(message); - } - } - } - iterations++; - } - return true; - } catch (Exception e ) { - throw e; - } finally { - if (stopwatch.isRunning()) { - stopwatch.stop(); - } - } - } - - /** - * Should this consumer continue to consume messages from the topic? - * @return - */ - public abstract boolean continuePolling(); - /** - * Process a message from a DMaaP topic - * - * @param message - * @throws Exception - */ - public abstract void processMessage(String message) throws Exception; - /** - * Has the request been accepted by the receiving system? - * Should the consumer move to processing messages? - * - * @param message - * @return - */ - public abstract boolean isAccepted(String message); - /** - * has the request failed? - * - * @param message - * @return - */ - public abstract boolean isFailure(String message); - /** - * The request id to filter messages on - * @return - */ - public abstract String getRequestId(); - /** - * Logic that defines when the consumer should stop processing messages - */ - public abstract void stopProcessingMessages(); - - /** - * time in milliseconds - */ - public int getMaximumElapsedTime() { - return 180000; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java deleted file mode 100644 index 7bdd7dfe40..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapProperties.java +++ /dev/null @@ -1,32 +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.client.dmaap; - -import java.util.Map; - -public interface DmaapProperties { - - /** - * A map of strings which contains the properties for a dmaap client - * @return - */ - public Map getProperties(); -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java deleted file mode 100644 index 1bdecbf2a7..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java +++ /dev/null @@ -1,48 +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.client.dmaap; - -import java.util.Iterator; -import java.util.ServiceLoader; - -public class DmaapPropertiesLoader { - - private final ServiceLoader services; - private DmaapPropertiesLoader() { - services = ServiceLoader.load(DmaapProperties.class); - } - - private static class Helper { - private static final DmaapPropertiesLoader INSTANCE = new DmaapPropertiesLoader(); - } - - public static DmaapPropertiesLoader getInstance() { - return Helper.INSTANCE; - } - - public DmaapProperties getImpl() { - for (DmaapProperties service : services) { - return service; - } - - return null; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java deleted file mode 100644 index d2752c531b..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPublisher.java +++ /dev/null @@ -1,51 +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.client.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.openecomp.mso.client.dmaap.rest.RestPublisher; - -public abstract class DmaapPublisher extends DmaapClient { - - private long seconds; - private final Publisher publisher; - public DmaapPublisher() throws FileNotFoundException, IOException { - super("dmaap/default-consumer.properties"); - this.publisher = new RestPublisher(properties); - this.seconds = 20; - - } - - public DmaapPublisher(long seconds) throws FileNotFoundException, IOException { - this(); - this.seconds = seconds; - } - - public void send(String json) throws IOException, InterruptedException { - auditLogger.info("publishing message to dmaap topic " + this.getTopic() + ": " + json); - publisher.send(json); - //publisher.close(seconds, TimeUnit.SECONDS); - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java deleted file mode 100644 index d89ee6e5c6..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/Publisher.java +++ /dev/null @@ -1,26 +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.client.dmaap; - -public interface Publisher { - - public void send(String json); -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java deleted file mode 100644 index 29472b2180..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/DMaaPConsumerFailure.java +++ /dev/null @@ -1,34 +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.client.dmaap.exceptions; - -public class DMaaPConsumerFailure extends Exception { - - private static final long serialVersionUID = 2499229901897110362L; - - public DMaaPConsumerFailure() { - super(); - } - - public DMaaPConsumerFailure(String message) { - super(message); - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java deleted file mode 100644 index c9d675067e..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/exceptions/ExceededMaximumPollingTime.java +++ /dev/null @@ -1,34 +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.client.dmaap.exceptions; - -public class ExceededMaximumPollingTime extends RuntimeException { - - private static final long serialVersionUID = 2331207691092906423L; - - public ExceededMaximumPollingTime() { - super(); - } - - public ExceededMaximumPollingTime(String message) { - super(message); - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.java deleted file mode 100644 index f54eba406e..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/DMaaPRestClient.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.client.dmaap.rest; - -import java.net.URL; -import java.util.Base64; -import java.util.Map; -import java.util.Optional; - -import javax.ws.rs.client.ClientResponseFilter; - -import org.openecomp.mso.client.ResponseExceptionMapperImpl; -import org.openecomp.mso.client.policy.RestClient; - -public class DMaaPRestClient extends RestClient { - - private final String username; - private final String password; - public DMaaPRestClient(URL url, String contentType, String username, String password) { - super(url, contentType); - this.username = username; - this.password = password; - } - - @Override - protected void initializeHeaderMap(Map headerMap) { - headerMap.put("Authorization", "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes())); - } - - @Override - protected Optional addResponseFilter() { - return Optional.of(new ResponseExceptionMapperImpl()); - } - - @Override - public RestClient addRequestId(String requestId) { - return null; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java deleted file mode 100644 index fb914a0c13..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/PropertiesBean.java +++ /dev/null @@ -1,131 +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.client.dmaap.rest; - -import java.util.Properties; - -public class PropertiesBean { - - private String username; - private String password; - private String environment; - private String partition; - private String contentType; - private String host; - private String topic; - private String timeout; - - - public PropertiesBean(Properties properties) { - this.withUsername(properties.getProperty("username")) - .withPassword(properties.getProperty("password")) - .withTopic(properties.getProperty("topic")) - .withEnvironment(properties.getProperty("environment")) - .withHost(properties.getProperty("host")) - .withTimeout(properties.getProperty("timeout", "20000")) - .withPartition(properties.getProperty("partition")) - .withContentType(properties.getProperty("contentType", "application/json")); - } - public String getUsername() { - return username; - } - public void setUsername(String username) { - this.username = username; - } - public PropertiesBean withUsername(String username) { - this.username = username; - return this; - } - public String getPassword() { - return password; - } - public void setPassword(String password) { - this.password = password; - } - public PropertiesBean withPassword(String password) { - this.password = password; - return this; - } - public String getEnvironment() { - return environment; - } - public void setEnvironment(String environment) { - this.environment = environment; - } - public PropertiesBean withEnvironment(String environment) { - this.environment = environment; - return this; - } - public String getPartition() { - return partition; - } - public void setPartition(String partition) { - this.partition = partition; - } - public PropertiesBean withPartition(String partition) { - this.partition = partition; - return this; - } - public String getContentType() { - return contentType; - } - public void setContentType(String contentType) { - this.contentType = contentType; - } - public PropertiesBean withContentType(String contentType) { - this.contentType = contentType; - return this; - } - public String getHost() { - return host; - } - public void setHost(String host) { - this.host = host; - } - public PropertiesBean withHost(String host) { - this.host = host; - return this; - } - public String getTopic() { - return topic; - } - public void setTopic(String topic) { - this.topic = topic; - } - public PropertiesBean withTopic(String topic) { - this.topic = topic; - return this; - } - public String getTimeout() { - return timeout; - } - public void setTimeout(String timeout) { - this.timeout = timeout; - } - public PropertiesBean withTimeout(String timeout) { - this.timeout = timeout; - return this; - } - - - - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java deleted file mode 100644 index ff199e2373..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestConsumer.java +++ /dev/null @@ -1,60 +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.client.dmaap.rest; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; -import java.util.Properties; - -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.UriBuilder; - -import org.openecomp.mso.client.dmaap.Consumer; -import org.openecomp.mso.client.policy.RestClient; - -public class RestConsumer implements Consumer { - - private final RestClient client; - public RestConsumer(Properties properties) { - PropertiesBean bean = new PropertiesBean(properties); - client = new DMaaPRestClient(this.createURL(bean), bean.getContentType(), bean.getUsername(), bean.getPassword()); - } - - private URL createURL(PropertiesBean properties) { - try { - return UriBuilder.fromUri("http://" + properties.getHost()) - .path("events").path(properties.getTopic()) - .path(properties.getPartition()) - .path("consumer1") - .queryParam("timeout", properties.getTimeout()).build().toURL(); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - @Override - public Iterable fetch() { - - return client.get(new GenericType>() {}); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java deleted file mode 100644 index e8e685932a..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/rest/RestPublisher.java +++ /dev/null @@ -1,56 +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.client.dmaap.rest; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Properties; - -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriBuilderException; - -import org.openecomp.mso.client.dmaap.Publisher; -import org.openecomp.mso.client.policy.RestClient; - -public class RestPublisher implements Publisher { - - private final RestClient client; - - public RestPublisher(Properties properties) { - PropertiesBean bean = new PropertiesBean(properties); - client = new DMaaPRestClient(this.createURL(bean), bean.getContentType(), bean.getUsername(), bean.getPassword()); - } - - private URL createURL(PropertiesBean properties) { - try { - return UriBuilder.fromUri("http://" + properties.getHost()) - .path("events").path(properties.getTopic()) - .queryParam("timeout", properties.getTimeout()).build().toURL(); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - @Override - public void send(String json) { - client.post(json); - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaaproperties/DefaultDmaapPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaaproperties/DefaultDmaapPropertiesImpl.java new file mode 100644 index 0000000000..c3bf53cfde --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaaproperties/DefaultDmaapPropertiesImpl.java @@ -0,0 +1,39 @@ +/*- + * ============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.client.dmaaproperties; + +import java.util.Map; + +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.client.dmaap.DmaapProperties; + +public class DefaultDmaapPropertiesImpl implements DmaapProperties { + + private final Map properties; + public DefaultDmaapPropertiesImpl() { + this.properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); + } + @Override + public Map getProperties() { + return this.properties; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java deleted file mode 100644 index ca6a943af5..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/exceptions/SDNOException.java +++ /dev/null @@ -1,39 +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.client.exceptions; - - -public class SDNOException extends Exception { - - private static final long serialVersionUID = 6189163383568887383L; - - public SDNOException() { - super(); - } - - public SDNOException(String string) { - super(string); - } - - public SDNOException(Exception e) { - super(e); - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/AAIOrchestrator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/AAIOrchestrator.java new file mode 100644 index 0000000000..73bad21c87 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/AAIOrchestrator.java @@ -0,0 +1,114 @@ +/*- + * ============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.client.orchestration; + +import java.util.Optional; +import java.util.logging.Logger; + +import org.modelmapper.ModelMapper; +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; +import org.openecomp.mso.client.aai.AAIResourcesClient; +import org.openecomp.mso.client.aai.entities.AAIEntityObject; +import org.openecomp.mso.client.aai.objects.AAIOwningEntity; +import org.openecomp.mso.client.aai.objects.AAIProject; +import org.openecomp.mso.client.aai.objects.AAIServiceInstance; + +public class AAIOrchestrator { + + private static Logger LOGGER = Logger.getLogger("AAIOrchestrator"); + + public void createServiceInstance(ServiceDecomposition serviceDecomp) { + try{ + ModelMapper modelMapper = new ModelMapper(); + AAIEntityObject serviceInstance = modelMapper.map(serviceDecomp.getServiceInstance(), AAIServiceInstance.class); + AAIResourcesClient aaiRC = this.getClient(); + aaiRC.createIfNotExists(serviceInstance.getUri(), Optional.of(serviceInstance)); + }catch(Exception ex) { + String msg = "Failed to create service instance in A&AI."; + throw new IllegalStateException(msg); + } + } + + public void deleteServiceInstance(ServiceDecomposition serviceDecomp) { + try{ + ModelMapper modelMapper = new ModelMapper(); + AAIEntityObject serviceInstance = modelMapper.map(serviceDecomp.getServiceInstance(), AAIServiceInstance.class); + AAIResourcesClient aaiRC = this.getClient(); + aaiRC.delete(serviceInstance.getUri()); + } catch (Exception ex) { + String msg = "Failed to delete service instance in A&AI."; + throw new IllegalStateException(msg); + } + } + + public void createProject(ServiceDecomposition serviceDecomp) { + try{ + ModelMapper modelMapper = new ModelMapper(); + AAIEntityObject project = modelMapper.map(serviceDecomp.getProject(), AAIProject.class); + AAIResourcesClient aaiRC = this.getClient(); + aaiRC.createIfNotExists(project.getUri(), Optional.of(project)); + }catch(Exception ex) { + String msg = "Failed to create project in A&AI."; + throw new IllegalStateException(msg); } + } + + public void createProjectandConnectServiceInstance(ServiceDecomposition serviceDecomp) { + try{ + ModelMapper modelMapper = new ModelMapper(); + AAIEntityObject project = modelMapper.map(serviceDecomp.getProject(), AAIProject.class); + AAIEntityObject serviceInstance = modelMapper.map(serviceDecomp.getServiceInstance(), AAIServiceInstance.class); + AAIResourcesClient aaiRC = this.getClient(); + aaiRC.createIfNotExists(project.getUri(), Optional.of(project)).connect(project.getUri(), serviceInstance.getUri()); + } catch(Exception ex) { + String msg = "Failed to create project and connect service instance in A&AI."; + throw new IllegalStateException(msg); + } + } + + public void createOwningEntity(ServiceDecomposition serviceDecomp) { + try{ + ModelMapper modelMapper = new ModelMapper(); + AAIEntityObject owningEntity = modelMapper.map(serviceDecomp.getOwningEntity(), AAIOwningEntity.class); + AAIResourcesClient aaiRC = this.getClient(); + aaiRC.createIfNotExists(owningEntity.getUri(), Optional.of(owningEntity)); + }catch(Exception ex) { + String msg = "Failed to create owning entity in A&AI."; + throw new IllegalStateException(msg); + } + } + + public void createOwningEntityandConnectServiceInstance(ServiceDecomposition serviceDecomp) { + try{ + ModelMapper modelMapper = new ModelMapper(); + AAIEntityObject owningEntity = modelMapper.map(serviceDecomp.getOwningEntity(), AAIOwningEntity.class); + AAIEntityObject serviceInstance = modelMapper.map(serviceDecomp.getServiceInstance(), AAIServiceInstance.class); + AAIResourcesClient aaiRC = this.getClient(); + aaiRC.createIfNotExists(owningEntity.getUri(), Optional.of(owningEntity)).connect(owningEntity.getUri(), serviceInstance.getUri()); + }catch(Exception ex) { + String msg = "Failed to create owning entity and connect service instance in A&AI."; + throw new IllegalStateException(msg); } + } + + protected AAIResourcesClient getClient() { + return new AAIResourcesClient(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/SDNCOrchestrator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/SDNCOrchestrator.java new file mode 100644 index 0000000000..4cefad2a3b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/orchestration/SDNCOrchestrator.java @@ -0,0 +1,61 @@ +/*- + * ============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.client.orchestration; + +import java.util.Optional; +import java.util.logging.Logger; + +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; +import org.openecomp.mso.client.sdnc.beans.SDNCRequest; +import org.openecomp.mso.client.sdnc.beans.SDNCSvcAction; +import org.openecomp.mso.client.sdnc.beans.SDNCSvcOperation; +import org.openecomp.mso.client.sdnc.mapper.ServiceTopologyOperationRequestMapper; +import org.openecomp.mso.client.sdnc.sync.SDNCSyncRpcClient; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +public class SDNCOrchestrator { + + private static MsoPropertiesFactory msoPF = new MsoPropertiesFactory(); + + public void createServiceInstance (ServiceDecomposition serviceDecomp) { + + try{ + msoPF.initializeMsoProperties("MSO_PROP_SDNC_ADAPTER", "mso.sdnc.properties"); + Optional msoAction = getMSOAction(serviceDecomp); + ServiceTopologyOperationRequestMapper sdncRM = new ServiceTopologyOperationRequestMapper(msoAction, SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, "CreateServiceInstance"); + SDNCRequest request = sdncRM.reqMapper(serviceDecomp); + SDNCSyncRpcClient sdncRC = new SDNCSyncRpcClient (request, msoPF); + sdncRC.run(); + } catch (Exception ex) { + throw new IllegalStateException(); + } + } + + private Optional getMSOAction (ServiceDecomposition serviceDecomp){ + String serviceType = serviceDecomp.getServiceInstance().getServiceType(); + if(serviceType == null || serviceType.equals("")){ + return Optional.empty(); + } + + return Optional.of(serviceType); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java deleted file mode 100644 index 0ea15ab204..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/CommonObjectMapperProvider.java +++ /dev/null @@ -1,51 +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.client.policy; - -import javax.ws.rs.ext.ContextResolver; - -import javax.ws.rs.ext.Provider; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -@Provider -public class CommonObjectMapperProvider implements ContextResolver { - - final ObjectMapper mapper; - - public CommonObjectMapperProvider() { - - mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - mapper.enable(MapperFeature.USE_ANNOTATIONS); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); - mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); - } - - @Override - public ObjectMapper getContext(Class type) { - return mapper; - } -} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java deleted file mode 100644 index 7b765ebb5f..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/DecisionAttributes.java +++ /dev/null @@ -1,93 +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.client.policy; - - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "ServiceType", "VNFType", "BB_ID", "WorkStep", "ErrorCode" }) -public class DecisionAttributes { - - @JsonProperty("ServiceType") - private String serviceType; - @JsonProperty("VNFType") - private String vNFType; - @JsonProperty("BB_ID") - private String bbID; - @JsonProperty("WorkStep") - private String workStep; - @JsonProperty("ErrorCode") - private String errorCode; - - @JsonProperty("ServiceType") - public String getServiceType() { - return serviceType; - } - - @JsonProperty("ServiceType") - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - - @JsonProperty("VNFType") - public String getVNFType() { - return vNFType; - } - - @JsonProperty("VNFType") - public void setVNFType(String vNFType) { - this.vNFType = vNFType; - } - - @JsonProperty("BB_ID") - public String getBBID() { - return bbID; - } - - @JsonProperty("BB_ID") - public void setBBID(String bBID) { - this.bbID = bBID; - } - - @JsonProperty("WorkStep") - public String getWorkStep() { - return workStep; - } - - @JsonProperty("WorkStep") - public void setWorkStep(String workStep) { - this.workStep = workStep; - } - - @JsonProperty("ErrorCode") - public String getErrorCode() { - return errorCode; - } - - @JsonProperty("ErrorCode") - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java deleted file mode 100644 index e02941944a..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/LoggingFilter.java +++ /dev/null @@ -1,138 +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.client.policy; - -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.logging.Logger; - -import javax.annotation.Priority; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.client.ClientRequestContext; -import javax.ws.rs.client.ClientRequestFilter; -import javax.ws.rs.client.ClientResponseContext; -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.ext.WriterInterceptor; -import javax.ws.rs.ext.WriterInterceptorContext; - -@Priority(Integer.MIN_VALUE) -public class LoggingFilter implements ClientRequestFilter, ClientResponseFilter, WriterInterceptor { - - private static final Logger logger = Logger.getLogger(LoggingFilter.class.getName()); - private static final String ENTITY_STREAM_PROPERTY = "LoggingFilter.entityStream"; - private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; - private final int maxEntitySize; - - public LoggingFilter() { - maxEntitySize = 1024 * 1024; - } - - public LoggingFilter(int maxPayloadSize) { - this.maxEntitySize = Integer.min(maxPayloadSize, 1024 * 1024); - } - - private void log(StringBuilder sb) { - logger.info(sb.toString()); - } - - private InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset) - throws IOException { - if (!stream.markSupported()) { - stream = new BufferedInputStream(stream); - } - stream.mark(maxEntitySize + 1); - final byte[] entity = new byte[maxEntitySize + 1]; - final int entitySize = stream.read(entity); - if (entitySize != -1) { - b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset)); - } - if (entitySize > maxEntitySize) { - b.append("...more..."); - } - b.append('\n'); - stream.reset(); - return stream; - } - - @Override - public void filter(ClientRequestContext requestContext) throws IOException { - if (requestContext.hasEntity()) { - final OutputStream stream = new LoggingStream(requestContext.getEntityStream()); - requestContext.setEntityStream(stream); - requestContext.setProperty(ENTITY_STREAM_PROPERTY, stream); - } - } - - @Override - public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { - final StringBuilder sb = new StringBuilder(); - if (responseContext.hasEntity()) { - responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET)); - log(sb); - } - } - - @Override - public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { - final LoggingStream stream = (LoggingStream) context.getProperty(ENTITY_STREAM_PROPERTY); - context.proceed(); - if (stream != null) { - log(stream.getStringBuilder(DEFAULT_CHARSET)); - } - } - - private class LoggingStream extends FilterOutputStream { - - private final StringBuilder sb = new StringBuilder(); - private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - LoggingStream(OutputStream out) { - super(out); - } - - StringBuilder getStringBuilder(Charset charset) { - // write entity to the builder - final byte[] entity = baos.toByteArray(); - - sb.append(new String(entity, 0, entity.length, charset)); - if (entity.length > maxEntitySize) { - sb.append("...more..."); - } - sb.append('\n'); - - return sb; - } - - @Override - public void write(final int i) throws IOException { - if (baos.size() <= maxEntitySize) { - baos.write(i); - } - out.write(i); - } - } -} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.java deleted file mode 100644 index 98c7e1558d..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecision.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.client.policy; - - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "decision", "details" }) -public class PolicyDecision { - - @JsonProperty("decision") - private String decision; - @JsonProperty("details") - private String details; - - @JsonProperty("decision") - public String getDecision() { - return decision; - } - - @JsonProperty("decision") - public void setDecision(String decision) { - this.decision = decision; - } - - @JsonProperty("details") - public String getDetails() { - return details; - } - - @JsonProperty("details") - public void setDetails(String details) { - this.details = details; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.java deleted file mode 100644 index c83fb19e34..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyDecisionRequest.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.client.policy; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "decisionAttributes", "ecompcomponentName" }) -public class PolicyDecisionRequest { - - @JsonProperty("decisionAttributes") - private DecisionAttributes decisionAttributes; - @JsonProperty("ecompcomponentName") - private String ecompcomponentName; - - @JsonProperty("decisionAttributes") - public DecisionAttributes getDecisionAttributes() { - return decisionAttributes; - } - - @JsonProperty("decisionAttributes") - public void setDecisionAttributes(DecisionAttributes decisionAttributes) { - this.decisionAttributes = decisionAttributes; - } - - @JsonProperty("ecompcomponentName") - public String getEcompcomponentName() { - return ecompcomponentName; - } - - @JsonProperty("ecompcomponentName") - public void setEcompcomponentName(String ecompcomponentName) { - this.ecompcomponentName = ecompcomponentName; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java deleted file mode 100644 index 4ed2a887ef..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestClient.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - 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========================================================= - */ - -package org.openecomp.mso.client.policy; - -import java.net.MalformedURLException; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; - -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriBuilderException; - -import org.openecomp.mso.client.ResponseExceptionMapperImpl; -import org.openecomp.mso.client.RestProperties; -import org.openecomp.mso.client.policy.entities.PolicyServiceType; -import org.springframework.stereotype.Service; - -@Service -public class PolicyRestClient extends RestClient { - - private static final String X_ECOMP_REQUESTID = String.valueOf(UUID.randomUUID()); - private final PolicyRestProperties properties; - public PolicyRestClient(PolicyRestProperties props, PolicyServiceType serviceType) { - super(props, Optional.of(UriBuilder.fromPath(serviceType.toString()).build())); - this.properties = props; - this.getClient(); - } - - @Override - protected void initializeHeaderMap(Map headerMap) { - headerMap.put("ClientAuth", properties.getClientAuth()); - headerMap.put("Authorization", properties.getAuth()); - headerMap.put("Environment", properties.getEnvironment()); - this.addRequestId(X_ECOMP_REQUESTID); - } - - @Override - protected Optional addResponseFilter() { - return Optional.of(new ResponseExceptionMapperImpl()); - } - - @Override - public RestClient addRequestId(String requestId) { - this.headerMap.put("X-ECOMP-RequestID", requestId); - return this; - } -} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java deleted file mode 100644 index d9336768fc..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/PolicyRestProperties.java +++ /dev/null @@ -1,64 +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.client.policy; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Map; - -import org.openecomp.mso.bpmn.core.PropertyConfiguration; -import org.openecomp.mso.client.RestProperties; - -public class PolicyRestProperties implements RestProperties { - - - final Map props; - public PolicyRestProperties() { - this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); - - } - @Override - public URL getEndpoint() { - try { - return new URL(props.getOrDefault("policy.endpoint", "")); - } catch (MalformedURLException e) { - return null; - } - } - - @Override - public String getSystemName() { - return "MSO"; - } - - public String getClientAuth() { - return props.get("policy.client.auth"); - } - - public String getAuth() { - return props.get("policy.auth"); - } - - public String getEnvironment() { - return props.get("policy.environment"); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java deleted file mode 100644 index 1436d83a94..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/RestClient.java +++ /dev/null @@ -1,220 +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.client.policy; - -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Optional; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.ClientResponseFilter; -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation.Builder; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.ext.ContextResolver; - -import org.apache.log4j.Logger; -import org.openecomp.mso.client.RestProperties; -import org.openecomp.mso.logger.MsoLogger; -import org.springframework.stereotype.Service; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@Service -public abstract class RestClient { - protected static final String ECOMP_COMPONENT_NAME = "MSO"; - - private static final int MAX_PAYLOAD_SIZE = 1024 * 1024; - private WebTarget webTarget; - - protected final Map headerMap; - protected final MsoLogger msoLogger; - protected URL host; - protected Optional path; - protected Logger logger; - protected String accept; - protected String contentType; - - protected RestClient(RestProperties props, Optional path) { - logger = Logger.getLogger(getClass().getName()); - msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - - headerMap = new HashMap<>(); - try { - host = props.getEndpoint(); - } catch (MalformedURLException e) { - logger.error("url not valid", e); - throw new RuntimeException(e); - } - - this.path = path; - initializeClient(getClient()); - } - - protected RestClient(RestProperties props, Optional path, String accept, String contentType) { - this(props, path); - this.accept = accept; - this.contentType = contentType; - - } - - protected RestClient(URL host, String contentType) { - headerMap = new HashMap<>(); - logger = Logger.getLogger(getClass().getName()); - msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - this.path = Optional.empty(); - this.host = host; - this.contentType = contentType; - initializeClient(getClient()); - } - - /** - * Override method to return false to disable logging. - * - * @return true - to enable logging, false otherwise - */ - protected boolean enableLogging() { - return true; - } - - /** - * Override method to return custom value for max payload size. - * - * @return Default value for MAX_PAYLOAD_SIZE = 1024 * 1024 - */ - protected int getMaxPayloadSize() - { - return MAX_PAYLOAD_SIZE; - } - - protected Builder getBuilder() { - - Builder builder = webTarget.request(); - initializeHeaderMap(headerMap); - - for (Entry entry : headerMap.entrySet()) { - builder.header(entry.getKey(), entry.getValue()); - } - return builder; - } - - protected abstract void initializeHeaderMap(Map headerMap); - - protected abstract Optional addResponseFilter(); - - public abstract RestClient addRequestId(String requestId); - - protected ContextResolver getMapper() { - return new CommonObjectMapperProvider(); - } - - protected String getAccept() { - return accept; - } - - protected String getContentType() { - return contentType; - } - - protected String getMergeContentType() { - return "application/merge-patch+json"; - } - - protected Client getClient() { - return ClientBuilder.newBuilder().build(); - } - - protected void initializeClient(Client client) { - if (this.enableLogging()) { - client.register(logger).register(new LoggingFilter(this.getMaxPayloadSize())); - } - client.register(this.getMapper()); - Optional responseFilter = this.addResponseFilter(); - responseFilter.ifPresent(clientResponseFilter -> client.register(clientResponseFilter)); - webTarget = path.map(uri -> client.target(UriBuilder.fromUri(host + uri.toString()))) - .orElseGet(() -> client.target(host.toString())); - this.accept = MediaType.APPLICATION_JSON; - this.contentType = MediaType.APPLICATION_JSON; - } - - public Response get() { - return this.getBuilder().accept(this.getAccept()).get(); - } - - public Response post(Object obj) { - return this.getBuilder().accept(this.getAccept()).post(Entity.entity(obj, this.getContentType())); - } - - public Response patch(Object obj) { - return this.getBuilder().header("X-HTTP-Method-Override", "PATCH").accept(this.getAccept()) - .post(Entity.entity(obj, this.getMergeContentType())); - } - - public Response put(Object obj) { - return this.getBuilder().accept(this.getAccept()).put(Entity.entity(obj, this.getContentType())); - } - - public Response delete() { - return this.getBuilder().accept(this.getAccept()).delete(); - } - - public Response delete(Object obj) { - return this.getBuilder().header("X-HTTP-Method-Override", "DELETE").accept(this.getAccept()) - .put(Entity.entity(obj, this.getContentType())); - } - - public T get(Class resultClass) { - return this.get().readEntity(resultClass); - } - - public T get(GenericType resultClass) { - return this.get().readEntity(resultClass); - } - - public T post(Object obj, Class resultClass) { - return this.post(obj).readEntity(resultClass); - } - - public T patch(Object obj, Class resultClass) { - return this.patch(obj).readEntity(resultClass); - } - - public T put(Object obj, Class resultClass) { - return this.put(obj).readEntity(resultClass); - } - - public T delete(Class resultClass) { - return this.delete().readEntity(resultClass); - } - - public T delete(Object obj, Class resultClass) { - return this.delete(obj).readEntity(resultClass); - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java deleted file mode 100644 index 01f6738947..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/policy/entities/PolicyServiceType.java +++ /dev/null @@ -1,48 +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.client.policy.entities; - -public enum PolicyServiceType { - GET_CONFIG("getConfig"), - SEND_EVENT("sendEvent"), - PUSH_POLICY("pushPolicy"), - CREATE_POLICY("createPolicy"), - UPDATE_POLICY("updatePolicy"), - GET_DECISION("getDecision"), - GET_METRICS("getMetrics"), - DELETE_POLICY("deletePolicy"), - LIST_CONFIG("listConfig"), - CREATE_DICTIONARY_ITEM("createDictionaryItem"), - UPDATE_DICTIONARY_ITEM("updateDictionaryItem"), - GET_DICTIONARY_ITEMS("getDictionaryItems"); - - private final String name; - - PolicyServiceType(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java new file mode 100644 index 0000000000..27352dc11d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/AAIPropertiesImpl.java @@ -0,0 +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.client.restproperties; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Map; + +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.client.aai.AAIProperties; +import org.openecomp.mso.client.aai.AAIVersion; + +public class AAIPropertiesImpl implements AAIProperties { + + final Map props; + + public AAIPropertiesImpl() { + this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); + + } + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(props.get("aai.endpoint")); + } + + @Override + public String getSystemName() { + return "MSO"; + } + + @Override + public AAIVersion getDefaultVersion() { + return AAIVersion.LATEST; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/PolicyRestPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/PolicyRestPropertiesImpl.java new file mode 100644 index 0000000000..eccf87c09d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/restproperties/PolicyRestPropertiesImpl.java @@ -0,0 +1,64 @@ +/*- + * ============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.client.restproperties; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Map; + +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.client.policy.PolicyRestProperties; + +public class PolicyRestPropertiesImpl implements PolicyRestProperties { + + + final Map props; + public PolicyRestPropertiesImpl() { + this.props = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); + + } + @Override + public URL getEndpoint() { + try { + return new URL(props.getOrDefault("policy.endpoint", "")); + } catch (MalformedURLException e) { + return null; + } + } + + @Override + public String getSystemName() { + return "MSO"; + } + + public String getClientAuth() { + return props.get("policy.client.auth"); + } + + public String getAuth() { + return props.get("policy.auth"); + } + + public String getEnvironment() { + return props.get("policy.environment"); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java new file mode 100644 index 0000000000..cd04fc5ef0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCRequest.java @@ -0,0 +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.client.sdnc.beans; + +public class SDNCRequest { + private String requestId; + private String svcInstanceId; + private SDNCSvcAction svcAction; + private SDNCSvcOperation svcOperation; + private String callbackUrl; + private String msoAction; + private String requestData; + + public SDNCRequest(String requestId, String svcInstanceId, SDNCSvcAction svcAction, SDNCSvcOperation svcOperation, + String callbackUrl, String msoAction, String requestData) { + this.requestId = requestId; + this.svcInstanceId = svcInstanceId; + this.svcAction = svcAction; + this.svcOperation = svcOperation; + this.callbackUrl = callbackUrl; + this.msoAction = msoAction; + this.requestData = requestData; + } + public SDNCRequest(){ + + } + + public String getRequestId() { + return requestId; + } + public void setRequestId(String requestId) { + this.requestId = requestId; + } + public String getSvcInstanceId() { + return svcInstanceId; + } + public void setSvcInstanceId(String svcInstanceId) { + this.svcInstanceId = svcInstanceId; + } + public SDNCSvcAction getSvcAction() { + return svcAction; + } + public void setSvcAction(SDNCSvcAction svcAction) { + this.svcAction = svcAction; + } + public SDNCSvcOperation getSvcOperation() { + return svcOperation; + } + public void setSvcOperation(SDNCSvcOperation svcOperation) { + this.svcOperation = svcOperation; + } + public String getCallbackUrl() { + return callbackUrl; + } + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + public String getMsoAction() { + return msoAction; + } + public void setMsoAction(String msoAction) { + this.msoAction = msoAction; + } + + public String getRequestData() { + return requestData; + } + public void setRequestData(String requestData) { + this.requestData = requestData; + } + @Override + public String toString() { + return "SDNCRequest [requestId=" + requestId + ", svcInstanceId=" + svcInstanceId + ", svcAction=" + svcAction + + ", svcOperation=" + svcOperation + ", callbackUrl=" + callbackUrl + ", msoAction=" + msoAction + + ", requestData=" + requestData + "]"; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java new file mode 100644 index 0000000000..91e3a59276 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcAction.java @@ -0,0 +1,46 @@ +/*- + * ============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.client.sdnc.beans; + +public enum SDNCSvcAction { + ACTIVATE("activate"), + DELETE("delete"), + ASSIGN("assign"), + ROLLBACK("rollback"), + UNASSIGN("unassign"), + DEACTIVATE("deactivate"), + CHANGE_DELETE("changedelete"), + CHANGE_ASSIGN("changeassign"), + CREATE("create"), + ENABLE("enable"), + DISABLE("disable"); + + private final String name; + + private SDNCSvcAction(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java new file mode 100644 index 0000000000..8cf1052064 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/beans/SDNCSvcOperation.java @@ -0,0 +1,43 @@ +/*- + * ============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.client.sdnc.beans; + +public enum SDNCSvcOperation { + + VF_MODULE_TOPOLOGY_OPERATION("vf-module-topology-operation"), + NETWORK_TOPOLOGY_OPERATION("network-topology-operation"), + VNF_TOPOLOGY_OPERATION("vnf-topology-operation"), + CONTRAIL_ROUTE_TOPOLOGY_OPERATION("contrail-route-topology-operation"), + SECURITY_ZONE_TOPOLOGY_OPERATION("security-zone-topology-operation"), + PORT_MIRROR_TOPOLOGY_OPERATION("port-mirror-topology-operation"), + SERVICE_TOPOLOGY_OPERATION("service-topology-operation"); + + private final String name; + + private SDNCSvcOperation(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java new file mode 100644 index 0000000000..3e714e901d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/SDNCRequestMapper.java @@ -0,0 +1,46 @@ +/*- + * ============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.client.sdnc.mapper; + +import java.util.Optional; + +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; +import org.openecomp.mso.client.sdnc.beans.SDNCRequest; +import org.openecomp.mso.client.sdnc.beans.SDNCSvcAction; +import org.openecomp.mso.client.sdnc.beans.SDNCSvcOperation; + +public abstract class SDNCRequestMapper { + + protected final Optional msoAction; + protected final SDNCSvcOperation svcOperation; + protected final SDNCSvcAction svcAction; + protected final String requestAction; + + public SDNCRequestMapper (Optional msoAction, SDNCSvcOperation svcOperation, + SDNCSvcAction svcAction, String requestAction) { + this.msoAction = msoAction; + this.svcOperation = svcOperation; + this.svcAction = svcAction; + this.requestAction = requestAction; + } + + public abstract SDNCRequest reqMapper (ServiceDecomposition serviceDecomp); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java new file mode 100644 index 0000000000..b87ed00650 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/mapper/ServiceTopologyOperationRequestMapper.java @@ -0,0 +1,98 @@ +/*- + * ============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.client.sdnc.mapper; + +import java.io.StringWriter; +import java.util.Optional; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; +import org.openecomp.mso.client.sdnc.beans.SDNCRequest; +import org.openecomp.mso.client.sdnc.beans.SDNCSvcAction; +import org.openecomp.mso.client.sdnc.beans.SDNCSvcOperation; + +import openecomp.org.mso.workflow.schema.v1.EcompModelInformation; +import openecomp.org.mso.workflow.schema.v1.RequestInformation; +import openecomp.org.mso.workflow.schema.v1.SDNCServiceInstanceRequestData; +import openecomp.org.mso.workflow.schema.v1.ServiceInformation; +import openecomp.org.mso.workflow.schema.v1.ServiceRequestInput; + +public class ServiceTopologyOperationRequestMapper extends SDNCRequestMapper{ + + public ServiceTopologyOperationRequestMapper(Optional msoAction, SDNCSvcOperation svcOperation, + SDNCSvcAction svcAction, String requestAction) { + super(msoAction, svcOperation, svcAction, requestAction); + } + + @Override + public SDNCRequest reqMapper (ServiceDecomposition serviceDecomp) { + SDNCRequest req = new SDNCRequest(); + req.setCallbackUrl(serviceDecomp.getCallbackURN()); + if(msoAction.isPresent()){ + req.setMsoAction(msoAction.get()); + } + req.setRequestId(serviceDecomp.getRequest().getSdncRequestId()); + req.setSvcInstanceId(serviceDecomp.getServiceInstance().getInstanceId()); + req.setSvcAction(svcAction); + req.setSvcOperation(svcOperation); + String reqData =""; + + RequestInformation reqInfo = new RequestInformation(); + reqInfo.setRequestAction(requestAction); + reqInfo.setSource("MSO"); + reqInfo.setRequestId(serviceDecomp.getRequest().getRequestId()); + ServiceInformation servInfo = new ServiceInformation(); + EcompModelInformation emi = new EcompModelInformation(); + emi.setModelInvariantUuid(serviceDecomp.getRequest().getModelInfo().getModelInvariantUuid()); + emi.setModelName(serviceDecomp.getRequest().getModelInfo().getModelName()); + emi.setModelVersion(serviceDecomp.getRequest().getModelInfo().getModelVersion() ); + servInfo.setEcompModelInformation(emi); + servInfo.setServiceId(serviceDecomp.getServiceInstance().getServiceId()); + servInfo.setSubscriptionServiceType(serviceDecomp.getCustomer().getSubscriptionServiceType()); + servInfo.setServiceInstanceId(serviceDecomp.getServiceInstance().getInstanceName()); + servInfo.setGlobalCustomerId(serviceDecomp.getCustomer().getGlobalSubscriberId()); + ServiceRequestInput servReqInput = new ServiceRequestInput(); + servReqInput.setServiceInstanceName(serviceDecomp.getServiceInstance().getInstanceName()); + SDNCServiceInstanceRequestData sdncSIRD = new SDNCServiceInstanceRequestData(); + sdncSIRD.setRequestInformation(reqInfo); + sdncSIRD.setServiceInformation(servInfo); + sdncSIRD.setServiceRequestInput(servReqInput); + + try { + JAXBContext context = JAXBContext.newInstance(SDNCServiceInstanceRequestData.class); + + Marshaller jaxbMarshaller = context.createMarshaller(); + jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + + StringWriter sw = new StringWriter(); + jaxbMarshaller.marshal(sdncSIRD, sw); + reqData = sw.toString(); + req.setRequestData(reqData); + } catch (JAXBException e) { + e.printStackTrace(); + } + + return req; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java new file mode 100644 index 0000000000..2ddafc1c17 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/CallbackHeader.java @@ -0,0 +1,154 @@ +/*- + * ============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.client.sdnc.sync; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="ResponseCode" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="ResponseMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +//SDNCAdapter to BPEL Async response header +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestId", + "responseCode", + "responseMessage" +}) +@XmlRootElement(name = "CallbackHeader") +public class CallbackHeader { + + @XmlElement(name = "RequestId", required = true) + protected String requestId; + @XmlElement(name = "ResponseCode", required = true) + protected String responseCode; + @XmlElement(name = "ResponseMessage", required = true) + protected String responseMessage; + + public CallbackHeader() { + } + + public CallbackHeader(String reqId, String respCode, String respMsg) { + this.requestId = reqId; + this.responseCode = respCode; + this.responseMessage = respMsg; + } + + /** + * 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 value) { + this.requestId = value; + } + + /** + * Gets the value of the responseCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponseCode() { + return responseCode; + } + + /** + * Sets the value of the responseCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponseCode(String value) { + this.responseCode = value; + } + + /** + * Gets the value of the responseMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResponseMessage() { + return responseMessage; + } + + /** + * Sets the value of the responseMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResponseMessage(String value) { + this.responseMessage = value; + } + + @Override + public String toString() { + return "CallbackHeader [requestId=" + requestId + ", responseCode=" + + responseCode + ", responseMessage=" + responseMessage + "]"; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java new file mode 100644 index 0000000000..331fefa677 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Constants.java @@ -0,0 +1,48 @@ +/*- + * ============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.client.sdnc.sync; + + +public interface Constants { + + public static final String BPEL_REST_URL_PROP = "org.openecomp.mso.adapters.sdnc.rest.bpelurl"; + public static final String BPEL_URL_PROP = "org.openecomp.mso.adapters.sdnc.bpelurl"; + public static final String DEFAULT_BPEL_URL = "http://localhost:8080//active-bpel/services/SDNCAdapterCallbackV1"; + + public static final String MY_URL_PROP = "org.openecomp.mso.adapters.sdnc.myurl"; + public static final String DEFAULT_MY_URL = "https://localhost:8443/adapters/rest/SDNCNotify"; + + public static final String SDNC_AUTH_PROP = "org.openecomp.mso.adapters.sdnc.sdncauth"; + public static final String DEFAULT_SDNC_AUTH = "406B2AE613211B6FB52466DE6E1769AC"; + + public static final String DEFAULT_BPEL_AUTH = "05FDA034C27D1CA51AAB8FAE512EDE45241E16FC8C137D292AA3A964431C82DB"; + public static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.sdnc.bpelauth"; + + + public static final String SDNC_SVCCFGRESP_ROOT = "input"; + public static final String SDNC_REQ_ID = "/svc-request-id"; + public static final String SDNC_RESP_CODE = "/response-code"; + public static final String SDNC_RESP_MSG = "/response-message"; + public static final String SDNC_CONNECTTIME_PROP = "org.openecomp.mso.adapters.sdnc.sdncconnecttime"; + public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + + public static final String REQUEST_TUNABLES = "org.openecomp.mso.adapters.sdnc"; +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java new file mode 100644 index 0000000000..3ddfdb2925 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/ObjectFactory.java @@ -0,0 +1,77 @@ +/*- + * ============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.client.sdnc.sync; + + +import javax.xml.bind.annotation.XmlRegistry; + + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.openecomp.mso.adapters.sdnc package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.adapters.sdnc + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link RequestHeader } + * + */ + public RequestHeader createRequestHeader() { + return new RequestHeader(); + } + + /** + * Create an instance of {@link SDNCAdapterResponse } + * + */ + public SDNCAdapterResponse createSDNCAdapterResponse() { + return new SDNCAdapterResponse(); + } + + /** + * Create an instance of {@link SDNCAdapterRequest } + * + */ + public SDNCAdapterRequest createSDNCAdapterRequest() { + return new SDNCAdapterRequest(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java new file mode 100644 index 0000000000..dee79898fa --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestHeader.java @@ -0,0 +1,219 @@ +/*- + * ============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.client.sdnc.sync; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="RequestId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="SvcInstanceId" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="SvcAction" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="SvcOperation" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="CallbackUrl" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +//BPEL to SDNCAdapter request header +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestId", + "svcInstanceId", + "svcAction", + "svcOperation", + "callbackUrl", + "msoAction" +}) +@XmlRootElement(name = "RequestHeader") +public class RequestHeader { + + @XmlElement(name = "RequestId", required = true) + protected String requestId; + @XmlElement(name = "SvcInstanceId") + protected String svcInstanceId; + @XmlElement(name = "SvcAction", required = true) + protected String svcAction; + @XmlElement(name = "SvcOperation", required = true) + protected String svcOperation; + @XmlElement(name = "CallbackUrl", required = true) + protected String callbackUrl; + @XmlElement(name = "MsoAction") + protected String msoAction; + + /** + * 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 value) { + this.requestId = value; + } + + public String getSvcInstanceId() { + return svcInstanceId; + } + + public void setSvcInstanceId(String svcInstanceId) { + this.svcInstanceId = svcInstanceId; + } + + /** + * Gets the value of the svcAction property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSvcAction() { + return svcAction; + } + + /** + * Sets the value of the svcAction property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSvcAction(String value) { + this.svcAction = value; + } + + /** + * Gets the value of the svcOperation property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSvcOperation() { + return svcOperation; + } + + /** + * Sets the value of the svcOperation property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSvcOperation(String value) { + this.svcOperation = value; + } + + /** + * Gets the value of the callbackUrl property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCallbackUrl() { + return callbackUrl; + } + + /** + * Sets the value of the callbackUrl property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCallbackUrl(String value) { + this.callbackUrl = value; + } + + /** + * Gets the value of the callbackUrl property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMsoAction() { + return msoAction; + } + + /** + * Sets the value of the callbackUrl property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMsoAction(String value) { + this.msoAction = value; + } + + + @Override + public String toString() { + return "RequestHeader [requestId=" + requestId + + ", svcInstanceId=" + svcInstanceId + + ", svcAction=" + svcAction + + ", svcOperation=" + svcOperation + + ", callbackUrl=" + callbackUrl + + ", msoAction=" + msoAction + "]"; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java new file mode 100644 index 0000000000..55d42df6e1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/RequestTunables.java @@ -0,0 +1,222 @@ +/*- + * ============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.client.sdnc.sync; + + +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +import org.openecomp.mso.logger.MessageEnum; +public class RequestTunables { + + private MsoPropertiesFactory msoPropertiesFactory; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + public static final String MSO_PROP_SDNC_ADAPTER="MSO_PROP_SDNC_ADAPTER"; + + //criteria + private String reqId = ""; + private String msoAction = ""; + private String operation = ""; + private String action = ""; + + //tunables + private String reqMethod = "POST"; + private String sdncUrl = null; + private String timeout = "60000"; + private String headerName = "sdnc-request-header"; + private String namespace = ""; + private String asyncInd = "N"; //future use + + private String sdncaNotificationUrl = null; + + public RequestTunables(String reqId, String msoAction, String operation, String action, MsoPropertiesFactory msoPropFactory) { + super(); + msoPropertiesFactory = msoPropFactory; + if (reqId != null) { + this.reqId = reqId; + } + if (msoAction != null) { + this.msoAction = msoAction; + } + if (operation != null) { + this.operation = operation; + } + if (action != null) { + this.action = action; + } + } + + public String getReqId() { + return reqId; + } + public void setReqId(String reqId) { + this.reqId = reqId; + } + public String getReqMethod() { + return reqMethod; + } + public void setReqMethod(String reqMethod) { + this.reqMethod = reqMethod; + } + public String getMsoAction() { + return msoAction; + } + public void setMsoAction(String msoAction) { + this.msoAction = msoAction; + } + public String getAction() { + return action; + } + public void setAction(String action) { + this.action = action; + } + public String getOperation() { + return operation; + } + public void setOperation(String operation) { + this.operation = operation; + } + public String getSdncUrl() { + return sdncUrl; + } + public void setSdncUrl(String sdncUrl) { + this.sdncUrl = sdncUrl; + } + public String getTimeout() { + return timeout; + } + public void setTimeout(String timeout) { + this.timeout = timeout; + } + public String getAsyncInd() { + return asyncInd; + } + public void setAsyncInd(String asyncInd) { + this.asyncInd = asyncInd; + } + public String getHeaderName() { + return headerName; + } + public void setHeaderName(String headerName) { + this.headerName = headerName; + } + + + public String getSdncaNotificationUrl() { + return sdncaNotificationUrl; + } + + public void setSdncaNotificationUrl(String sdncaNotificationUrl) { + this.sdncaNotificationUrl = sdncaNotificationUrl; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + @Override + public String toString() { + return "RequestTunables [reqId=" + reqId + ", msoAction=" + msoAction + + ", operation=" + operation + ", action=" + action + + ", reqMethod=" + reqMethod + ", sdncUrl=" + sdncUrl + + ", timeout=" + timeout + ", headerName=" + headerName + + ", sdncaNotificationUrl=" + sdncaNotificationUrl + + ", namespace=" + namespace + "]"; + } + + public void setTunables() + { + String error = null; + String key = null; + if ("query".equals(action)) { //due to variable format for operation eg services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9 + key = Constants.REQUEST_TUNABLES + "." + msoAction + ".." + action; + msoLogger.debug("Generated key: " + key); + } + else if ("put".equals(action) || "restdelete".equals(action)) { //due to variable format for operation eg services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9 + key = Constants.REQUEST_TUNABLES + "..." + action; + msoLogger.debug("Generated key: " + key); + } else { + key = Constants.REQUEST_TUNABLES + "." + msoAction + "." + operation +"." + action; + msoLogger.debug("Generated key: " + key); + } + + String value; + try { + value = msoPropertiesFactory.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getProperty(key, ""); + } catch (MsoPropertiesException e) { + msoLogger.error (MessageEnum.LOAD_PROPERTIES_FAIL, "Unknown. Mso Properties ID not found in cache: " + MSO_PROP_SDNC_ADAPTER, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e); + value=""; + } + + if (value != null && value.length() > 0) { + + String[] parts = value.split("\\|"); //escape pipe + if (parts.length < 3) { + msoLogger.warn(MessageEnum.RA_SDNC_INVALID_CONFIG, key, value, "SDNC", "", MsoLogger.ErrorCode.DataError, "Invalid config"); + } + + for (int i = 0; i < parts.length; i++) { + if (i == 0) { + reqMethod = parts[i]; + msoLogger.debug("Request Method is set to: " + reqMethod); + } else if (i == 1) { + timeout = parts[i]; + msoLogger.debug("Timeout is set to: " + timeout); + } else if (i == 2) { + sdncUrl = SDNCAdapterPortTypeImpl.getProperty(Constants.REQUEST_TUNABLES + "." + parts[i], "",msoPropertiesFactory); + if (operation != null && sdncUrl != null) { + sdncUrl = sdncUrl + operation; + } + msoLogger.debug("SDNC Url is set to: " + sdncUrl); + } else if (i == 3) { + headerName = parts[i]; + msoLogger.debug("HeaderName is set to: " + headerName); + } else if (i == 4) { + namespace = parts[i]; + msoLogger.debug("NameSpace is set to: " + namespace); + } else if (i == 5) { + asyncInd = parts[i]; + msoLogger.debug("AsyncInd is set to: " + asyncInd); + } + } + if (sdncUrl == null) { + error = "Invalid configuration, sdncUrl required for:" + key + " value:" + value; + } + } else { + error = "Missing configuration for:" + key; + } + if (error != null) { + msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, key, "SDNC", "", MsoLogger.ErrorCode.DataError, "Missing config param"); + alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + } + msoLogger.debug ("RequestTunables Key:" + key + " Value:" + value + " Tunables:" + this.toString()); + return; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java new file mode 100644 index 0000000000..6e9d6757ad --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequest.java @@ -0,0 +1,136 @@ +/*- + * ============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.client.sdnc.sync; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import java.io.StringWriter; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}CallbackHeader"/>
+ *         <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +//SDNCAdapter to BPEL Async response +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "callbackHeader", + "requestData" +}) +@XmlRootElement(name = "SDNCAdapterCallbackRequest") +public class SDNCAdapterCallbackRequest { + + @XmlElement(name = "CallbackHeader", required = true) + protected CallbackHeader callbackHeader; + @XmlElement(name = "RequestData") + protected Object requestData; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + /** + * Gets the value of the callbackHeader property. + * + * @return + * possible object is + * {@link CallbackHeader } + * + */ + public CallbackHeader getCallbackHeader() { + return callbackHeader; + } + + /** + * Sets the value of the callbackHeader property. + * + * @param value + * allowed object is + * {@link CallbackHeader } + * + */ + public void setCallbackHeader(CallbackHeader value) { + this.callbackHeader = value; + } + + /** + * Gets the value of the requestData property. + * + * @return + * possible object is + * {@link Object } + * + */ + public Object getRequestData() { + return requestData; + } + + /** + * Sets the value of the requestData property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setRequestData(Object value) { + this.requestData = value; + } + + @Override + public String toString() { + try { + JAXBContext ctx = JAXBContext.newInstance("org.openecomp.mso.adapters.sdnc.client"); + Marshaller m = ctx.createMarshaller(); + m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); + StringWriter w = new StringWriter(); + m.marshal(this, w); + return (w.toString()); + } + catch (Exception e) + { + msoLogger.error(MessageEnum.RA_MARSHING_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception - MARSHING_ERROR", e); + } + return(""); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java new file mode 100644 index 0000000000..8b56932769 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortType.java @@ -0,0 +1,57 @@ +/*- + * ============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.client.sdnc.sync; + + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.bind.annotation.XmlSeeAlso; + +import org.openecomp.mso.client.sdnc.beans.SDNCRequest; + + +/** + * This class was generated by Apache CXF 2.7.11.redhat-3 + * 2015-01-27T18:25:50.914-05:00 + * Generated source version: 2.7.11.redhat-3 + * + */ +//BPEL SDNCAdapter SOAP WebService - impl class in impl pkg +@WebService(targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/wsdl/v1", name = "SDNCAdapterPortType") +@XmlSeeAlso({ObjectFactory.class}) +@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +public interface SDNCAdapterPortType { + + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterResponse") + @WebMethod(operationName = "SDNCAdapter") + public SDNCAdapterResponse sdncAdapter( + @WebParam(partName = "SDNCAdapterRequest", name = "SDNCAdapterRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1") + SDNCAdapterRequest sdncAdapterRequest + ); + + @WebMethod + public void healthCheck(); + + SDNCAdapterResponse sdncAdapter(SDNCRequest bpelRequest); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java new file mode 100644 index 0000000000..3d9aab666a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterPortTypeImpl.java @@ -0,0 +1,108 @@ +/*- + * ============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.client.sdnc.sync; + +import javax.annotation.PostConstruct; +import javax.jws.WebService; +import javax.servlet.http.HttpServletResponse; + +import org.openecomp.mso.client.sdnc.beans.SDNCRequest; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +//BPEL SDNCAdapter SOAP Web Service implementation +@WebService(serviceName = "SDNCAdapterService", endpointInterface = "org.openecomp.mso.client.sdnc.sync.SDNCAdapterPortType", targetNamespace = "http://org.openecomp/workflow/sdnc/ad") +public class SDNCAdapterPortTypeImpl implements SDNCAdapterPortType { + + private MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory(); + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + private static final String LOG_SERVICE_NAME = "MSO-BPMN:MSO-SDNCAdapter."; + private static final String LOG_REPLY_NAME = "MSO-SDNCAdapter:MSO-BPMN."; + public static final String MSO_PROP_SDNC_ADAPTER="MSO_PROP_SDNC_ADAPTER"; + + @PostConstruct + public void init () { + msoLogger.info(MessageEnum.RA_INIT_SDNC_ADAPTER, "SDNC", "SDNCAdapterPortType"); + } + + /** + * Health Check web method. Does nothing but return to show the adapter is deployed. + */ + @Override + public void healthCheck () + { + msoLogger.debug("Health check call in SDNC Adapter"); + } + + public static String getProperty(String key, String defaultValue, MsoPropertiesFactory msoPropertiesFactoryp) { + String value; + try { + value = msoPropertiesFactoryp.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getProperty(key, defaultValue); + } catch (MsoPropertiesException e) { + msoLogger.error (MessageEnum.NO_PROPERTIES, "Unknown. Mso Properties ID not found in cache: " + MSO_PROP_SDNC_ADAPTER, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - Mso Properties ID not found in cache", e); + return null; + } + msoLogger.debug("Config read for " + MSO_PROP_SDNC_ADAPTER + " - key:" + key + " value:" + value); + return value; + } + + @Override + public SDNCAdapterResponse sdncAdapter(SDNCRequest bpelRequest) { + String bpelReqId = bpelRequest.getRequestId(); + String callbackUrl = bpelRequest.getCallbackUrl(); + long startTime = System.currentTimeMillis (); + MsoLogger.setLogContext(SDNCRequestIdUtil.getSDNCOriginalRequestId (bpelReqId), bpelRequest.getSvcInstanceId()); + MsoLogger.setServiceName (bpelRequest.getSvcAction().toString()); + msoLogger.info(MessageEnum.RA_RECEIVE_BPEL_REQUEST, bpelReqId, callbackUrl, "SDNC", ""); + + SDNCSyncRpcClient sdncClient = new SDNCSyncRpcClient(bpelRequest,msoPropertiesFactory); + long subStartTime = System.currentTimeMillis (); + try { + Thread sdncClientThread = new Thread(sdncClient); + sdncClientThread.start(); + } + catch (Exception e){ + String respMsg = "Error sending request to SDNC. Failed to start SDNC Client thread " + e.getMessage(); + msoLogger.error(MessageEnum.RA_SEND_REQUEST_SDNC_ERR, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception sending request to SDNC. Failed to start SDNC Client thread", e); + alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, respMsg); + SDNCResponse sdncResp = new SDNCResponse(bpelReqId); + sdncResp.setRespCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + sdncResp.setRespMsg(respMsg); + } + + msoLogger.debug("Sending synchronous response to BPEL"); + SDNCAdapterResponse wsResp = new SDNCAdapterResponse(); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + return (wsResp); + } + + @Override + public org.openecomp.mso.client.sdnc.sync.SDNCAdapterResponse sdncAdapter( + org.openecomp.mso.client.sdnc.sync.SDNCAdapterRequest sdncAdapterRequest) { + // TODO Auto-generated method stub + return null; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java new file mode 100644 index 0000000000..5beedb12be --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequest.java @@ -0,0 +1,128 @@ +/*- + * ============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.client.sdnc.sync; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{http://org.openecomp/workflow/sdnc/adapter/schema/v1}RequestHeader"/>
+ *         <element name="RequestData" type="{http://www.w3.org/2001/XMLSchema}anyType"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +//BPEL to SDNCAdapter request +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestHeader", + "requestData" +}) +@XmlRootElement(name = "SDNCAdapterRequest") +public class SDNCAdapterRequest { + + @XmlElement(name = "RequestHeader", required = true) + protected RequestHeader requestHeader; + @XmlElement(name = "RequestData", required = true) + protected Object requestData; + + /** + * Gets the value of the requestHeader property. + * + * @return + * possible object is + * {@link RequestHeader } + * + */ + public RequestHeader getRequestHeader() { + return requestHeader; + } + + /** + * Sets the value of the requestHeader property. + * + * @param value + * allowed object is + * {@link RequestHeader } + * + */ + public void setRequestHeader(RequestHeader value) { + this.requestHeader = value; + } + + /** + * Gets the value of the requestData property. + * + * @return + * possible object is + * {@link Object } + * + */ + public Object getRequestData() { + return requestData; + } + + /** + * Sets the value of the requestData property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setRequestData(Object value) { + this.requestData = value; + } + + @Override + public String toString() { + + String rd = ""; + if (requestData != null) + { + Node node = (Node) requestData; + Document doc = node.getOwnerDocument(); + rd = Utils.domToStr(doc); + } + return "SDNCAdapterRequest [requestHeader=" + requestHeader.toString() + + ", requestData=" + rd + "]"; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java new file mode 100644 index 0000000000..4625bfb74f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterResponse.java @@ -0,0 +1,53 @@ +/*- + * ============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.client.sdnc.sync; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +//SDNCAdapter to BPEL Sync Response(ACK) - async response(s) follow +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "SDNCAdapterResponse") +public class SDNCAdapterResponse { + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java new file mode 100644 index 0000000000..08d3bdbad7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterPortType.java @@ -0,0 +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.client.sdnc.sync; + + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.bind.annotation.XmlSeeAlso; + + + +//SDNCAdapter to BPEL Async response WEB Service +@WebService(targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", name = "SDNCCallbackAdapterPortType") +@XmlSeeAlso({ObjectFactory.class}) +@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) +public interface SDNCCallbackAdapterPortType { + + @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse") + @WebMethod(operationName = "SDNCAdapterCallback") + public SDNCAdapterResponse sdncAdapterCallback( + @WebParam(partName = "SDNCAdapterCallbackRequest", name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/schema/v1") + SDNCAdapterCallbackRequest sdncAdapterCallbackRequest + ); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java new file mode 100644 index 0000000000..0e65a3080f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCCallbackAdapterService.java @@ -0,0 +1,126 @@ +/*- + * ============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.client.sdnc.sync; + + +import java.net.URL; + +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceFeature; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +/** + * This class was generated by Apache CXF 2.7.11.redhat-3 + * 2015-01-28T11:07:02.074-05:00 + * Generated source version: 2.7.11.redhat-3 + * + */ +//SDNCAdapter to BPEL Async response WEB Service +@WebServiceClient(name = "SDNCCallbackAdapterService", + wsdlLocation = "main/resources/SDNCCallbackAdapter.wsdl", + targetNamespace = "http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1") +public class SDNCCallbackAdapterService extends Service { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + public final static URL WSDL_LOCATION; + public final static QName SERVICE = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterService"); + public final static QName SDNCCallbackAdapterSoapHttpPort = new QName("http://org.openecomp/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterSoapHttpPort"); + static { + URL wsdlUrl = null; + try { + wsdlUrl = Thread.currentThread().getContextClassLoader().getResource("main/resources/SDNCCallbackAdapter.wsdl"); + //wsdlUrl = SDNCCallbackAdapterService.class.getClassLoader().getResource("SDNCCallbackAdapter.wsdl"); + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); + } + if(wsdlUrl == null) { + msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "WSDL not found"); + } else { + try { + msoLogger.info(MessageEnum.RA_PRINT_URL, "SDNCCallbackAdapter.wsdl", wsdlUrl.toURI().toString(), "SDNC", ""); + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "SDNCCallbackAdapter.wsdl", "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - URL convention problem", e); + } + } + WSDL_LOCATION = wsdlUrl; + } + + public SDNCCallbackAdapterService(URL wsdlLocation) { + super(wsdlLocation, SERVICE); + } + + public SDNCCallbackAdapterService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public SDNCCallbackAdapterService() { + super(WSDL_LOCATION, SERVICE); + } + + //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 + //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 + //compliant code instead. + public SDNCCallbackAdapterService(WebServiceFeature ... features) { + super(WSDL_LOCATION, SERVICE, features); + } + + //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 + //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 + //compliant code instead. + public SDNCCallbackAdapterService(URL wsdlLocation, WebServiceFeature ... features) { + super(wsdlLocation, SERVICE, features); + } + + //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 + //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 + //compliant code instead. + public SDNCCallbackAdapterService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * + * @return + * returns SDNCCallbackAdapterPortType + */ + @WebEndpoint(name = "SDNCCallbackAdapterSoapHttpPort") + public SDNCCallbackAdapterPortType getSDNCCallbackAdapterSoapHttpPort() { + return super.getPort(SDNCCallbackAdapterSoapHttpPort, SDNCCallbackAdapterPortType.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns SDNCCallbackAdapterPortType + */ + @WebEndpoint(name = "SDNCCallbackAdapterSoapHttpPort") + public SDNCCallbackAdapterPortType getSDNCCallbackAdapterSoapHttpPort(WebServiceFeature... features) { + return super.getPort(SDNCCallbackAdapterSoapHttpPort, SDNCCallbackAdapterPortType.class, features); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java new file mode 100644 index 0000000000..d905748591 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCRequestIdUtil.java @@ -0,0 +1,39 @@ +/*- + * ============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.client.sdnc.sync; + + +public class SDNCRequestIdUtil { + // Add private constructor to prevent instance creation. + private SDNCRequestIdUtil () {} + + public static String getSDNCOriginalRequestId (String newRequestId) { + + // Camunda scripts will add postfix, such as -1, -2, on the original requestID, to make sure requestID is unique while sending request to SDNC + // In order to use the unique requestID in logging, need to remove the postfix added by the Camunda scripts + // Verify whether the requestId is a valid UUID with postfix (-1, -2). If yes, it should contain 5 times char '-', since valid UUID contains 4 times '-' + // If the requestId is not a valid UUID with postfix, we do nothing + if (newRequestId.split("-").length == 6) { + return newRequestId.substring(0, newRequestId.lastIndexOf('-')); + } + return newRequestId; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java new file mode 100644 index 0000000000..850f5b4734 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCResponse.java @@ -0,0 +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.client.sdnc.sync; + + +import java.io.Serializable; + +public class SDNCResponse implements Serializable { + + private static final long serialVersionUID = 1L; + private String reqId = null; + private int respCode = 0; + private String respMsg = null; + private String sdncResp = null; + + public SDNCResponse(String reqId) { + this.reqId = reqId; + } + public SDNCResponse(String reqId, int respCode, String respMsg) { + this.reqId = reqId; + this.respCode = respCode; + this.respMsg = respMsg; + } + + public String getReqId() { + return reqId; + } + public void setReqId(String reqId) { + this.reqId = reqId; + } + public int getRespCode() { + return respCode; + } + public void setRespCode(int respCode) { + this.respCode = respCode; + } + public String getRespMsg() { + return respMsg; + } + public void setRespMsg(String respMsg) { + this.respMsg = respMsg; + } + public String getSdncResp() { + return sdncResp; + } + public void setSdncResp(String sdncResp) { + this.sdncResp = sdncResp; + } + + @Override + public String toString() { + return "SDNCResponse [reqId=" + reqId + ", respCode=" + respCode + + ", respMsg=" + respMsg + ", sdncResp=" + sdncResp + "]"; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java new file mode 100644 index 0000000000..ce9b706760 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/SDNCSyncRpcClient.java @@ -0,0 +1,317 @@ +/*- + * ============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.client.sdnc.sync; + + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.XMLConstants; +import javax.xml.bind.DatatypeConverter; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.ws.BindingProvider; +import javax.xml.ws.handler.MessageContext; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathFactory; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.json.JSONArray; +import org.json.JSONObject; +import org.openecomp.mso.client.sdnc.beans.SDNCRequest; +import org.openecomp.mso.client.sdnc.beans.SDNCSvcAction; +import org.openecomp.mso.client.sdnc.beans.SDNCSvcOperation; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +//SDNCAdapter to SDNC Rest Client +public class SDNCSyncRpcClient implements Runnable { + + private MsoPropertiesFactory msoPropertiesFactory; + + private SDNCRequest bpelRequest; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + public static final String MSO_PROP_SDNC_ADAPTER="MSO_PROP_SDNC_ADAPTER"; + + + public SDNCSyncRpcClient(SDNCRequest bpelRequest,MsoPropertiesFactory msoPropFactory) { + this.bpelRequest = bpelRequest; + msoPropertiesFactory = msoPropFactory; + } + + @Override + public void run() + { + String action = bpelRequest.getSvcAction().toString(); + String operation = bpelRequest.getSvcOperation().toString(); + String bpelReqId = bpelRequest.getRequestId(); + String msoAction = bpelRequest.getMsoAction(); + MsoLogger.setLogContext(SDNCRequestIdUtil.getSDNCOriginalRequestId (bpelReqId), bpelRequest.getSvcInstanceId()); + MsoLogger.setServiceName("SDNCRestClient"); + String sdncReqBody = ""; + + msoLogger.debug("BPEL Request:" + bpelRequest.toString()); + RequestTunables rt = new RequestTunables(bpelReqId, msoAction, operation, action, msoPropertiesFactory); + rt.setTunables(); + rt.setSdncaNotificationUrl(SDNCAdapterPortTypeImpl.getProperty(Constants.MY_URL_PROP, Constants.DEFAULT_MY_URL,msoPropertiesFactory)); + + if ("POST".equals(rt.getReqMethod())) { + try { + DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + InputSource is = new InputSource(); + is.setCharacterStream(new StringReader(bpelRequest.getRequestData())); + Document reqDoc = db.parse(is); + sdncReqBody = Utils.genSdncReq(reqDoc, rt); + }catch(Exception ex) { + throw new IllegalStateException(); + } + } else if("PUT".equals(rt.getReqMethod())) { + try { + DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + InputSource is = new InputSource(); + is.setCharacterStream(new StringReader(bpelRequest.getRequestData())); + Document reqDoc = db.parse(is); + sdncReqBody = Utils.genSdncPutReq(reqDoc, rt); + }catch(Exception ex) { + throw new IllegalStateException(); + } + } + long sdncStartTime = System.currentTimeMillis(); + SDNCResponse sdncResp = getSdncResp(sdncReqBody, rt, msoPropertiesFactory); + msoLogger.recordMetricEvent (sdncStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from SDNC", "SDNC", action + "." + operation, null); + msoLogger.debug ("Got the SDNC Code : " + sdncResp.getRespCode()); + msoLogger.debug ("Got the SDNC Response Message:" + sdncResp.getRespMsg()); + validateSDNCResponse(sdncResp.getSdncResp()); + return; + } + + public static SDNCResponse getSdncResp(String sdncReqBody, RequestTunables rt, MsoPropertiesFactory msoPropertiesFactoryp) { + URL url; + HttpURLConnection con = null; + DataOutputStream out = null; + BufferedReader in = null; + SDNCResponse sdncResp = new SDNCResponse(rt.getReqId()); + StringBuffer response = new StringBuffer(); + + msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC, rt.toString(), "SDNC", ""); + msoLogger.debug("SDNC Request Body:\n" + sdncReqBody); + + try { + msoLogger.debug("url is: " + rt.getSdncUrl()); + url = new URL(rt.getSdncUrl()); + con = (HttpURLConnection) url.openConnection(); + con.setConnectTimeout(Integer.parseInt(SDNCAdapterPortTypeImpl.getProperty(Constants.SDNC_CONNECTTIME_PROP, "2000",msoPropertiesFactoryp))); + con.setReadTimeout(Integer.parseInt(rt.getTimeout())); + con.setRequestProperty("Accept", "application/json"); + String userCredentials = msoPropertiesFactoryp.getMsoJavaProperties(MSO_PROP_SDNC_ADAPTER).getEncryptedProperty(Constants.SDNC_AUTH_PROP, Constants.DEFAULT_SDNC_AUTH, Constants.ENCRYPTION_KEY); + + String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); + con.setRequestProperty ("Authorization", basicAuth); + con.setRequestMethod(rt.getReqMethod()); + + if ("POST".equals(rt.getReqMethod()) || "PUT".equals(rt.getReqMethod())) { + con.setRequestProperty("Content-type", "application/json"); + con.setRequestProperty("Content-length",String.valueOf(sdncReqBody.length())); + con.setDoOutput(true); + out = new DataOutputStream(con.getOutputStream()); + out.writeBytes(sdncReqBody); + out.flush(); + out.close(); + } + + //Get response + sdncResp.setRespCode(con.getResponseCode()); + sdncResp.setRespMsg(con.getResponseMessage()); + + if (con.getResponseCode()>= 200 && con.getResponseCode()<=299) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + String inputLine; + //Not parsing the response -it contains a responseHdr section and data section + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + } + + sdncResp.setSdncResp(response.toString()); + msoLogger.info(MessageEnum.RA_RESPONSE_FROM_SDNC, sdncResp.toString(), "SDNC", ""); + return(sdncResp); + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception processing request to SDNC", e); + //default + sdncResp.setRespCode(HttpURLConnection.HTTP_INTERNAL_ERROR); + String respMsg = "Error processing request to SDNC. "; + String sdncErrMsg = null; + + if (e instanceof java.net.SocketTimeoutException ) { + sdncResp.setRespCode(HttpURLConnection.HTTP_CLIENT_TIMEOUT); + respMsg = "Request to SDNC timed out. "; + } + if (con != null) { + try { //e1 + if (con.getResponseCode() != HttpURLConnection.HTTP_OK) //seen in SocketException connection reset + sdncResp.setRespCode(con.getResponseCode()); + respMsg = respMsg + con.getResponseMessage() + ". "; + InputStream is = con.getErrorStream(); + if (is != null) { + XPathFactory xpathFactory = XPathFactory.newInstance(); + XPath xpath = xpathFactory.newXPath(); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true); + DocumentBuilder db; + Document doc = null; + try { //e2 + db = dbf.newDocumentBuilder(); + doc = db.parse(is); + NodeList errors = (NodeList)xpath.evaluate("errors/error", doc, XPathConstants.NODESET); + for (int i = 0; i < errors.getLength(); i++) { + Element error = (Element) errors.item(i); + String eType = null; + try { + eType = xpath.evaluate("error-type", error); + sdncErrMsg = ". SDNC Returned-[error-type:" + eType; + } catch (Exception e3) { + msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); + } + + String eTag = null; + try { + eTag = xpath.evaluate( "error-tag", error); + sdncErrMsg = sdncErrMsg + ", error-tag:" + eTag; + } catch (Exception e3) { + msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); + } + + String eMsg = null; + try { + eMsg = xpath.evaluate("error-message", error); + sdncErrMsg = sdncErrMsg + ", error-message:" + eMsg + "]"; + } catch (Exception e3) { + msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while evaluate xpath", e3); + } + } + } catch (Exception e2) { + msoLogger.error (MessageEnum.RA_ANALYZE_ERROR_EXC, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while analyse error", e2); + } + } //is != null + } catch (Exception e1) { + msoLogger.error (MessageEnum.RA_ERROR_GET_RESPONSE_SDNC, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while get SDNC response", e1); + } + } //con != null + + if (e.getMessage() != null) { + respMsg = respMsg + e.getMessage(); + } + if (sdncErrMsg != null) { + respMsg = respMsg + sdncErrMsg; + } + + sdncResp.setRespMsg(respMsg); + + msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with SDNC", e); + alarmLogger.sendAlarm("MsoInternalError", MsoAlarmLogger.CRITICAL, respMsg); + return(sdncResp); + } + finally { + if (con != null) { + con.disconnect(); + } + } + } + public void validateSDNCResponse (String sdncResponse){ + String msg; + msoLogger.debug ("Starting validate sdnc response"); + String responseMessage = ""; + String responseCode = ""; + if (sdncResponse != null || !sdncResponse.equals("")){ + try{ + msoLogger.debug ("Got the SDNC Response: " + sdncResponse); + JSONObject jsonObj = new JSONObject(sdncResponse); + msoLogger.debug ("jsonObj has been created"); + + JSONObject requestData = jsonObj.getJSONObject("v1:RequestData"); + JSONObject output = requestData.getJSONObject("output"); + try{ + responseMessage = output.getString("response-message"); + responseCode = output.getString("response-code"); + } catch (Exception ex) { + msoLogger.debug("Response not in lower hyphen"); + } + if(responseMessage.equals("")&&responseCode.equals("")){ + try{ + responseMessage = output.getString("ResponseMessage"); + responseCode = output.getString("ResponseCode"); + } catch (Exception ex) { + msoLogger.debug("Response does not exist"); + } + } + msoLogger.debug("ResponseMessage is: " + responseMessage); + msoLogger.debug("Response Code is: " + responseCode); + if(responseMessage.equals("")){ + msg = "Error from SDNC: Response Message is empty."; + msoLogger.debug(msg); + throw new IllegalStateException(msg); + } + + if(responseCode.equals("")){ + responseCode = "0"; + } + + int code = Integer.parseInt(responseCode); + if(code >=200 && code <=299 || code ==0){ + msoLogger.debug ("Successful Response from SDNC"); + + } else { + msg = "Error from SDNC: Code is not 200-299 or 0."; + msoLogger.debug(msg); + throw new IllegalStateException(msg); + } + } catch (Exception ex) { + msg = "Validate SDNC Response has failed."; + msoLogger.debug(msg); + throw new IllegalStateException(msg); + } + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java new file mode 100644 index 0000000000..7457b59390 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdnc/sync/Utils.java @@ -0,0 +1,195 @@ +/*- + * ============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.client.sdnc.sync; + + +import java.io.StringWriter; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; +public class Utils { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + + public static String genSdncReq(Document reqDoc, RequestTunables rt) { + try { + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + //NewDoc for output + //Root + Document newdoc = db.newDocument(); + Element root = newdoc.createElementNS(rt.getNamespace(), "input"); + newdoc.appendChild(root); + + //Header + Element hdr = newdoc.createElement(rt.getHeaderName()); + root.appendChild(hdr); + + String elemData = rt.getReqId(); + Element hdrChild; + if (elemData != null && elemData.length() > 0) + { + hdrChild = newdoc.createElement("svc-request-id"); + hdrChild.appendChild(newdoc.createTextNode(elemData)); + hdr.appendChild(hdrChild); + } + + elemData = rt.getAction(); + if (elemData != null && elemData.length() > 0) + { + hdrChild = newdoc.createElement("svc-action"); + hdrChild.appendChild(newdoc.createTextNode(elemData)); + hdr.appendChild(hdrChild); + } + + elemData = rt.getSdncaNotificationUrl(); + if (elemData != null && elemData.length() > 0) + { + hdrChild = newdoc.createElement("svc-notification-url"); + hdrChild.appendChild(newdoc.createTextNode(elemData)); + hdr.appendChild(hdrChild); + } + + //RequestData + NodeList nodes = reqDoc.getDocumentElement().getChildNodes(); + for (int i = 0; i < nodes.getLength(); i++) { + Node n = nodes.item(i); + Node newNode = newdoc.importNode(n, true); + root.appendChild(newNode); + } + + String s = domToStr(newdoc); + msoLogger.debug("Formatted SdncReq:\n" + s); + return (s); + + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in genSdncReq", e); + } + return(null); + } + + public static String genSdncPutReq(Document reqDoc, RequestTunables rt) { + try { + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + //NewDoc for output + //Root + Document newdoc = db.newDocument(); + + //RequestData + NodeList nodes = reqDoc.getDocumentElement().getChildNodes(); + + + Element root = newdoc.createElement(nodes.item(0).getNodeName()); + newdoc.appendChild(root); + + NodeList childNodes = nodes.item(0).getChildNodes(); + for (int i = 0; i < childNodes.getLength(); i++) { + Node n = childNodes.item(i); + Node newNode = newdoc.importNode(n, true); + root.appendChild(newNode); + } + + String s = domToStr(newdoc); + msoLogger.debug("Formatted SdncPutReq:\n" + s); + return (s); + + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception in genSdncPutReq", e); + } + return(null); + } + + public static String genMsoFailResp(SDNCResponse resp) { + try { + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + //NewDoc for output + //Root + Document newdoc = db.newDocument(); + Element root = newdoc.createElement("output"); + newdoc.appendChild(root); + + Element elem1 = newdoc.createElement("svc-request-id"); + elem1.appendChild(newdoc.createTextNode(resp.getReqId())); + root.appendChild(elem1); + + Element elem2 = newdoc.createElement("response-code"); + elem2.appendChild(newdoc.createTextNode(String.valueOf(resp.getRespCode()))); + root.appendChild(elem2); + + Element elem3 = newdoc.createElement("response-message"); + elem3.appendChild(newdoc.createTextNode(String.valueOf(resp.getRespMsg()))); + root.appendChild(elem3); + + String s = domToStr(newdoc); + msoLogger.debug("Formatted SdncReq:" + s); + return (s); + + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_RESPONSE, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception in genMsoFailResp", e); + } + return(null); + } + + + public static String domToStr(Document doc) + { + if (doc != null) + { + try { + DOMSource ds = new DOMSource(doc); + StringWriter sw = new StringWriter(); + StreamResult sr = new StreamResult(sw); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer t = tf.newTransformer(); + //t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");// + t.transform(ds, sr); + String s = sw.toString(); + + // This is an awful fix for now but we don't want that xmlns="" to be generated + s = s.replaceAll("xmlns=\"\"", ""); + return(s); + } catch (Exception e) { + msoLogger.error(MessageEnum.RA_ERROR_CONVERT_XML2STR, "", "", MsoLogger.ErrorCode.DataError, "Exception - domToStr", e); + } + } + return(null); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java deleted file mode 100644 index df30e43822..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidator.java +++ /dev/null @@ -1,37 +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.client.sdno; - -import java.io.IOException; - -public interface SDNOValidator { - - /** - * Issues a health diagnostic request for a given vnf to SDN-O - * - * @param vnfId - * @param requestingUserId - * @throws IOException - * @throws Exception - */ - public void healthDiagnostic(String vnfId, String requestingUserId) throws IOException, Exception; - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.java deleted file mode 100644 index bdb4aa94ee..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/SDNOValidatorImpl.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.client.sdno; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; - -import org.openecomp.mso.client.dmaap.Consumer; -import org.openecomp.mso.client.dmaap.DmaapConsumer; -import org.openecomp.mso.client.dmaap.DmaapPublisher; -import org.openecomp.mso.client.exceptions.SDNOException; -import org.openecomp.mso.jsonpath.JsonPathUtil; - -public class SDNOValidatorImpl implements SDNOValidator { - - private final static String aafUserName = "something"; - private final static String clientName = "MSO"; - private final static String healthDiagnosticPath = "body.output.response-healthdiagnostic"; - private final static String producerFilePath = ""; - private String uuid; - private boolean continuePolling = true; - @Override - public void healthDiagnostic(String vnfName, String uuid) { - //Query A&AI data - // setup SDNO Entity - //Call SDNO for Health Diagnostic - //create producer file for MRClient https://wiki.web.att.com/display/MessageRouter/DMaaP_MR_JavaReferenceClient - // final MRBatchingPublisher pub = MRClientFactory.createBatchingPublisher(producerFilePath); - // pub.send("Mypartitionkey",JSON.toString(object)); - //create consumer file for MRClient https://wiki.web.att.com/display/MessageRouter/DMaaP_MR_JavaReferenceClient - //check for error in subscription feed filter via jsonpath - //block and continue to poll waiting for response - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java deleted file mode 100644 index 26c74b0615..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Body.java +++ /dev/null @@ -1,77 +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.client.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "input" -}) -public class Body implements Serializable -{ - - @JsonProperty("input") - private Input input; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = 9101706044452851559L; - - @JsonProperty("input") - public Input getInput() { - return input; - } - - @JsonProperty("input") - public void setInput(Input input) { - this.input = input; - } - - public Body withInput(Input input) { - this.input = input; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public Body withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java deleted file mode 100644 index 579f481ba8..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/Input.java +++ /dev/null @@ -1,79 +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.client.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "request-healthdiagnostic", - "request-hd-custom" -}) -public class Input implements Serializable -{ - - @JsonProperty("request-healthdiagnostic") - private RequestHealthDiagnostic RequestHealthDiagnostic; - - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = 7155546785389227528L; - - @JsonProperty("request-healthdiagnostic") - public RequestHealthDiagnostic getRequestHealthDiagnostic() { - return RequestHealthDiagnostic; - } - - @JsonProperty("request-healthdiagnostic") - public void setRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { - this.RequestHealthDiagnostic = RequestHealthDiagnostic; - } - - public Input withRequestHealthDiagnostic(RequestHealthDiagnostic RequestHealthDiagnostic) { - this.RequestHealthDiagnostic = RequestHealthDiagnostic; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public Input withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java deleted file mode 100644 index 2cddd0331e..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/RequestHealthDiagnostic.java +++ /dev/null @@ -1,185 +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.client.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "request-client-name", - "request-node-name", - "request-node-ip", - "request-id", - "request-user-id", - "request-node-type", - "health-diagnostic-code" -}) -public class RequestHealthDiagnostic implements Serializable -{ - - @JsonProperty("request-client-name") - private String requestClientName; - @JsonProperty("request-node-name") - private String requestNodeName; - @JsonProperty("request-node-ip") - private String requestNodeIp; - @JsonProperty("request-id") - private String requestId; - @JsonProperty("request-user-id") - private String requestUserId; - @JsonProperty("request-node-type") - private String requestNodeType; - @JsonProperty("health-diagnostic-code") - private String healthDiagnosticCode; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = 1166788526178388021L; - - @JsonProperty("request-client-name") - public String getRequestClientName() { - return requestClientName; - } - - @JsonProperty("request-client-name") - public void setRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - } - - public RequestHealthDiagnostic withRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - return this; - } - - @JsonProperty("request-node-name") - public String getRequestNodeName() { - return requestNodeName; - } - - @JsonProperty("request-node-name") - public void setRequestNodeName(String requestNodeName) { - this.requestNodeName = requestNodeName; - } - - public RequestHealthDiagnostic withRequestNodeName(String requestNodeName) { - this.requestNodeName = requestNodeName; - return this; - } - - @JsonProperty("request-node-ip") - public String getRequestNodeIp() { - return requestNodeIp; - } - - @JsonProperty("request-node-ip") - public void setRequestNodeIp(String requestNodeIp) { - this.requestNodeIp = requestNodeIp; - } - - public RequestHealthDiagnostic withRequestNodeIp(String requestNodeIp) { - this.requestNodeIp = requestNodeIp; - return this; - } - - @JsonProperty("request-id") - public String getRequestId() { - return requestId; - } - - @JsonProperty("request-id") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public RequestHealthDiagnostic withRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - @JsonProperty("request-user-id") - public String getRequestUserId() { - return requestUserId; - } - - @JsonProperty("request-user-id") - public void setRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - } - - public RequestHealthDiagnostic withRequestUserId(String requestUserId) { - this.requestUserId = requestUserId; - return this; - } - - @JsonProperty("request-node-type") - public String getRequestNodeType() { - return requestNodeType; - } - - @JsonProperty("request-node-type") - public void setRequestNodeType(String requestNodeType) { - this.requestNodeType = requestNodeType; - } - - public RequestHealthDiagnostic withRequestNodeType(String requestNodeType) { - this.requestNodeType = requestNodeType; - return this; - } - - @JsonProperty("health-diagnostic-code") - public String getHealthDiagnosticCode() { - return healthDiagnosticCode; - } - - @JsonProperty("health-diagnostic-code") - public void setHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - } - - public RequestHealthDiagnostic withHealthDiagnosticCode(String healthDiagnosticCode) { - this.healthDiagnosticCode = healthDiagnosticCode; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public RequestHealthDiagnostic withAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java deleted file mode 100644 index 976f5b9a33..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/ResultInfo.java +++ /dev/null @@ -1,116 +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.client.sdno.beans; - -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ -"client-name", -"code", -"processing-host", -"request-id", -"status" -}) -public class ResultInfo { - -@JsonProperty("client-name") -private String clientName; -@JsonProperty("code") -private String code; -@JsonProperty("processing-host") -private String processingHost; -@JsonProperty("request-id") -private String requestId; -@JsonProperty("status") -private String status; -@JsonIgnore -private Map additionalProperties = new HashMap<>(); - -@JsonProperty("client-name") -public String getClientName() { -return clientName; -} - -@JsonProperty("client-name") -public void setClientName(String clientName) { -this.clientName = clientName; -} - -@JsonProperty("code") -public String getCode() { -return code; -} - -@JsonProperty("code") -public void setCode(String code) { -this.code = code; -} - -@JsonProperty("processing-host") -public String getProcessingHost() { -return processingHost; -} - -@JsonProperty("processing-host") -public void setProcessingHost(String processingHost) { -this.processingHost = processingHost; -} - -@JsonProperty("request-id") -public String getRequestId() { -return requestId; -} - -@JsonProperty("request-id") -public void setRequestId(String requestId) { -this.requestId = requestId; -} - -@JsonProperty("status") -public String getStatus() { -return status; -} - -@JsonProperty("status") -public void setStatus(String status) { -this.status = status; -} - -@JsonAnyGetter -public Map getAdditionalProperties() { -return this.additionalProperties; -} - -@JsonAnySetter -public void setAdditionalProperty(String name, Object value) { -this.additionalProperties.put(name, value); -} - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java deleted file mode 100644 index 8505ec9a74..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/beans/SDNO.java +++ /dev/null @@ -1,131 +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.client.sdno.beans; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "operation", - "nodeLoc", - "nodeType", - "body" -}) -public class SDNO implements Serializable -{ - - @JsonProperty("operation") - private String operation; - @JsonProperty("nodeLoc") - private String nodeLoc; - @JsonProperty("nodeType") - private String nodeType; - @JsonProperty("body") - private Body body; - @JsonIgnore - private Map additionalProperties = new HashMap<>(); - private final static long serialVersionUID = -5303297382564282650L; - - @JsonProperty("operation") - public String getOperation() { - return operation; - } - - @JsonProperty("operation") - public void setOperation(String operation) { - this.operation = operation; - } - - @JsonProperty("nodeLoc") - public String getNodeLoc() { - return nodeLoc; - } - - @JsonProperty("nodeLoc") - public void setNodeLoc(String nodeLoc) { - this.nodeLoc = nodeLoc; - } - - public SDNO withNodeLoc(String nodeLoc) { - this.nodeLoc = nodeLoc; - return this; - } - - public SDNO withOperation(String operation) { - this.operation = operation; - return this; - } - - @JsonProperty("nodeType") - public String getNodeType() { - return nodeType; - } - - @JsonProperty("nodeType") - public void setNodeType(String nodeType) { - this.nodeType = nodeType; - } - - public SDNO withNodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - @JsonProperty("body") - public Body getBody() { - return body; - } - - @JsonProperty("body") - public void setBody(Body body) { - this.body = body; - } - - public SDNO withBody(Body body) { - this.body = body; - return this; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @JsonAnySetter - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - - public SDNO SDNO (String name, Object value) { - this.additionalProperties.put(name, value); - return this; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java deleted file mode 100644 index f23d882b53..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapConsumer.java +++ /dev/null @@ -1,156 +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.client.sdno.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; - -import org.openecomp.mso.client.dmaap.DmaapConsumer; -import org.openecomp.mso.client.exceptions.SDNOException; -import org.openecomp.mso.jsonpath.JsonPathUtil; - -public class SDNOHealthCheckDmaapConsumer extends DmaapConsumer { - - private final String uuid; - private boolean continuePolling = true; - private final static String healthDiagnosticPath = "body.output.*"; - - public SDNOHealthCheckDmaapConsumer() throws FileNotFoundException, IOException { - this("none"); - } - - public SDNOHealthCheckDmaapConsumer(String uuid) throws FileNotFoundException, IOException { - super(); - this.uuid = uuid; - } - - @Override - public String getUserName() { - return msoProperties.get("sdno.health-check.dmaap.username"); - } - - @Override - public String getPassword() { - return msoProperties.get("sdno.health-check.dmaap.password"); - } - - @Override - public String getTopic() { - return msoProperties.get("sdno.health-check.dmaap.subscriber.topic"); - } - - @Override - public boolean continuePolling() { - return continuePolling; - } - - @Override - public void stopProcessingMessages() { - continuePolling = false; - } - @Override - public void processMessage(String message) throws Exception { - if (isHealthDiagnostic(message, this.getRequestId())) { - if (!healthDiagnosticSuccessful(message)) { - Optional statusMessage = this.getStatusMessage(message); - if (statusMessage.isPresent()) { - throw new SDNOException("failed with message " + statusMessage.get()); - } else { - throw new SDNOException("failed with no status message"); - } - } else { - auditLogger.info("successful health diagnostic found for request: " + this.getRequestId()); - stopProcessingMessages(); - } - } - } - - @Override - public boolean isAccepted(String message) { - if (isResultInfo(message)) { - Optional code = isAccepted(message, this.getRequestId()); - if (code.isPresent()) { - if ("202".equals(code.get())) { - return true; - } else { - //TODO check other statuses 400 and 500 - } - } else { - //TODO throw error - } - } - - return false; - } - - @Override - public boolean isFailure(String message) { - if (isResultInfo(message)) { - Optional code = isFailure(message, this.getRequestId()); - if (code.isPresent()) { - if ("500".equals(code.get())) { - return true; - } else { - //TODO check other statuses 400 and 500 - } - } else { - //TODO throw error - } - } - - return false; - } - - @Override - public String getRequestId() { - return uuid; - } - - protected Optional isAccepted(String json, String uuid) { - return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='ACCEPTED' && @.request-id=='%s')].code", uuid)); - } - - protected Optional isFailure(String json, String uuid) { - return JsonPathUtil.getInstance().locateResult(json, String.format("$.result-info[?(@.status=='FAILURE' && @.request-id=='%s')].code", uuid)); - } - - protected boolean isResultInfo(String json) { - return JsonPathUtil.getInstance().pathExists(json, "$[?(@.result-info)]"); - } - - protected boolean isHealthDiagnostic(String json, String uuid) { - return JsonPathUtil.getInstance().pathExists(json, String.format("$[?(@.result-info.request-id=='%s')].%s", uuid, healthDiagnosticPath)); - } - - protected boolean healthDiagnosticSuccessful(String json) { - return JsonPathUtil.getInstance().pathExists(json, "$." + healthDiagnosticPath + "[?(@.response-status=='Success')]"); - } - - protected Optional getStatusMessage(String json) { - return JsonPathUtil.getInstance().locateResult(json, "$." + healthDiagnosticPath + ".error-message"); - } - - @Override - public int getMaximumElapsedTime() { - return 300000; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java deleted file mode 100644 index 73f06b8e58..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/sdno/dmaap/SDNOHealthCheckDmaapPublisher.java +++ /dev/null @@ -1,50 +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.client.sdno.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.openecomp.mso.client.dmaap.DmaapPublisher; - -public class SDNOHealthCheckDmaapPublisher extends DmaapPublisher { - - public SDNOHealthCheckDmaapPublisher() throws FileNotFoundException, IOException { - super(); - } - - @Override - public String getUserName() { - return msoProperties.get("sdno.health-check.dmaap.username"); - } - - @Override - public String getPassword() { - return msoProperties.get("sdno.health-check.dmaap.password"); - } - - @Override - public String getTopic() { - return msoProperties.get("sdno.health-check.dmaap.publisher.topic"); - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java deleted file mode 100644 index ca0d8e9d70..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/jsonpath/JsonPathUtil.java +++ /dev/null @@ -1,59 +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.jsonpath; - -import java.util.Optional; - -import com.jayway.jsonpath.Configuration; -import com.jayway.jsonpath.JsonPath; -import com.jayway.jsonpath.Option; - -import net.minidev.json.JSONArray; - -public class JsonPathUtil { - - - private final Configuration conf; - - private JsonPathUtil() { - conf = Configuration.defaultConfiguration().addOptions(Option.ALWAYS_RETURN_LIST, Option.SUPPRESS_EXCEPTIONS); - } - - private static class Helper { - private static final JsonPathUtil INSTANCE = new JsonPathUtil(); - } - - public static JsonPathUtil getInstance() { - return Helper.INSTANCE; - } - public boolean pathExists(String json, String jsonPath) { - return !JsonPath.using(conf).parse(json).read(jsonPath).isEmpty(); - } - - public Optional locateResult(String json, String jsonPath) { - final JSONArray result = JsonPath.using(conf).parse(json).read(jsonPath); - if (result.isEmpty()) { - return Optional.empty(); - } else { - return Optional.of((T)result.get(0)); - } - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml deleted file mode 100644 index 772867d3f2..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/processes.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - default - - false - true - - - - diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.openecomp.mso.client.RestProperties b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.openecomp.mso.client.RestProperties new file mode 100644 index 0000000000..2668367d16 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.openecomp.mso.client.RestProperties @@ -0,0 +1,2 @@ +org.openecomp.mso.client.restproperties.AAIPropertiesImpl +org.openecomp.mso.client.restproperties.PolicyRestPropertiesImpl \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.openecomp.mso.client.dmaap.DmaapProperties b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.openecomp.mso.client.dmaap.DmaapProperties new file mode 100644 index 0000000000..8010194263 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/META-INF/services/org.openecomp.mso.client.dmaap.DmaapProperties @@ -0,0 +1 @@ +org.openecomp.mso.client.dmaaproperties.DefaultDmaapPropertiesImpl \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/AppCClient.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/AppCClient.bpmn new file mode 100644 index 0000000000..fb25363a76 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/AppCClient.bpmn @@ -0,0 +1,127 @@ + + + + + SequenceFlow_1wz1rfg + + + + SequenceFlow_1wz1rfg + SequenceFlow_14vlkf4 + + + + SequenceFlow_1j937vi + + + + + SequenceFlow_14vlkf4 + SequenceFlow_1j937vi + + + + + SequenceFlow_1wi3avf + + + + SequenceFlow_1gq753e + + + + + SequenceFlow_1wi3avf + SequenceFlow_1gq753e + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/DecomposeService.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/DecomposeService.bpmn index 8a89b43cde..841964211e 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/DecomposeService.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/DecomposeService.bpmn @@ -11,7 +11,7 @@ SequenceFlow_0tgrn11 - + SequenceFlow_0g4aus9 diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn index a432417c21..481d1dfa6f 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/Homing.bpmn @@ -1,259 +1,259 @@ - - - - - SequenceFlow_1x9usa6 - - - SequenceFlow_1x9usa6 - SequenceFlow_10x3ocp - - - - - - SequenceFlow_1rf4vs8 - - - - SequenceFlow_00nlh7l - - - - SequenceFlow_00nlh7l - SequenceFlow_1rf4vs8 + + + + + SequenceFlow_1x9usa6 + + + SequenceFlow_1x9usa6 + SequenceFlow_10x3ocp + + + + + + SequenceFlow_1rf4vs8 + + + + SequenceFlow_00nlh7l + + + + SequenceFlow_00nlh7l + SequenceFlow_1rf4vs8 - - - - - - - SequenceFlow_0kamg53 - SequenceFlow_1o7154s +ex.processSubflowsBPMNException(execution)]]> + + + + + + + SequenceFlow_0kamg53 + SequenceFlow_1o7154s - - - SequenceFlow_0kamg53 - - - - SequenceFlow_1o7154s - - - - - - - SequenceFlow_043r3j8 - SequenceFlow_1h9opg9 - - - - SequenceFlow_10x3ocp - badResponse - goodResponse - - - - badResponse - SequenceFlow_0clfkld +ex.processJavaException(execution)]]> + + + SequenceFlow_0kamg53 + + + + SequenceFlow_1o7154s + + + + + + + SequenceFlow_043r3j8 + SequenceFlow_1h9opg9 + + + + SequenceFlow_10x3ocp + badResponse + goodResponse + + + + badResponse + SequenceFlow_0clfkld - - - - - SequenceFlow_0clfkld - - - - - - - - - - - - - - - - goodResponse - SequenceFlow_043r3j8 - - - - SequenceFlow_1h9opg9 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ex.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.")]]> + + + + + SequenceFlow_0clfkld + + + + + + + + + + + + + + + + goodResponse + SequenceFlow_043r3j8 + + + + SequenceFlow_1h9opg9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/ManualHandling.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/ManualHandling.bpmn index 2f30864c39..4d31eee45a 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/ManualHandling.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/ManualHandling.bpmn @@ -5,7 +5,7 @@ SequenceFlow_0jav6cu - SequenceFlow_192yimz + SequenceFlow_14cyk9v @@ -26,15 +26,7 @@ exceptionUtil.processJavaException(execution)]]> - - - SequenceFlow_0jav6cu - SequenceFlow_0zgg47r - - - + @@ -51,9 +43,87 @@ def mh = new ManualHandling() mh.setTaskVariables(task)]]> - SequenceFlow_0zgg47r + SequenceFlow_0igra4l SequenceFlow_192yimz + + + + + + + + + ${URN_mso_adapters_openecomp_db_endpoint} + + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + POST + + ${statusCode} + + soap-http-connector + + + SequenceFlow_0mbjrvr + SequenceFlow_0b84ki5 + + + SequenceFlow_0zgg47r + SequenceFlow_0mbjrvr + + + + SequenceFlow_192yimz + SequenceFlow_0zer29a + + + + + + + ${URN_mso_adapters_openecomp_db_endpoint} + + + + application/soap+xml + #{BasicAuthHeaderValueDB} + + + POST + + ${statusCode} + + soap-http-connector + + + SequenceFlow_0zer29a + SequenceFlow_14cyk9v + + + SequenceFlow_0jav6cu + SequenceFlow_0zgg47r + + + + + + SequenceFlow_0b84ki5 + SequenceFlow_0igra4l + + @@ -66,69 +136,119 @@ mh.setTaskVariables(task)]]> - + - + - + - + - + - + - + - - + + - + - + - - + + - + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + - - - + + + - + - - + + + + + + + + + diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/RainyDayHandler.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/RainyDayHandler.bpmn index 2638d85a8a..8183469798 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/RainyDayHandler.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/RainyDayHandler.bpmn @@ -64,9 +64,11 @@ rdh.queryPolicy(execution)]]> - + + + SequenceFlow_0navei4 SequenceFlow_1f0bjoy diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ReceiveWorkflowMessage.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ReceiveWorkflowMessage.bpmn index ad857eddcd..abae950134 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ReceiveWorkflowMessage.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/ReceiveWorkflowMessage.bpmn @@ -181,4 +181,4 @@ receiveWorkflowMessage.processReceivedMessage(execution)]]> - \ No newline at end of file + diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV2.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV2.bpmn new file mode 100644 index 0000000000..68afc9ae5a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterRestV2.bpmn @@ -0,0 +1,539 @@ + + + + This version of SDNCAdapterRest allows for interim notifications to be sent for any non-final response received from SDNC. + + SequenceFlow_3 + SequenceFlow_14 + + + + SequenceFlow_17 + SequenceFlow_35 + + + + SequenceFlow_23 + SequenceFlow_36 + + + + + SequenceFlow_14 + SequenceFlow_17 + SequenceFlow_23 + SequenceFlow_24 + + + + + + + + + + + SequenceFlow_35 + + + + SequenceFlow_36 + + + + + SequenceFlow_2 + SequenceFlow_3 + + + + + SequenceFlow_9 + SequenceFlow_2 + + + + + SequenceFlow_9 + + + + SequenceFlow_27 + SequenceFlow_34 + + + + + SequenceFlow_34 + + + + SequenceFlow_44 + SequenceFlow_1 + + + + + SequenceFlow_1 + + + SequenceFlow_27 + + ${SDNCREST_timeout} + + + + + SequenceFlow_24 + SequenceFlow_44 + + SequenceFlow_41 + SequenceFlow_42 + + + + + SequenceFlow_25 + + + + SequenceFlow_30 + SequenceFlow_39 + SequenceFlow_43 + + + + + + + SequenceFlow_42 + SequenceFlow_8 + SequenceFlow_30 + + + + + + + SequenceFlow_25 + SequenceFlow_0u48ihb + SequenceFlow_0vluoaq + SequenceFlow_41 + + + + + SequenceFlow_39 + + + SequenceFlow_8 + + + + SequenceFlow_43 + SequenceFlow_0u48ihb + SequenceFlow_1g8pswz + + + SequenceFlow_1g8pswz + SequenceFlow_0my3p6y + + + + + + + + + + + + + + SequenceFlow_0my3p6y + SequenceFlow_0vluoaq + + + + + + SequenceFlow_4 + + + + + SequenceFlow_4 + SequenceFlow_11 + + + + + SequenceFlow_11 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOCommonBPMN/src/main/resources/xsd/MSOWorkflowSchemaV1.xsd b/bpmn/MSOCommonBPMN/src/main/resources/xsd/MSOWorkflowSchemaV1.xsd index a8b5fcc945..e743dc754e 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/xsd/MSOWorkflowSchemaV1.xsd +++ b/bpmn/MSOCommonBPMN/src/main/resources/xsd/MSOWorkflowSchemaV1.xsd @@ -1,20 +1,11 @@

JBWEB000065: HTTP Status 500 - java.lang.NullPointerException

-
-

- JBWEB000309: type - JBWEB000066: Exception report -

-

- JBWEB000068: message - java.lang.NullPointerException -

-

- JBWEB000069: description - JBWEB000145: The server encountered an internal error that - prevented it from fulfilling this request. -

-

- JBWEB000070: exception -

org.jboss.resteasy.spi.UnhandledException:
-					java.lang.NullPointerException
-					org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:365)
-					org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:233)
-					org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:209)
-					org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:557)
-					org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
-					org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
-					org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
-					org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
-					org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
-					javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
-					org.openecomp.mso.logger.LogFilter.doFilter(LogFilter.java:35)
-				
-

-

- JBWEB000071: root cause -

java.lang.NullPointerException
-					org.openecomp.mso.adapters.network.NetworkAdapterRest$CreateNetworkVolumesTask.run(NetworkAdapterRest.java:128)
-					org.openecomp.mso.adapters.network.NetworkAdapterRest.createNetwork(NetworkAdapterRest.java:64)
-					sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-					sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
-					sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
-					java.lang.reflect.Method.invoke(Method.java:606)
-					org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
-					org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269)
-					org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227)
-					org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216)
-					org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
-					org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
-					org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
-					org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
-					org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
-					org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
-					javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
-					org.openecomp.mso.logger.LogFilter.doFilter(LogFilter.java:35)
-				
-

-

- JBWEB000072: note - JBWEB000073: The full stack trace of the root cause is available - in the JBoss Web/7.2.2.Final-redhat-1 logs. -

-
-

JBoss Web/7.2.2.Final-redhat-1

+
+

+ JBWEB000309: type + JBWEB000066: Exception report +

+

+ JBWEB000068: message + java.lang.NullPointerException +

+

+ JBWEB000069: description + JBWEB000145: The server encountered an internal error that + prevented it from fulfilling this request. + +

+

+ JBWEB000070: exception +

org.jboss.resteasy.spi.UnhandledException:
+				java.lang.NullPointerException
+				org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:365)
+				org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:233)
+				org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:209)
+				org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:557)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
+				org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
+				javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
+				org.openecomp.mso.logger.LogFilter.doFilter(LogFilter.java:35)
+			
+

+

+ JBWEB000071: root cause +

java.lang.NullPointerException
+				org.openecomp.mso.adapters.network.NetworkAdapterRest$CreateNetworkVolumesTask.run(NetworkAdapterRest.java:128)
+				org.openecomp.mso.adapters.network.NetworkAdapterRest.createNetwork(NetworkAdapterRest.java:64)
+				sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+				sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
+				sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+				java.lang.reflect.Method.invoke(Method.java:606)
+				org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
+				org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269)
+				org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227)
+				org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216)
+				org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
+				org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
+				org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
+				org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
+				javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
+				org.openecomp.mso.logger.LogFilter.doFilter(LogFilter.java:35)
+			
+

+

+ JBWEB000072: note + JBWEB000073: The full stack trace of the root cause is available + in the JBoss Web/7.2.2.Final-redhat-1 logs. + +

+
+

JBoss Web/7.2.2.Final-redhat-1

\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/response-failure.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/response-failure.json new file mode 100644 index 0000000000..6ffc7d901c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/response-failure.json @@ -0,0 +1,32 @@ +{ + "transaction": [ + { + "put": [ + { + "body": { + "201": "test" + } + }, + { + "body": { + "200": "test2" + } + } + ] + }, + { + "put": [ + { + "body": { + "400": "my great error" + } + }, + { + "body": { + "200": "test4" + } + } + ] + } + ] +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/response-success.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/response-success.json new file mode 100644 index 0000000000..7dae38335a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/response-success.json @@ -0,0 +1,32 @@ +{ + "transaction": [ + { + "put": [ + { + "body": { + "201": "test" + } + }, + { + "body": { + "200": "test2" + } + } + ] + }, + { + "put": [ + { + "body": { + "201": "test3" + } + }, + { + "body": { + "200": "test4" + } + } + ] + } + ] +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/test-request.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/test-request.json new file mode 100644 index 0000000000..f5ffe38285 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/test-request.json @@ -0,0 +1,22 @@ +{ + "transactions" : [ { + "put" : [ { + "uri" : "/network/generic-vnfs/generic-vnf/test1/relationship-list/relationship", + "body" : { + "related-link" : "/cloud-infrastructure/pservers/pserver/test2" + } + }, { + "uri" : "/network/generic-vnfs/generic-vnf/test3/relationship-list/relationship", + "body" : { + "related-link" : "/cloud-infrastructure/pservers/pserver/test4" + } + } ] + }, { + "put" : [ { + "uri" : "/network/generic-vnfs/generic-vnf/test5/relationship-list/relationship", + "body" : { + "related-link" : "/cloud-infrastructure/pservers/pserver/test6" + } + } ] + } ] +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/e2e-complex.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/e2e-complex.json new file mode 100644 index 0000000000..6fc9cb36e6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/e2e-complex.json @@ -0,0 +1,660 @@ +{ + "physical-location-id": "MTCWNJA4DCP", + "complex-name": "mtcnj", + "resource-version": "1498188613044", + "physical-location-type": "Mobility", + "street1": "200 S. Laurel Ave, Rm A4-3C30", + "city": "Middletown", + "state": "NJ", + "postal-code": "07748", + "country": "USA", + "region": "US", + "latitude": "40.39596", + "longitude": "-74.135342", + "lata": "224", + "ctag-pools": { + "ctag-pool": [ + { + "target-pe": "sfcca301vr1", + "availability-zone-name": "mtcnj-esx-az01", + "ctag-pool-purpose": "IPAG", + "ctag-values": "2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025", + "resource-version": "1494254946087", + "relationship-list": { + "relationship": [ + { + "related-to": "vpls-pe", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vpls-pes/vpls-pe/sfcca301vr1", + "relationship-data": [ + { + "relationship-key": "vpls-pe.equipment-name", + "relationship-value": "sfcca301vr1" + } + ] + } + ] + } + }, + { + "target-pe": "VPESAT-mtcnj401me6", + "availability-zone-name": "mtcnj-esx-az01", + "ctag-pool-purpose": "VPE", + "ctag-values": "3001,3002,3003,3004,3005,3006,3007,3008,3009,3010,3011,3012,3013,3014,3015,3016,3017,3018,3019,3020,3021,3022,3023,3024,3025,3026,3027,3028,3029,3030,3031,3032,3033,3034,3035,3036,3037,3038,3039,3040,3041,3042,3043,3044,3045,3046,3047,3048,3049,3050", + "resource-version": "1494254975977" + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "vce", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", + "relationship-data": [ + { + "relationship-key": "vce.vnf-id", + "relationship-value": "a9fec18e-1ea3-40e4-a6c0-a89b3de07053" + } + ], + "related-to-property": [ + { + "property-key": "vce.vnf-name", + "property-value": "mtcnj411vbc" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj104snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj104snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj105snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj105snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/compute_host", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "compute_host" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj106snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj106snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj126sd9", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj126sd9" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "vce", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/8ae1e5f8-61f1-4c71-913a-b40cc4593cb9", + "relationship-data": [ + { + "relationship-key": "vce.vnf-id", + "relationship-value": "8ae1e5f8-61f1-4c71-913a-b40cc4593cb9" + } + ], + "related-to-property": [ + { + "property-key": "vce.vnf-name", + "property-value": "mtcnj411vbc" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj102sta", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj102sta" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnjtax102", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnjtax102" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj107snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj107snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj118snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj118snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj110snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj110snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj109snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj109snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj114snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj114snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj119snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj119snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj116snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj116snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "vce", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/a2935fa9-b743-49f4-9813-a127f13c4e93", + "relationship-data": [ + { + "relationship-key": "vce.vnf-id", + "relationship-value": "a2935fa9-b743-49f4-9813-a127f13c4e93" + } + ], + "related-to-property": [ + { + "property-key": "vce.vnf-name", + "property-value": "mtcnj410vbc" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj108snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj108snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj123sd9", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj123sd9" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj101snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj101snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj102snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj102snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnjtax101", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnjtax101" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj113snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj113snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj111snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj111snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj103snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj103snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj117snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj117snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj101sta", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj101sta" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "vce", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/network/vces/vce/c7fe7698-8063-4e26-8bd3-ca3edde0b0d4", + "relationship-data": [ + { + "relationship-key": "vce.vnf-id", + "relationship-value": "c7fe7698-8063-4e26-8bd3-ca3edde0b0d4" + } + ], + "related-to-property": [ + { + "property-key": "vce.vnf-name", + "property-value": "mtcnj412vbc" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj120snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj120snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj124sd9", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj124sd9" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj125sd9", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj125sd9" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj112snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj112snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/pservers/pserver/mtcnj115snd", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtcnj115snd" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "cloud-region", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtcnj2", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "mtcnj2" + } + ], + "related-to-property": [ + { + "property-key": "cloud-region.owner-defined-type", + "property-value": "lcp" + } + ] + }, + { + "related-to": "oam-network", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/f9263cat-4eaa-43a0-bea4-adcf6e123456", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIAIC25" + }, + { + "relationship-key": "oam-network.network-uuid", + "relationship-value": "f9263cat-4eaa-43a0-bea4-adcf6e123456" + } + ], + "related-to-property": [ + { + "property-key": "oam-network.network-name", + "property-value": "VLAN-OAM-1323" + } + ] + }, + { + "related-to": "oam-network", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/b9263fab-4eaa-43a0-bea4-adcf6e999999", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIAIC25" + }, + { + "relationship-key": "oam-network.network-uuid", + "relationship-value": "b9263fab-4eaa-43a0-bea4-adcf6e999999" + } + ], + "related-to-property": [ + { + "property-key": "oam-network.network-name", + "property-value": "VLAN-OAM-1323" + } + ] + }, + { + "related-to": "oam-network", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/oam-networks/oam-network/cf33dc95-c5d2-48fd-8078-fd949363f63b", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIAIC25" + }, + { + "relationship-key": "oam-network.network-uuid", + "relationship-value": "cf33dc95-c5d2-48fd-8078-fd949363f63b" + } + ], + "related-to-property": [ + { + "property-key": "oam-network.network-name", + "property-value": "VLAN-OAM-1323" + } + ] + }, + { + "related-to": "availability-zone", + "related-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/availability-zones/availability-zone/mtcnj-esx-az01", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "att-aic" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIAIC25" + }, + { + "relationship-key": "availability-zone.availability-zone-name", + "relationship-value": "mtcnj-esx-az01" + } + ] + } + ] + } + } \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/empty-query-result.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/empty-query-result.json new file mode 100644 index 0000000000..914332edba --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/empty-query-result.json @@ -0,0 +1,3 @@ +{ + "results": [] +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/mockObject.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/mockObject.json new file mode 100644 index 0000000000..2f97b47dd3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/mockObject.json @@ -0,0 +1,10 @@ +{ + "id" : "something", + "resource-version" : "1234", + "plural" : { + "singular" : [{ + "id" : "something2", + "resource-version" : "5678" + }] + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/service-instance-pathed-query.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/service-instance-pathed-query.json new file mode 100644 index 0000000000..6ec513e4bb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/resources/service-instance-pathed-query.json @@ -0,0 +1,8 @@ +{ + "results": [ + { + "resource-type": "service-instance", + "resource-link": "https://aai-conexus-e2e.test.att.com:8443/aai/v9/business/customers/customer/key1/service-subscriptions/service-subscription/key2/service-instances/service-instance/key3" + } + ] +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/getCatalogServiceResourcesData.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/getCatalogServiceResourcesData.json index a69d1b3622..b3ab31c1de 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/getCatalogServiceResourcesData.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/getCatalogServiceResourcesData.json @@ -21,6 +21,7 @@ "nfType": null, "nfRole": null, "nfNamingCode": null, + "multiStageDesign": null, "vfModules": [ { "modelInfo": { diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/getCatalogServiceResourcesDataWithConfig.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/getCatalogServiceResourcesDataWithConfig.json new file mode 100644 index 0000000000..610965038f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/getCatalogServiceResourcesDataWithConfig.json @@ -0,0 +1,182 @@ +{ + "serviceResources": { + "modelInfo": { + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelUuid": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantUuid": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + }, + "serviceType": "PortMirroring", + "serviceRole": "InfraRole", + "serviceVnfs": [ + { + "modelInfo": { + "modelName": "vSAMP10a", + "modelUuid": "ff2ae348-214a-11e7-93ae-92361f002671", + "modelInvariantUuid": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationUuid": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelInstanceName": "vSAMP10a 1" + }, + "toscaNodeType": "VF", + "nfFunction": null, + "nfType": null, + "nfRole": null, + "nfNamingCode": null, + "vfModules": [ + { + "modelInfo": { + "modelName": "NetworkFqdnTest4", + "modelUuid": "025606c1-4223-11e7-9252-005056850d2e", + "modelInvariantUuid": "06bd0a18-65c0-4418-83c7-5b0d13cba01a", + "modelVersion": "2.0", + "modelCustomizationUuid": "06bd0a18-65c0-4418-83c7-5b0d13cba01a" + }, + "isBase": true, + "vfModuleLabel": "label", + "initialCount": 0, + "hasVolumeGroup": true + }, + { + "modelInfo": { + "modelName": "NetworkFqdnTest3", + "modelUuid": "02560575-4223-11e7-9252-005056850d2e", + "modelInvariantUuid": "06bd0a18-65c0-4418-83c7-5b0d13cba0bb", + "modelVersion": "1.0", + "modelCustomizationUuid": "06bd0a18-65c0-4418-83c7-5b0d13cba0bb" + }, + "isBase": true, + "vfModuleLabel": "label", + "initialCount": 0, + "hasVolumeGroup": false + }, + { + "modelInfo": { + "modelName": "NetworkFqdnTest5", + "modelUuid": "025607e4-4223-11e7-9252-005056850d2e", + "modelInvariantUuid": "06bd0a18-65c0-4418-83c7-5b0d14cba01a", + "modelVersion": "1.0", + "modelCustomizationUuid": "06bd0a18-65c0-4418-83c7-5b0d14cba01a" + }, + "isBase": false, + "vfModuleLabel": "label", + "initialCount": 0, + "hasVolumeGroup": false + }, + { + "modelInfo": { + "modelName": "vSAMP10aDEV::PCM::module-2", + "modelUuid": "7774b4e4-7d37-11e7-bb31-be2e44b06b34", + "modelInvariantUuid": "93e9c1d2-7d37-11e7-bb31-be2e44b06b34", + "modelVersion": "2", + "modelCustomizationUuid": "6728bee8-7d3a-11e7-bb31-be2e44b06b34" + }, + "isBase": false, + "vfModuleLabel": "PCM", + "initialCount": 0, + "hasVolumeGroup": true + }, + { + "modelInfo": { + "modelName": "vSAMP10aDEV::PCM::module-1", + "modelUuid": "066de97e-253e-11e7-93ae-92361f002671", + "modelInvariantUuid": "64efd51a-2544-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationUuid": "b4ea86b4-253f-11e7-93ae-92361f002671" + }, + "isBase": false, + "vfModuleLabel": "PCM", + "initialCount": 0, + "hasVolumeGroup": true + }, + { + "modelInfo": { + "modelName": "vSAMP10aDEV::base::module-0", + "modelUuid": "20c4431c-246d-11e7-93ae-92361f002671", + "modelInvariantUuid": "78ca26d0-246d-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationUuid": "cb82ffd8-252a-11e7-93ae-92361f002671" + }, + "isBase": true, + "vfModuleLabel": "base", + "initialCount": 1, + "hasVolumeGroup": true + }, + { + "modelInfo": { + "modelName": "vSAMP10a::base::module-0", + "modelUuid": "02560de2-4223-11e7-9252-005056850d2e", + "modelInvariantUuid": null, + "modelVersion": "2", + "modelCustomizationUuid": "MIGRATED_36e76920-ef30-4793-9979-cbd7d4b2bfc4" + }, + "isBase": true, + "vfModuleLabel": "base", + "initialCount": 1, + "hasVolumeGroup": true + }, + { + "modelInfo": { + "modelName": "base::module-0", + "modelUuid": "02561381-4223-11e7-9252-005056850d2e", + "modelInvariantUuid": null, + "modelVersion": "1", + "modelCustomizationUuid": "MIGRATED_51baae4c-b7c7-4f57-b77e-6e01acca89e5" + }, + "isBase": true, + "vfModuleLabel": "module-0", + "initialCount": 1, + "hasVolumeGroup": false + }, + { + "modelInfo": { + "modelName": "vSAMP10a::PCM::module-1", + "modelUuid": "02560f1b-4223-11e7-9252-005056850d2e", + "modelInvariantUuid": null, + "modelVersion": "1", + "modelCustomizationUuid": "MIGRATED_e9be2ed7-45b6-479c-b06e-9093899f8ce8" + }, + "isBase": true, + "vfModuleLabel": "PCM", + "initialCount": 1, + "hasVolumeGroup": true + } + ] + } + ], + "serviceNetworks": [], + "serviceAllottedResources": [ + { + "modelInfo": { + "modelName": "Tunnel_Xconn", + "modelUuid": "f6b7d4c6-e8a4-46e2-81bc-31cad5072842", + "modelInvariantUuid": "b7a1b78e-6b6b-4b36-9698-8c9530da14af", + "modelVersion": "1.0", + "modelCustomizationUuid": "5b9bee43-f537-4fb3-9e8b-4de9f714d28a", + "modelInstanceName": "Pri_Tunnel_Xconn 9" + }, + "toscaNodeType": null, + "allottedResourceType": null, + "allottedResourceRole": null, + "providingServiceModelInvariantUuid": null, + "nfFunction": null, + "nfType": null, + "nfRole": null, + "nfNamingCode": null + } + ], + "serviceConfigs": [ + { + "modelInfo": { + "modelName": "Molder", + "modelUuid": "025606c1-4fff-11e7-9252-005056850d2e", + "modelInvariantUuid": "025606c1-4eee-11e7-9252-005056850d2e", + "modelVersion": "1.0", + "modelCustomizationUuid": "025606c1-4ddd-11e7-9252-005056850d2e", + "modelInstanceName": "X_FILES_001" + }, + "toscaNodeType": "Scully" + } + ] + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/sdncCallbackSoapWrapper.xml b/bpmn/MSOCommonBPMN/src/test/resources/__files/sdncCallbackSoapWrapper.xml new file mode 100644 index 0000000000..0b1baf2cb4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/sdncCallbackSoapWrapper.xml @@ -0,0 +1,19 @@ + + + + + + + SDNC_REQUEST_ID + 200 + OK + + + SDNC_RESPONSE_DATA + + + + diff --git a/bpmn/MSOCommonBPMN/src/test/resources/camunda.cfg.xml b/bpmn/MSOCommonBPMN/src/test/resources/camunda.cfg.xml index c94e32e686..e151aca5fd 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/camunda.cfg.xml +++ b/bpmn/MSOCommonBPMN/src/test/resources/camunda.cfg.xml @@ -19,14 +19,6 @@ - - - - - - - - @@ -36,22 +28,15 @@ - - - - - - - diff --git a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties index 1cebbcfc48..049fc7c551 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties +++ b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties @@ -13,12 +13,12 @@ mso.healthcheck.log.debug=false mso.adapters.completemsoprocess.endpoint=http://localhost:28090/CompleteMsoProcess -mso.adapters.db.endpoint=http://localhost:28090/dbadapters/MsoRequestsDbAdapter +mso.adapters.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter mso.adapters.openecomp.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter mso.adapters.db.auth=757A94191D685FD2092AC1490730A4FC mso.adapters.network.endpoint=http://localhost:28090/networks/NetworkAdapter -mso.adapters.network.rest.endpoint=http://localhost:28090/networks/NetworkAdapter +mso.adapters.network.rest.endpoint=http://localhost:28090/networks/rest/v1/networks mso.adapters.po.auth=757A94191D685FD2092AC1490730A4FC mso.adapters.po.password=3141634BF7E070AA289CF2892C986C0B @@ -28,16 +28,17 @@ mso.adapters.workflow.message.endpoint=http://localhost:28090/workflows/messages aai.auth=26AFB797A6A57960D5D718491925C50F77CDC22AC394B3DBA09950D8FD1C0764 -policy.endpoint=https://mtanjvsgcvm02.nvp.cip.att.com:8081/pdp/api/getDecision +policy.endpoint=https://mtanjvsgcvm02.nvp.cip.att.com:8081/pdp/api/ policy.client.auth=Basic bTAzNzQzOnBvbGljeVIwY2sk policy.auth=Basic dGVzdHBkcDphbHBoYTEyMw== policy.environment=TEST -appc.topic.read=APPC-CL-FUSION-LCM-RESPONSE -appc.topic.read.timeout=60000 -appc.client.response.timeout=3600000 -appc.topic.write=APPC-CL-FUSION-LCM -appc.pool.members=uebsb91bodc.it.openecomp.org:3904,uebsb92bodc.it.openecomp.org:3904,uebsb93bodc.it.openecomp.org:3904 +appc.topic.read=APPC-TEST-AMDOCS2 +appc.topic.write=APPC-TEST-AMDOCS1-DEV3 +appc.topic.read.timeout=120000 +appc.client.response.timeout=120000 +appc.service=ueb +appc.poolMembers=uebsb93kcdc.it.att.com:3904,uebsb92kcdc.it.att.com:3904,uebsb91kcdc.it.att.com:3904 appc.client.key=iaEMAfjsVsZnraBP appc.client.secret=wcivUjsjXzmGFBfxMmyJu9dz @@ -56,17 +57,24 @@ mso.workflow.message.endpoint=http://localhost:28080/mso/WorkflowMesssage mso.workflow.sdncadapter.callback=http://localhost:28080/mso/SDNCAdapterCallbackService mso.sniro.auth=test:testpwd -mso.sniro.endpoint=http://localhost:28090/optimizationInstance/V1/create mso.sniro.timeout=PT30M +mso.sniro.policies.dhv.2vvig=SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 +mso.sniro.policies.dhv.4vvig=SNIRO.DistanceToLocationPolicy_vhngw,SNIRO.VNFPolicy_vhngatewayprimary1_v1,SNIRO.ResourceInstancePolicy_hngateway,SNIRO.ResourceRegionPolicy_hngateway_v1,SNIRO.VNFPolicy_vhngatewaysecondary1_v1,SNIRO.ZonePolicy_vhngw,SNIRO.PlacementOptimizationPolicy_dhv_v3,SNIRO.VNFPolicy_vhnportal_primary1_v1,SNIRO.ResourceInstancePolicy_vhnportal_v3,SNIRO.ResourceRegionPolicy_vhnportal_v1,SNIRO.VNFPolicy_vhnportalsecondary1_v1,SNIRO.ZonePolicy_vhnportal,SNIRO.VNFPolicy_vvigprimary2_v1,SNIRO.VNFPolicy_vvigsecondary2_v1,SNIRO.DistanceToLocationPolicy_vvig,SNIRO.InventoryGroupPolicy_vvig,SNIRO.VNFPolicy_vvigprimary1_v1,SNIRO.ResourceInstancePolicy_vvig,SNIRO.VNFPolicy_vvigsecondary1_v1 + mso.service.agnostic.sniro.host=http://localhost:28090 mso.service.agnostic.sniro.endpoint=/sniro/api/v2/placement mso.catalog.db.endpoint=http://localhost:28090/ +ruby.create-ticket-request.dmaap.username=m04768@mso.ecomp.att.com +ruby.create-ticket-request.dmaap.password=eHQ1cUJrOUc +ruby.create-ticket-request.publisher.topic=com.att.pdas.st1.msoCMFallout-v1 + + mso.adapters.tenant.endpoint=http://localhost:28090/tenantAdapterMock mso.adapters.vnf-async.endpoint=http://localhost:28090/vnfs/VnfAdapterAsync mso.adapters.vnf.endpoint=http://localhost:28090/vnfs/VnfAdapter -mso.adapters.vnf.rest.endpoint=http://localhost:28090/vnfs/v1/vnfs +mso.adapters.vnf.rest.endpoint=http://localhost:28090/vnfs/rest/v1/vnfs mso.workflow.vnfadapter.create.callback=http://localhost:28080/mso/vnfAdapterNotify mso.workflow.vnfadapter.delete.callback=http://localhost:28080/mso/vnfAdapterNotify mso.workflow.vnfadapter.query.callback=http://localhost:28080/mso/services/VNFAdapterQuerCallbackV1 @@ -98,6 +106,7 @@ mso.workflow.default.aai.v8.tenant.uri=/aai/v8/cloud-infrastructure/cloud-region mso.workflow.default.aai.v8.vce.uri=/aai/v8/network/vces/vce mso.workflow.default.aai.v8.vpn-binding.uri=/aai/v8/network/vpn-bindings/vpn-binding mso.workflow.notification.name=GenericNotificationService +mso.bpmn.optimisticlockingexception.retrycount=3 log.debug.CompleteMsoProcess=true log.debug.CreateNetworkInstanceInfra=true @@ -116,7 +125,7 @@ log.debug.GenericDeleteVnf=true log.debug.vnfAdapterCreateV1=true log.debug.vnfAdapterRestV1=true -policyClientAuth=Basic bTAzNzQzOnBvbGljeVIwY2sk -policyAuth=Basic dGVzdHBkcDphbHBoYTEyMw== -policyEnvironment=TEST -policyEndpoint=localhost:8080/pdp/api/getDecision +sdno.health-check.dmaap.username=m04768@mso.ecomp.att.com +sdno.health-check.dmaap.password=eHQ1cUJrOUc +sdno.health-check.dmaap.subscriber.topic=com.att.sdno.test-health-diagnostic-v02 +sdno.health-check.dmaap.publisher.topic=com.att.sdno.test-health-diagnostic-v02 \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/mso.properties b/bpmn/MSOCommonBPMN/src/test/resources/mso.properties new file mode 100644 index 0000000000..2428b512b1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/mso.properties @@ -0,0 +1,42 @@ +### +# ============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========================================================= +### + +### SDNCURL +### +#EE# +org.openecomp.mso.adapters.sdnc.sdncgeturl=https://localhost:8443/restconf/config/L3SDN-API: +org.openecomp.mso.adapters.sdnc.sdncposturl=https://localhost:8443/restconf/operations/L3SDN-API: +### +### BPEL ASYNC CALLLBACK/NOTIFICATION URL +### +#EE# +org.openecomp.mso.adapters.sdnc.bpelurl=http://localhost:8080/active-bpel/services/SDNCAdapterCallbackV1 +### +### SDNC ASYNC NOTIFICATION/RESPONSE URL +### +#EE# +org.openecomp.mso.adapters.sdnc.myurl=https://localhost:8443/adapters/rest/SDNCNotify +### +org.openecomp.mso.adapters.sdnc.sdncauth=admin:admin +org.openecomp.mso.adapters.sdnc.bpelauth=avosAdmin:jboss123 +org.openecomp.mso.adapters.sdnc.sdncconnecttime=2000 +org.openecomp.mso.adapters.sdnc.sdncreadtime=5000 + +org.openecomp.mso.adapters.sdnc...query=toto diff --git a/bpmn/MSOCommonBPMN/src/test/resources/mso.sdnc.properties b/bpmn/MSOCommonBPMN/src/test/resources/mso.sdnc.properties new file mode 100644 index 0000000000..f53e2d2b65 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/mso.sdnc.properties @@ -0,0 +1,152 @@ +#MSO SDNCA Properties go here +### +### UNIQUE SDNCURLs for Requests supported by SDNCA. URLS have unique tags eg a format like sdncurlXY (XY is unique eg digits) +### +org.openecomp.mso.adapters.sdnc.sdncurl1=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/operations/L3SDN-API: +org.openecomp.mso.adapters.sdnc.sdncurl2=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/config/L3SDN-API: +org.openecomp.mso.adapters.sdnc.sdncurl3=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/operations/AicHoming: +org.openecomp.mso.adapters.sdnc.sdncurl4=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/operations/Firewall-API: +org.openecomp.mso.adapters.sdnc.sdncurl5=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/config +org.openecomp.mso.adapters.sdnc.sdncurl6=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/operations/VNF-API: +org.openecomp.mso.adapters.sdnc.sdncurl7=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/operations/L3UCPE-API: +org.openecomp.mso.adapters.sdnc.sdncurl8=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/operations/NBNC-API: +org.openecomp.mso.adapters.sdnc.sdncurl9=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/operations/NORTHBOUND-API:service-topology-operation +org.openecomp.mso.adapters.sdnc.sdncurl10=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/operations/GENERIC-RESOURCE-API: +org.openecomp.mso.adapters.sdnc.sdncurl11=https://sdncodl.it.us.03.aic.cip.att.com:8443/restconf/operations/VNFTOPOLOGYAIC-API: +org.openecomp.mso.adapters.sdnc.sdncurl12=https://sdncodl.it.us.03.aic.cip.att.com:8443/ +org.openecomp.mso.adapters.sdnc.sdncurl13=http://mtznjv1fcbc01.kvm.cip.att.com:8181/restconf/operations/SDNW-API: +#org.openecomp.mso.adapters.sdnc.sdncurl14=http://txcdtl01bb2697.itservices.sbc.com:8181/restconf/operations/GENERIC-RESOURCE-API:port-mirror-topology-operation +org.openecomp.mso.adapters.sdnc.sdncurl14=http://mtanjv9sdbc51-eth1-0.aic.cip.att.com:8443/restconf/operations/GENERIC-RESOURCE-API: +### BPEL ASYNC CALLBACK/NOTIFICATION URL +### +org.openecomp.mso.adapters.sdnc.bpelurl=http://mtanjv9mobp01-eth1-0.aic.cip.att.com:8080/mso/SDNCAdapterCallbackService +org.openecomp.mso.adapters.sdnc.rest.bpelurl=http://mtanjv9mobp01-eth1-0.aic.cip.att.com:8080/mso/WorkflowMessage +### +### SDNC ASYNC NOTIFICATION/RESPONSE URL +### +org.openecomp.mso.adapters.sdnc.myurl=http://mtanjv9moja02-eth1-0.aic.cip.att.com:8080/adapters/rest/SDNCNotify +### Production value diff from other servers +org.openecomp.mso.adapters.sdnc.sdncauth=406B2AE613211B6FB52466DE6E1769AC +org.openecomp.mso.adapters.sdnc.bpelauth=F8E9452B55DDE4CCE77547B0E748105C54CF5EF1351B4E2CBAABF2981EFE776D +org.openecomp.mso.adapters.sdnc.sdncconnecttime=5000 +### +### Distinct Requests Supported by SDNCA. sdncurls added on top of file. fields may be null eg msoaction,operation resulting in .. construct +### +###org.openecomp.mso.adapters.sdnc.MSOACTION.OPERATION.ACTION=METHOD|TIMEOUT|URL|HEADERNAME|NAMESPACE +### +org.openecomp.mso.adapters.sdnc..service-homing-operation.homing=POST|60000|sdncurl3|sdnc-homing-header|com:att:sdnctl:aicHoming +org.openecomp.mso.adapters.sdnc.infra..query=GET|60000|sdncurl5| +org.openecomp.mso.adapters.sdnc.mobility..query=GET|60000|sdncurl5| +org.openecomp.mso.adapters.sdnc.vfmodule..query=GET|60000|sdncurl12| +org.openecomp.mso.adapters.sdnc...query=GET|60000|sdncurl2| +org.openecomp.mso.adapters.sdnc...put=PUT|60000|sdncurl5| +org.openecomp.mso.adapters.sdnc...restdelete=DELETE|60000|sdncurl5| +org.openecomp.mso.adapters.sdnc.gammainternet.svc-topology-operation.assign=POST|60000|sdncurl1|sdnc-request-header|com:att:sdnctl:l3api +org.openecomp.mso.adapters.sdnc.gammainternet.svc-topology-operation.delete=POST|250000|sdncurl1|sdnc-request-header|com:att:sdnctl:l3api +org.openecomp.mso.adapters.sdnc.gammainternet.service-configuration-operation.reserve=POST|60000|sdncurl1|sdnc-request-header|com:att:sdnctl:l3api +org.openecomp.mso.adapters.sdnc.gammainternet.service-configuration-operation.activate=POST|90000|sdncurl1|sdnc-request-header|com:att:sdnctl:l3api +org.openecomp.mso.adapters.sdnc.gammainternet.service-configuration-operation.delete=POST|250000|sdncurl1|sdnc-request-header|com:att:sdnctl:l3api +org.openecomp.mso.adapters.sdnc.gammainternet.service-configuration-operation.turnup=POST|60000|sdncurl1|sdnc-request-header|com:att:sdnctl:l3api +org.openecomp.mso.adapters.sdnc.gammainternet.service-configuration-operation.changereserve=POST|60000|sdncurl1|sdnc-request-header|com:att:sdnctl:l3api +org.openecomp.mso.adapters.sdnc.gammainternet.service-configuration-operation.changedelete=POST|250000|sdncurl1|sdnc-request-header|com:att:sdnctl:l3api +org.openecomp.mso.adapters.sdnc.gammainternet.service-configuration-operation.changeactivate=POST|60000|sdncurl1|sdnc-request-header|com:att:sdnctl:l3api +org.openecomp.mso.adapters.sdnc..feature-configuration-operation.activate=POST|60000|sdncurl4|sdnc-feature-request-header|com:att:sdnctl:firewallapi +org.openecomp.mso.adapters.sdnc..feature-configuration-operation.changeactivate=POST|60000|sdncurl4|sdnc-feature-request-header|com:att:sdnctl:firewallapi +org.openecomp.mso.adapters.sdnc..feature-configuration-operation.delete=POST|60000|sdncurl4|sdnc-feature-request-header|com:att:sdnctl:firewallapi +org.openecomp.mso.adapters.sdnc..vnf-topology-operation.assign=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..vnf-topology-operation.activate=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..vnf-topology-operation.rollback=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..vnf-topology-operation.delete=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..vnf-topology-operation.changeassign=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..vnf-topology-operation.changedelete=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..network-topology-operation.reserve=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..network-topology-operation.assign=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..network-topology-operation.activate=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..network-topology-operation.rollback=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..network-topology-operation.delete=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..network-topology-operation.changeassign=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc..network-topology-operation.changedelete=POST|270000|sdncurl6|sdnc-request-header|org:openecomp:sdnctl:vnf +org.openecomp.mso.adapters.sdnc.ucpe.service-configuration-operation.prepare=POST|360000|sdncurl7|sdnc-request-header|com:att:sdnctl:l3ucpe +org.openecomp.mso.adapters.sdnc.ucpe.service-configuration-operation.activate=POST|60000|sdncurl7|sdnc-request-header|com:att:sdnctl:l3ucpe +org.openecomp.mso.adapters.sdnc.ucpe.service-configuration-operation.delete=POST|360000|sdncurl7|sdnc-request-header|com:att:sdnctl:l3ucpe +org.openecomp.mso.adapters.sdnc.ucpe.service-configuration-operation.complete=POST|60000|sdncurl7|sdnc-request-header|com:att:sdnctl:l3ucpe +org.openecomp.mso.adapters.sdnc.ucpe.service-configuration-operation.activatevnf=POST|600000|sdncurl7|sdnc-request-header|com:att:sdnctl:l3ucpe +org.openecomp.mso.adapters.sdnc.ucpe.service-configuration-operation.designvnf=POST|60000|sdncurl7|sdnc-request-header|com:att:sdnctl:l3ucpe +org.openecomp.mso.adapters.sdnc.ucpe.service-configuration-operation.removevnf=POST|60000|sdncurl7|sdnc-request-header|com:att:sdnctl:l3ucpe +org.openecomp.mso.adapters.sdnc..svc-topology-operation.assign=POST|285000|sdncurl8|sdnc-request-header|com:att:sdnctl:nbncapi +org.openecomp.mso.adapters.sdnc..svc-topology-operation.activate=POST|285000|sdncurl8|sdnc-request-header|com:att:sdnctl:nbncapi +org.openecomp.mso.adapters.sdnc..svc-topology-operation.delete=POST|285000|sdncurl8|sdnc-request-header|com:att:sdnctl:nbncapi + +org.openecomp.mso.adapters.sdnc.service.ucpe.service-topology-assign-operation=POST|120000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.ucpe.service-topology-activate-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.ucpe-vnf.service-topology-cust-assign-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.ucpe-vnf.service-topology-cust-stage-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.ucpe-vnf.service-topology-cust-activate-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.ucpe-vnf.service-topology-cust-remove-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.dhv.service-topology-assign-operation=POST|120000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.infra.service-topology-infra-assign-operation=POST|120000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.infra.service-topology-infra-activate-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.vhnportal.service-topology-cust-assign-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.vhnportal.service-topology-cust-activate-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.vhngw.service-topology-cust-assign-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.vhngw.service-topology-infra-register-vnf-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.vhngw.service-topology-cust-activate-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.vvig.service-topology-cust-assign-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.vvig.service-topology-cust-activate-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.pe.service-topology-cust-assign-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.pe.service-topology-cust-stage-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 +org.openecomp.mso.adapters.sdnc.service.pe.service-topology-cust-activate-operation=POST|90000|sdncurl9|sdnc-request-header|com:att:sdnctl:northbound-api:v1 + +org.openecomp.mso.adapters.sdnc..service-topology-operation.assign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..service-topology-operation.rollback=POST|270000|sdncur10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..service-topology-operation.delete=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..service-topology-operation.deactivate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.network-topology-operation.assign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.network-topology-operation.unassign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.network-topology-operation.activate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.network-topology-operation.deactivate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vnf-topology-operation.assign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vnf-topology-operation.activate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vnf-topology-operation.unassign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vnf-topology-operation.deactivate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vnf-topology-operation.rollback=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vnf-topology-operation.delete=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vnf-topology-operation.changeassign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vnf-topology-operation.changedelete=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vf-module-topology-operation.assign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vf-module-topology-operation.activate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vf-module-topology-operation.unassign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vf-module-topology-operation.deactivate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vf-module-topology-operation.rollback=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vf-module-topology-operation.delete=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vf-module-topology-operation.changeassign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.generic-resource.vf-module-topology-operation.changedelete=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..contrail-route-topology-operation.assign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..contrail-route-topology-operation.unassign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..contrail-route-topology-operation.create=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..contrail-route-topology-operation.delete=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..contrail-route-topology-operation.activate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..contrail-route-topology-operation.deactivate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..security-zone-topology-operation.assign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..security-zone-topology-operation.unassign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..security-zone-topology-operation.create=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..security-zone-topology-operation.delete=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..security-zone-topology-operation.activate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..security-zone-topology-operation.deactivate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource + +org.openecomp.mso.adapters.sdnc..vnf-topology-aic-operation.assign=POST|270000|sdncurl11|sdnc-request-header|com:att:sdnctl:vnftopologyaic +org.openecomp.mso.adapters.sdnc..vnf-topology-aic-operation.activate=POST|270000|sdncurl11|sdnc-request-header|com:att:sdnctl:vnftopologyaic + +org.openecomp.mso.adapters.sdnc.TRANSPORT.service-topology-operation.assign=POST|270000|sdncurl13|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.TRANSPORT.service-topology-operation.rollback=POST|270000|sdncur13|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.TRANSPORT.service-topology-operation.delete=POST|270000|sdncurl13|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.TRANSPORT.service-topology-operation.deactivate=POST|270000|sdncurl13|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc.TRANSPORT.service-topology-operation.activate=POST|270000|sdncurl13|sdnc-request-header|com:att:sdnctl:generic-resource + +org.openecomp.mso.adapters.sdnc..port-mirror-topology-operation.assign=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..port-mirror-topology-operation.activate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..port-mirror-topology-operation.deactivate=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..port-mirror-topology-operation.enable=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..port-mirror-topology-operation.disable=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource +org.openecomp.mso.adapters.sdnc..port-mirror-topology-operation.delete=POST|270000|sdncurl10|sdnc-request-header|com:att:sdnctl:generic-resource + diff --git a/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json new file mode 100644 index 0000000000..e388d3e9ad --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/ruby/create-ticket/create-ticket-request.json @@ -0,0 +1,15 @@ +{ + "event": { + "msoRequest": { + "requestClientName": "MSO", + "requestId": "abc123", + "requestTime": "test-time", + "sourceName": "source-name", + "reason": "reason", + "action": "Create Ticket", + "workflowId": "work-flow-Id", + "notification": "notification" + } +} +} + diff --git a/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json new file mode 100644 index 0000000000..b9ad7a1f94 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-post-check-request.json @@ -0,0 +1,26 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000004", + "operation-type": "lport_mirroring_check", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + }, + { + "key": "interface-id", + "value": "test-interface-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json new file mode 100644 index 0000000000..ee28da86b9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-lport-mirror-pre-check-request.json @@ -0,0 +1,26 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000003", + "operation-type": "lport_mirroring_check", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + }, + { + "key": "interface-id", + "value": "test-interface-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json new file mode 100644 index 0000000000..95746ec3f9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-post-check-request.json @@ -0,0 +1,22 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000004", + "operation-type": "mirroring_check", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json new file mode 100644 index 0000000000..19d934d291 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/health-check/custom-port-mirror-pre-check-request.json @@ -0,0 +1,22 @@ +{ + "body": { + "input": { + "request-hd-custom": { + "request-client-name": "MSO", + "request-user-id": "test-user", + "request-id": "test-request-id", + "health-diagnostic-code": "VROUTER000003", + "operation-type": "mirroring_check", + "aai-param-list": [ + { + "key": "configuration-id", + "value": "test-configuration-id" + } + ] + } + } + }, + "operation": "health-diagnostic-custom", + "nodeLoc": "test-clli", + "nodeType": "VROUTER" +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json new file mode 100644 index 0000000000..15160b9dd9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/output-failure.json @@ -0,0 +1,25 @@ +{ + "body": { + "output": { + "response-hd-custom": { + "response-status": "Failure", + "cached-data": "false", + "response-interface-type": "ansible", + "response-id": "191bf423-8473-4f7c-9fbb-e5dcbb40a12b", + "remote_end_time": "2017-10-13T14:51:53.490+0000", + "response-client-name": "MSO", + "user_id": "md5621", + "remote_start_time": "2017-10-13T14:51:53.173+0000", + "error-message": "my error message", + "connection-failure-msg": "SDNO was unable to connect to an Ansible REST API server; Please ensure Ansible REST server is running" + } + } + }, + "result-info": { + "code": "200", + "status": "SUCCESS", + "request-id": "xyz123", + "client-name": "MSO", + "processing-host": "sdno-sdno-mtsnjv9sdno01" + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/output-success.json b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/output-success.json new file mode 100644 index 0000000000..a6794327d8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/output-success.json @@ -0,0 +1,22 @@ +{ + "body": { + "output": { + "response-healthdiagnostic": { + "response-node-ip": "192.20.127.76", + "response-id": "xyz123", + "response-node-name": "mtvnjv9aads11", + "response-status": "Success", + "response-interface-type": "ssh", + "response-details-json": "result", + "cached-data": "false" + } + } + }, + "result-info": { + "client-name": "MSO", + "code": "200", + "processing-host": "sdno1-host01", + "request-id": "xyz123", + "status": "SUCCESS" + } +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/response.json b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/response.json new file mode 100644 index 0000000000..2355e86938 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/org/openecomp/mso/client/sdno/response.json @@ -0,0 +1,17 @@ +{ + + "result-info": { + + "client-name": "MSO", + + "code": "202", + + "processing-host": "sdno1-host01", + + "request-id": "xyz123", + + "status": "ACCEPTED" + + } + +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdnc_adapter_data_request.xml b/bpmn/MSOCommonBPMN/src/test/resources/sdnc_adapter_data_request.xml new file mode 100644 index 0000000000..24fe72c62e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdnc_adapter_data_request.xml @@ -0,0 +1,33 @@ + + + ca424e60-cb22-43c5-88f9-ed68e17cebe2 + MSO + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + + + de19ae10-9a25-11e7-abc4-cec278b6b50a + ee938612-9a25-11e7-abc4-cec278b6b50a + 1.0 + MSOTADevInfra_Configuration_Service + + 14c5c14f-6caf-4028-9788-bb5ec9e8f9b8 + + MSO_1610_dev + + + MSO-DEV-SI-1802-PCM-926-100 + + + paramName + paramValue + + + + \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/sdnc_adapter_request.xml b/bpmn/MSOCommonBPMN/src/test/resources/sdnc_adapter_request.xml new file mode 100644 index 0000000000..2ecd36d68b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/sdnc_adapter_request.xml @@ -0,0 +1,47 @@ + + + 3a77913d-6d36-4507-8c6d-ab523af21fbf + 14c5c14f-6caf-4028-9788-bb5ec9e8f9b8 + assign + service-topology-operation + + callbackURL-test + PORT-MIRROR + + + + requestId-test + MSO + + + + CreateServiceInstance + + + serviceId-test + subscriptionServiceType-test + + + modelInvariantUuid-test + modelUuid-test + modelVersion-test + modelName-test + + serviceInstanceId-test + + globalSubscriberId-test + + + serviceInstanceName-test + + + paramName + paramValue + + + + + \ No newline at end of file -- cgit 1.2.3-korg