From 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Mon, 30 Jul 2018 15:56:09 -0400 Subject: Containerization feature of SO Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) --- mso-api-handlers/mso-api-handler-common/pom.xml | 144 +++++++-- .../beans/avpnbondingbeans/AVPNServiceNames.java | 44 +++ .../so/apihandler/camundabeans/BpmnRequest.java | 252 +++++++++++++++ .../camundabeans/CamundaBooleanInput.java | 72 +++++ .../camundabeans/CamundaBpmnRequestInput.java | 71 +++++ .../so/apihandler/camundabeans/CamundaInput.java | 76 +++++ .../camundabeans/CamundaIntegerInput.java | 71 +++++ .../camundabeans/CamundaMacroRequest.java | 107 +++++++ .../CamundaMacroRequestSerializer.java | 50 +++ .../so/apihandler/camundabeans/CamundaRequest.java | 135 ++++++++ .../apihandler/camundabeans/CamundaResponse.java | 96 ++++++ .../apihandler/camundabeans/CamundaVIDRequest.java | 338 +++++++++++++++++++++ .../org/onap/so/apihandler/camundabeans/Track.java | 49 +++ .../onap/so/apihandler/common/CamundaClient.java | 278 +++++++++++++++++ .../so/apihandler/common/CamundaTaskClient.java | 93 ++++++ .../onap/so/apihandler/common/CommonConstants.java | 88 ++++++ .../onap/so/apihandler/common/ErrorNumbers.java | 77 +++++ .../org/onap/so/apihandler/common/LSInputImpl.java | 119 ++++++++ .../so/apihandler/common/PathResourceResolver.java | 63 ++++ .../onap/so/apihandler/common/RequestClient.java | 102 +++++++ .../so/apihandler/common/RequestClientFactory.java | 68 +++++ .../apihandler/common/RequestClientParameter.java | 279 +++++++++++++++++ .../onap/so/apihandler/common/ResponseHandler.java | 221 ++++++++++++++ .../onap/so/apihandler/common/XMLValidator.java | 103 +++++++ .../recipe/CamundaClientErrorHandler.java | 51 ++++ .../java/org/onap/so/apihandlerinfra/Action.java | 45 +++ .../org/onap/so/apihandlerinfra/Constants.java | 52 ++++ .../java/org/onap/so/apihandlerinfra/Messages.java | 56 ++++ .../org/onap/so/apihandlerinfra/ModelType.java | 32 ++ .../org/onap/so/apihandlerinfra/MsoException.java | 26 ++ .../java/org/onap/so/apihandlerinfra/Status.java | 36 +++ .../apihandlerinfra/exceptions/ApiException.java | 125 ++++++++ .../exceptions/ApiExceptionMapper.java | 111 +++++++ .../exceptions/BPMNFailureException.java | 43 +++ .../exceptions/ClientConnectionException.java | 46 +++ .../exceptions/DuplicateRequestException.java | 47 +++ .../exceptions/RecipeNotFoundException.java | 43 +++ .../exceptions/ValidateException.java | 43 +++ .../exceptions/VfModuleNotFoundException.java | 46 +++ .../apihandlerinfra/logging/AlarmLoggerInfo.java | 84 +++++ .../apihandlerinfra/logging/ErrorLoggerInfo.java | 111 +++++++ .../mso/apihandler/camundabeans/BpmnRequest.java | 252 --------------- .../camundabeans/CamundaBooleanInput.java | 60 ---- .../camundabeans/CamundaBpmnRequestInput.java | 59 ---- .../mso/apihandler/camundabeans/CamundaInput.java | 66 ---- .../camundabeans/CamundaIntegerInput.java | 58 ---- .../apihandler/camundabeans/CamundaRequest.java | 133 -------- .../apihandler/camundabeans/CamundaResponse.java | 102 ------- .../apihandler/camundabeans/CamundaVIDRequest.java | 300 ------------------ .../mso/apihandler/camundabeans/Track.java | 49 --- .../mso/apihandler/common/BPELRestClient.java | 96 ------ .../mso/apihandler/common/CamundaClient.java | 254 ---------------- .../mso/apihandler/common/CamundaTaskClient.java | 93 ------ .../mso/apihandler/common/CommonConstants.java | 71 ----- .../mso/apihandler/common/ErrorNumbers.java | 73 ----- .../mso/apihandler/common/LSInputImpl.java | 119 -------- .../apihandler/common/PathResourceResolver.java | 64 ---- .../mso/apihandler/common/RequestClient.java | 84 ----- .../apihandler/common/RequestClientFactory.java | 61 ---- .../apihandler/common/RequestClientParamater.java | 242 --------------- .../mso/apihandler/common/ResponseHandler.java | 194 ------------ .../mso/apihandler/common/ValidationException.java | 48 --- .../mso/apihandler/common/XMLValidator.java | 103 ------- .../mso/apihandler/common/package-info.java | 25 -- .../onap/so/apihandler/camundabeans/BeansTest.java | 72 +++++ .../apihandler/camundabeans/BpmnRequestTest.java | 178 +++++++++++ .../CamundaMacroRequestSerializerTest.java | 36 +++ .../so/apihandler/common/AllTestsTestSuite.java | 33 ++ .../so/apihandler/common/CamundaClientTest.java | 166 ++++++++++ .../apihandler/common/CamundaTaskClientTest.java | 139 +++++++++ .../so/apihandler/common/ResponseHandlerTest.java | 139 +++++++++ .../recipe/CamundaClientErrorHandlerTest.java | 72 +++++ .../so/apihandlerinfra/ApiExceptionMapperTest.java | 97 ++++++ .../onap/so/apihandlerinfra/ApiExceptionTest.java | 128 ++++++++ .../org/onap/so/apihandlerinfra/TestAppender.java | 37 +++ .../mso/apihandler/camundabeans/BeansTest.java | 72 ----- .../apihandler/camundabeans/BpmnRequestTest.java | 178 ----------- .../apihandler/common/CamundaTaskClientTest.java | 132 -------- .../mso/camunda/tests/BPELRestClientTest.java | 125 -------- .../mso/camunda/tests/CamundaClientTest.java | 144 --------- .../mso/camunda/tests/CamundaRequestTest.java | 81 ----- .../mso/camunda/tests/CamundaResponseTest.java | 78 ----- .../mso/camunda/tests/ResponseHandlerTest.java | 137 --------- .../CamundaClientTest/WrappedVIDRequest.json | 1 + .../src/test/resources/logback-test.xml | 48 --- 85 files changed, 5063 insertions(+), 3629 deletions(-) create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/beans/avpnbondingbeans/AVPNServiceNames.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/BpmnRequest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaBooleanInput.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaBpmnRequestInput.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaInput.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaIntegerInput.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequestSerializer.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaRequest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaResponse.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/Track.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaTaskClient.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ErrorNumbers.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/LSInputImpl.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/PathResourceResolver.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClient.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientFactory.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Constants.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Messages.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/ModelType.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/MsoException.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Status.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/BPMNFailureException.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ClientConnectionException.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RecipeNotFoundException.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ValidateException.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/VfModuleNotFoundException.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/AlarmLoggerInfo.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/ErrorLoggerInfo.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBooleanInput.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBpmnRequestInput.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaInput.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaIntegerInput.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaRequest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaResponse.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/Track.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/PathResourceResolver.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientParamater.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/package-info.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/BeansTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/BpmnRequestTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequestSerializerTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/AllTestsTestSuite.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaTaskClientTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/ResponseHandlerTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandlerTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/TestAppender.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/camundabeans/BeansTest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequestTest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/common/CamundaTaskClientTest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaRequestTest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java delete mode 100644 mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/ResponseHandlerTest.java create mode 100644 mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json delete mode 100644 mso-api-handlers/mso-api-handler-common/src/test/resources/logback-test.xml (limited to 'mso-api-handlers/mso-api-handler-common') diff --git a/mso-api-handlers/mso-api-handler-common/pom.xml b/mso-api-handlers/mso-api-handler-common/pom.xml index 6ca1f3de28..b1963f1f4c 100644 --- a/mso-api-handlers/mso-api-handler-common/pom.xml +++ b/mso-api-handlers/mso-api-handler-common/pom.xml @@ -5,62 +5,150 @@ org.onap.so mso-api-handlers - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT + mso-api-handler-common - ECOMP MSO API Handler common - ECOMP MSO API Handler common classes + mso-api-handler-common + ONAP SO API Handler Common Libraries UTF-8 UTF-8 + 1.3.0 + 1.1.1 + 3.2.4 + 3.0.0 + 0.9.9-RC1 + 2.5.2 + 1.0.3 + 1.9.2 + 1.8 - + + + + + org.springframework.boot + spring-boot-dependencies + ${springboot.version} + pom + import + + + - - commons-io - commons-io + org.springframework.boot + spring-boot-starter-jersey - - javax - javaee-web-api - 6.0 - provided + commons-lang + commons-lang + 2.6 + + + antlr + antlr - - javax.activation activation 1.1.1 - provided - - org.onap.so - mso-catalog-db - ${project.version} + javax.transaction + jta + 1.1 - - org.onap.so - mso-requests-db - ${project.version} + org.json4s + json4s-jackson_2.9.1-1 + ${json4s-jackson-version} + + + org.json4s + json4s-core_2.9.2 + ${json4s-core-version} + + + com.fasterxml.jackson.core + jackson-databind - org.assertj - assertj-core - 3.10.0 + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-annotations + + + javax.servlet + servlet-api + 2.5 + + + org.javassist + javassist + + + org.json + json + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-base + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-providers + 2.9.2 + pom + + + org.springframework.boot + spring-boot-starter-test test - + + commons-beanutils + commons-beanutils + + + org.springframework.boot + spring-boot-configuration-processor + true + + + com.googlecode.junit-toolbox + junit-toolbox + 2.4 + + + org.onap.so + common + ${project.version} + + ${project.artifactId}-${project.version} - + + + org.apache.maven.plugins + maven-surefire-plugin + + + default-test + + test + + + + + jar diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/beans/avpnbondingbeans/AVPNServiceNames.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/beans/avpnbondingbeans/AVPNServiceNames.java new file mode 100644 index 0000000000..ed4e8c9305 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/beans/avpnbondingbeans/AVPNServiceNames.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.beans.avpnbondingbeans; + +public enum AVPNServiceNames { + AVPN_BONDING_TO_COLLABORATE("AVPNBondingToCollaborate"), + AVPN_BONDING_TO_IP_FLEX_REACH("AVPNBondingToIPFlexReach"), + AVPN_BONDING_TO_IP_TOLL_FREE("AVPNBondingToIPTollFree"); + + private String serviceName; + + AVPNServiceNames(String serviceName){ + this.serviceName=serviceName; + } + + public String getServiceName() { + return serviceName; + } + + @Override + public String toString() { + return "AVPNServiceNames{" + + "serviceName='" + serviceName + '\'' + + '}'; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/BpmnRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/BpmnRequest.java new file mode 100644 index 0000000000..bc2e5b1893 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/BpmnRequest.java @@ -0,0 +1,252 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + +import org.onap.so.apihandler.common.CommonConstants; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; + +/** + * JavaBean JSON class for a "bpmnRequest" which contains the JSON payload that + * will be passed to the Camunda process + */ +@JsonPropertyOrder({CommonConstants.REQUEST_ID_VARIABLE, + CommonConstants.IS_BASE_VF_MODULE_VARIABLE, CommonConstants.RECIPE_TIMEOUT_VARIABLE, + CommonConstants.REQUEST_ACTION_VARIABLE, CommonConstants.SERVICE_INSTANCE_ID_VARIABLE, + CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, + CommonConstants.VOLUME_GROUP_ID_VARIABLE, CommonConstants.NETWORK_ID_VARIABLE, + CommonConstants.SERVICE_TYPE_VARIABLE, CommonConstants.VNF_TYPE_VARIABLE, + CommonConstants.VF_MODULE_TYPE_VARIABLE, CommonConstants.NETWORK_TYPE_VARIABLE, + CommonConstants.REQUEST_DETAILS_VARIABLE}) +@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) +public class BpmnRequest { + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + private CamundaInput host; + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + private CamundaInput requestId; + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + private CamundaBooleanInput isBaseVfModule; + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + private CamundaIntegerInput recipeTimeout; + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + private CamundaInput requestAction; + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + private CamundaInput serviceInstanceId; + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + private CamundaInput vnfId; + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + private CamundaInput vfModuleId; + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + private CamundaInput volumeGroupId; + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + private CamundaInput networkId; + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + private CamundaInput serviceType; + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + private CamundaInput vnfType; + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + private CamundaInput vfModuleType; + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + private CamundaInput networkType; + + @JsonProperty(CommonConstants.REQUEST_DETAILS_VARIABLE) + private CamundaInput requestDetails; + + public BpmnRequest() { + /* Empty constructor */ + + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public CamundaInput getHost() { + return host; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public void setHost(CamundaInput host) { + this.host = host; + } + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + public CamundaInput getRequestId() { + return requestId; + } + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + public void setRequestId(CamundaInput requestId) { + this.requestId = requestId; + } + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + public CamundaBooleanInput getIsBaseVfModule() { + return isBaseVfModule; + } + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + public void setIsBaseVfModule(CamundaBooleanInput isBaseVfModule) { + this.isBaseVfModule = isBaseVfModule; + } + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + public CamundaIntegerInput getRecipeTimeout() { + return recipeTimeout; + } + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + public void setRecipeTimeout(CamundaIntegerInput recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + public CamundaInput getRequestAction() { + return requestAction; + } + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + public void setRequestAction(CamundaInput requestAction) { + this.requestAction = requestAction; + } + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + public CamundaInput getServiceInstanceId() { + return serviceInstanceId; + } + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + public void setServiceInstanceId(CamundaInput serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + public CamundaInput getVnfId() { + return vnfId; + } + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + public void setVnfId(CamundaInput vnfId) { + this.vnfId = vnfId; + } + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + public CamundaInput getVfModuleId() { + return vfModuleId; + } + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + public void setVfModuleId(CamundaInput vfModuleId) { + this.vfModuleId = vfModuleId; + } + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + public CamundaInput getVolumeGroupId() { + return volumeGroupId; + } + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + public void setVolumeGroupId(CamundaInput volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + public CamundaInput getNetworkId() { + return networkId; + } + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + public void setNetworkId(CamundaInput networkId) { + this.networkId = networkId; + } + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + public CamundaInput getServiceType() { + return serviceType; + } + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + public void setServiceType(CamundaInput serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + public CamundaInput getVnfType() { + return vnfType; + } + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + public void setVnfType(CamundaInput vnfType) { + this.vnfType = vnfType; + } + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + public CamundaInput getVfModuleType() { + return vfModuleType; + } + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + public void setVfModuleType(CamundaInput vfModuleType) { + this.vfModuleType = vfModuleType; + } + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + public CamundaInput getNetworkType() { + return networkType; + } + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + public void setNetworkType(CamundaInput networkType) { + this.networkType = networkType; + } + + @JsonProperty(CommonConstants.REQUEST_DETAILS_VARIABLE) + public CamundaInput getRequestDetails() { + return requestDetails; + } + + @JsonProperty(CommonConstants.REQUEST_DETAILS_VARIABLE) + public void setRequestDetails(CamundaInput requestDetails) { + this.requestDetails = requestDetails; + } + + + + + @Override + public String toString() { + + return "BpmnRequest"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaBooleanInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaBooleanInput.java new file mode 100644 index 0000000000..ea44375ff7 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaBooleanInput.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + + + +import org.onap.so.apihandler.common.CommonConstants; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that + * will be passed to the Camunda process + */ + + +public class CamundaBooleanInput { + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + private boolean value; + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + private String type = "Boolean"; + + + public CamundaBooleanInput() { + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public boolean getValue() { + return value; + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public void setValue(boolean value) { + this.value = value; + } + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + public String getType() { + return type; + } + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "CamundaInput [value=" + value + ", type=" + type + "]"; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaBpmnRequestInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaBpmnRequestInput.java new file mode 100644 index 0000000000..25293c7807 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaBpmnRequestInput.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.onap.so.apihandler.camundabeans; + + + +import org.onap.so.apihandler.common.CommonConstants; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that + * will be passed to the Camunda process + */ +public class CamundaBpmnRequestInput { + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + private BpmnRequest value; + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + private String type = "String"; + + + public CamundaBpmnRequestInput() { + /* Empty constructor */ + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public BpmnRequest getValue() { + return value; + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public void setValue(BpmnRequest value) { + this.value = value; + } + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + public String getType() { + return type; + } + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "CamundaInput [value=" + value + ", type=" + type + "]"; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaInput.java new file mode 100644 index 0000000000..29e72e005a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaInput.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + + + + +import org.onap.so.apihandler.common.CommonConstants; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that + * will be passed to the Camunda process + * + */ + + +public class CamundaInput { + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + private String value; + + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + private String type = "String"; + + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public String getValue() { + return value; + } + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + public String getType() { + return type; + } + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + public void setType(String type) { + this.type = type; + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return "CamundaInput [value=" + value + ", type=" + type + "]"; + } + + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaIntegerInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaIntegerInput.java new file mode 100644 index 0000000000..5bcfc6fb53 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaIntegerInput.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.onap.so.apihandler.camundabeans; + + + +import org.onap.so.apihandler.common.CommonConstants; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that + * will be passed to the Camunda process + */ +public class CamundaIntegerInput { + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + private int value; + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + private String type = "Integer"; + + + public CamundaIntegerInput() { + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public int getValue() { + return value; + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public void setValue(int value) { + this.value = value; + } + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + public String getType() { + return type; + } + + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "CamundaInput [value=" + Integer.toString(value) + ", type=" + type + "]"; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequest.java new file mode 100644 index 0000000000..c57c0965b9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequest.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.apihandler.common.CommonConstants; + +/** + * POJO which encapsulates the fields required to create a JSON request to invoke generic macro BPEL. + */ +@JsonPropertyOrder({CommonConstants.G_REQUEST_ID, CommonConstants.G_ACTION}) +@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) +public class CamundaMacroRequest { + + @JsonProperty(CommonConstants.G_REQUEST_ID) + private CamundaInput requestId; + + @JsonProperty(CommonConstants.G_ACTION) + private CamundaInput action; + + @JsonProperty(CommonConstants.G_SERVICEINSTANCEID) + private CamundaInput serviceInstanceId; + + + /** + * Sets new requestId. + * + * @param requestId New value of requestId. + */ + public void setRequestId(CamundaInput requestId) { + this.requestId = requestId; + } + + /** + * Gets action. + * + * @return Value of action. + */ + public CamundaInput getAction() { + return action; + } + + /** + * Sets new action. + * + * @param action New value of action. + */ + public void setAction(CamundaInput action) { + this.action = action; + } + + /** + * Gets requestId. + * + * @return Value of requestId. + */ + public CamundaInput getRequestId() { + return requestId; + } + + /** + * Sets new serviceInstanceId. + * + * @param serviceInstanceId New value of serviceInstanceId. + */ + public void setServiceInstanceId(CamundaInput serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + /** + * Gets serviceInstanceId. + * + * @return Value of serviceInstanceId. + */ + public CamundaInput getServiceInstanceId() { + return serviceInstanceId; + } + + @Override + public String toString() { + return "CamundaMacroRequest{" + + "requestId=" + requestId + + ", action=" + action + + ", serviceInstanceId=" + serviceInstanceId + + '}'; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequestSerializer.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequestSerializer.java new file mode 100644 index 0000000000..81adb40498 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequestSerializer.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +/** + * Class used to create data object and serialize it to JSON which the BPEL macro flow understands. + */ +public class CamundaMacroRequestSerializer { + + private CamundaMacroRequestSerializer(){} + + public static String getJsonRequest(String requestId, String action, String serviceInstanceId)throws JsonProcessingException{ + CamundaMacroRequest macroRequest = new CamundaMacroRequest(); + macroRequest.setAction(getCamundaInput(action)); + macroRequest.setRequestId(getCamundaInput(requestId)); + macroRequest.setServiceInstanceId(getCamundaInput(serviceInstanceId)); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + return mapper.writeValueAsString(macroRequest); + } + + private static CamundaInput getCamundaInput(String value){ + CamundaInput input = new CamundaInput(); + input.setType("String"); + input.setValue(value); + return input; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaRequest.java new file mode 100644 index 0000000000..48eeede7b3 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaRequest.java @@ -0,0 +1,135 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + + + + + +import org.onap.so.apihandler.common.CommonConstants; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; + +/** + * JavaBean JSON class for a "variables" which contains the xml payload that + * will be passed to the Camunda process + * + */ +@JsonPropertyOrder({ CommonConstants.CAMUNDA_SERVICE_INPUT, CommonConstants.CAMUNDA_HOST, + CommonConstants.SCHEMA_VERSION_HEADER, CommonConstants.REQUEST_ID_HEADER, CommonConstants.SERVICE_INSTANCE_ID_HEADER, + CommonConstants. REQUEST_TIMEOUT_HEADER, CommonConstants.CAMUNDA_SERVICE_INPUT}) +@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) +public class CamundaRequest { + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + private CamundaInput serviceInput; + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + private CamundaInput host; + + @JsonProperty(CommonConstants.SCHEMA_VERSION_HEADER) + private CamundaInput schema; + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + private CamundaInput reqid; + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_HEADER) + private CamundaInput svcid; + + @JsonProperty(CommonConstants.REQUEST_TIMEOUT_HEADER) + private CamundaInput timeout; + + public CamundaRequest() { + } + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + public CamundaInput getServiceInput() { + return serviceInput; + } + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + public void setServiceInput(CamundaInput serviceInput) { + this.serviceInput = serviceInput; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public CamundaInput getHost() { + return host; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public void setHost(CamundaInput host) { + this.host = host; + } + + @JsonProperty(CommonConstants.SCHEMA_VERSION_HEADER) + public CamundaInput getSchema() { + return schema; + } + + @JsonProperty(CommonConstants.SCHEMA_VERSION_HEADER) + public void setSchema(CamundaInput schema) { + this.schema = schema; + } + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + public CamundaInput getReqid() { + return reqid; + } + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + public void setReqid(CamundaInput reqid) { + this.reqid = reqid; + } + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_HEADER) + public CamundaInput getSvcid() { + return svcid; + } + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_HEADER) + public void setSvcid(CamundaInput svcid) { + this.svcid = svcid; + } + + + @JsonProperty(CommonConstants.REQUEST_TIMEOUT_HEADER) + public CamundaInput getTimeout() { + return timeout; + } + + @JsonProperty(CommonConstants.REQUEST_TIMEOUT_HEADER) + public void setTimeout(CamundaInput timeout) { + this.timeout = timeout; + } + + + + @Override + public String toString() { + return "CamundaRequest [serviceInput=" + serviceInput + ", host=" + + host + ", schema=" + schema + ", reqid=" + reqid + ", svcid=" + + svcid + ", timeout=" + timeout + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaResponse.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaResponse.java new file mode 100644 index 0000000000..92f4542b82 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaResponse.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * JavaBean JSON class for a "variables" which contains the xml payload that + * will be passed to the Camunda process + * + */ + +public class CamundaResponse { + + @JsonProperty("response") + private String response; + @JsonProperty("messageCode") + private int messageCode; + @JsonProperty("message") + private String message; + @JsonProperty("processInstanceID") + private String processInstanceID; + @JsonProperty("variables") + private String variables; + + public String getProcessInstanceID() { + return processInstanceID; + } + + public void setProcessInstanceID(String processInstanceID) { + this.processInstanceID = processInstanceID; + } + + public String getVariables() { + return variables; + } + + public void setVariables(String variables) { + this.variables = variables; + } + + public CamundaResponse() { + } + + public String getResponse() { + return response; + } + + public void setResponse(String response) { + this.response = response; + } + + public int getMessageCode() { + return messageCode; + } + + public void setMessageCode(int messageCode) { + this.messageCode = messageCode; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return "CamundaResponse [response=" + response + ", messageCode=" + + messageCode + ", message=" + message + "]"; + } + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java new file mode 100644 index 0000000000..9099b48f11 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/CamundaVIDRequest.java @@ -0,0 +1,338 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + + +import org.onap.so.apihandler.common.CommonConstants; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; + +/** + * JavaBean JSON class for a "variables" which contains the JSON payload that + * will be passed to the Camunda process + */ +@JsonPropertyOrder({CommonConstants.CAMUNDA_SERVICE_INPUT, CommonConstants.REQUEST_ID_VARIABLE, + CommonConstants.REQUEST_ID_HEADER, + CommonConstants.IS_BASE_VF_MODULE_VARIABLE, CommonConstants.RECIPE_TIMEOUT_VARIABLE, + CommonConstants.REQUEST_ACTION_VARIABLE, CommonConstants.SERVICE_INSTANCE_ID_VARIABLE, + CommonConstants.CORRELATION_ID, CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, + CommonConstants.VOLUME_GROUP_ID_VARIABLE, CommonConstants.NETWORK_ID_VARIABLE, + CommonConstants.CONFIGURATION_ID_VARIABLE, CommonConstants.SERVICE_TYPE_VARIABLE, + CommonConstants.VNF_TYPE_VARIABLE, CommonConstants.VF_MODULE_TYPE_VARIABLE, + CommonConstants.NETWORK_TYPE_VARIABLE, CommonConstants.CAMUNDA_SERVICE_INPUT, CommonConstants.RECIPE_PARAMS}) + +@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) +public class CamundaVIDRequest { + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + private CamundaInput serviceInput; + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + private CamundaInput host; + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + private CamundaInput requestId; + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + private CamundaInput msoRequestId; + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + private CamundaBooleanInput isBaseVfModule; + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + private CamundaIntegerInput recipeTimeout; + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + private CamundaInput requestAction; + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + private CamundaInput serviceInstanceId; + + @JsonProperty(CommonConstants.CORRELATION_ID) + private CamundaInput correlationId; + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + private CamundaInput vnfId; + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + private CamundaInput vfModuleId; + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + private CamundaInput volumeGroupId; + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + private CamundaInput networkId; + + @JsonProperty(CommonConstants.CONFIGURATION_ID_VARIABLE) + private CamundaInput configurationId; + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + private CamundaInput serviceType; + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + private CamundaInput vnfType; + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + private CamundaInput vfModuleType; + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + private CamundaInput networkType; + + @JsonProperty(CommonConstants.RECIPE_PARAMS) + private CamundaInput recipeParams; + + @JsonProperty(CommonConstants.API_VERSION) + private CamundaInput apiVersion; + + @JsonProperty(CommonConstants.ALACARTE) + private CamundaBooleanInput aLaCarte; + + @JsonProperty(CommonConstants.REQUEST_URI) + private CamundaInput requestUri; + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + public CamundaInput getServiceInput() { + return serviceInput; + } + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + public void setServiceInput(CamundaInput serviceInput) { + this.serviceInput = serviceInput; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public CamundaInput getHost() { + return host; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public void setHost(CamundaInput host) { + this.host = host; + } + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + public CamundaInput getRequestId() { + return requestId; + } + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + public void setRequestId(CamundaInput requestId) { + this.requestId = requestId; + } + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + public CamundaInput getMsoRequestId() { + return msoRequestId; + } + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + public void setMsoRequestId(CamundaInput msoRequestIdp) { + this.msoRequestId = msoRequestIdp; + } + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + public CamundaBooleanInput getIsBaseVfModule() { + return isBaseVfModule; + } + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + public void setIsBaseVfModule(CamundaBooleanInput isBaseVfModule) { + this.isBaseVfModule = isBaseVfModule; + } + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + public CamundaIntegerInput getRecipeTimeout() { + return recipeTimeout; + } + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + public void setRecipeTimeout(CamundaIntegerInput recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + public CamundaInput getRequestAction() { + return requestAction; + } + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + public void setRequestAction(CamundaInput requestAction) { + this.requestAction = requestAction; + } + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + public CamundaInput getServiceInstanceId() { + return serviceInstanceId; + } + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + public void setServiceInstanceId(CamundaInput serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + @JsonProperty(CommonConstants.CORRELATION_ID) + public CamundaInput getCorrelationId() { + return correlationId; + } + + @JsonProperty(CommonConstants.CORRELATION_ID) + public void setCorrelationId(CamundaInput correlationId) { + this.correlationId = correlationId; + } + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + public CamundaInput getVnfId() { + return vnfId; + } + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + public void setVnfId(CamundaInput vnfId) { + this.vnfId = vnfId; + } + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + public CamundaInput getVfModuleId() { + return vfModuleId; + } + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + public void setVfModuleId(CamundaInput vfModuleId) { + this.vfModuleId = vfModuleId; + } + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + public CamundaInput getVolumeGroupId() { + return volumeGroupId; + } + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + public void setVolumeGroupId(CamundaInput volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + public CamundaInput getNetworkId() { + return networkId; + } + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + public void setNetworkId(CamundaInput networkId) { + this.networkId = networkId; + } + + @JsonProperty(CommonConstants.CONFIGURATION_ID_VARIABLE) + public CamundaInput getConfigurationId() { + return configurationId; + } + + @JsonProperty(CommonConstants.CONFIGURATION_ID_VARIABLE) + public void setConfigurationId(CamundaInput configurationId) { + this.configurationId = configurationId; + } + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + public CamundaInput getServiceType() { + return serviceType; + } + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + public void setServiceType(CamundaInput serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + public CamundaInput getVnfType() { + return vnfType; + } + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + public void setVnfType(CamundaInput vnfType) { + this.vnfType = vnfType; + } + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + public CamundaInput getVfModuleType() { + return vfModuleType; + } + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + public void setVfModuleType(CamundaInput vfModuleType) { + this.vfModuleType = vfModuleType; + } + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + public CamundaInput getNetworkType() { + return networkType; + } + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + public void setNetworkType(CamundaInput networkType) { + this.networkType = networkType; + } + + @JsonProperty(CommonConstants.API_VERSION) + public CamundaInput getApiVersion() { + return apiVersion; + } + + @JsonProperty(CommonConstants.API_VERSION) + public void setApiVersion(CamundaInput apiVersion) { + this.apiVersion = apiVersion; + } + + @JsonProperty(CommonConstants.ALACARTE) + public CamundaBooleanInput getaLaCarte() { + return aLaCarte; + } + + @JsonProperty(CommonConstants.ALACARTE) + public void setaLaCarte(CamundaBooleanInput aLaCarte) { + this.aLaCarte = aLaCarte; + } + + @JsonProperty(CommonConstants.REQUEST_URI) + public CamundaInput getRequestUri() { + return requestUri; + } + + @JsonProperty(CommonConstants.REQUEST_URI) + public void setRequestUri(CamundaInput requestUri) { + this.requestUri = requestUri; + } + + public CamundaInput getRecipeParams() { + return recipeParams; + } + + public void setRecipeParams(CamundaInput recipeParams) { + this.recipeParams = recipeParams; + } + + @Override + public String toString() { + //return "CamundaRequest [requestId=" + + ", host=" + // + host + ", schema=" + schema + ", reqid=" + reqid + ", svcid=" + // + svcid + ", timeout=" + timeout + "]"; + return "CamundaRequest"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/Track.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/Track.java new file mode 100644 index 0000000000..3d4dc85089 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/camundabeans/Track.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + +public class Track { + + String title; + String singer; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSinger() { + return singer; + } + + public void setSinger(String singer) { + this.singer = singer; + } + + @Override + public String toString() { + return "Track [title=" + title + ", singer=" + singer + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java new file mode 100644 index 0000000000..7feb1ae758 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java @@ -0,0 +1,278 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + + +import java.io.IOException; + +import javax.xml.bind.DatatypeConverter; + +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.onap.so.apihandler.camundabeans.CamundaBooleanInput; +import org.onap.so.apihandler.camundabeans.CamundaInput; +import org.onap.so.apihandler.camundabeans.CamundaIntegerInput; +import org.onap.so.apihandler.camundabeans.CamundaRequest; +import org.onap.so.apihandler.camundabeans.CamundaVIDRequest; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +public class CamundaClient extends RequestClient{ + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CamundaClient.class); + private static final String CAMUNDA_URL_MESAGE = "Camunda url is: "; + + public CamundaClient() { + super(CommonConstants.CAMUNDA); + } + + + @Override + public HttpResponse post(String camundaReqXML, String requestId, + String requestTimeout, String schemaVersion, String serviceInstanceId, String action) + throws ClientProtocolException, IOException{ + HttpPost post = new HttpPost(url); + msoLogger.debug(CAMUNDA_URL_MESAGE + url); + String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion); + + StringEntity input = new StringEntity(jsonReq); + input.setContentType(CommonConstants.CONTENT_TYPE_JSON); + msoLogger.info("Camunda Request Content: " + jsonReq); + String encryptedCredentials = null; + if(props!=null){ + encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH); + if(encryptedCredentials != null){ + String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); + if(userCredentials != null){ + post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes()))); + } + } + } + + post.setEntity(input); + HttpResponse response = client.execute(post); + msoLogger.debug("Response is: " + response); + + return response; + } + + @Override + public HttpResponse post(String jsonReq) + throws ClientProtocolException, IOException{ + HttpPost post = new HttpPost(url); + msoLogger.debug(CAMUNDA_URL_MESAGE + url); + //String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion); + + StringEntity input = new StringEntity(jsonReq); + input.setContentType(CommonConstants.CONTENT_TYPE_JSON); + + String encryptedCredentials = null; + if(props!=null){ + encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH); + if(encryptedCredentials != null){ + String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); + if(userCredentials != null){ + post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes()))); + } + } + } + + post.setEntity(input); + HttpResponse response = client.execute(post); + msoLogger.debug("Response is: " + response); + + return response; + } + + public HttpResponse post(RequestClientParameter parameterObject) + throws ClientProtocolException, IOException{ + HttpPost post = new HttpPost(url); + msoLogger.debug("Camunda url is: "+ url); + String jsonReq = wrapVIDRequest(parameterObject.getRequestId(), parameterObject.isBaseVfModule(), parameterObject.getRecipeTimeout(), parameterObject.getRequestAction(), + parameterObject.getServiceInstanceId(), parameterObject.getCorrelationId(), parameterObject.getVnfId(), parameterObject.getVfModuleId(), parameterObject.getVolumeGroupId(), parameterObject.getNetworkId(), parameterObject.getConfigurationId(), + parameterObject.getServiceType(), parameterObject.getVnfType(), parameterObject.getVfModuleType(), parameterObject.getNetworkType(), parameterObject.getRequestDetails(), parameterObject.getApiVersion(), parameterObject.isaLaCarte(), parameterObject.getRequestUri(), parameterObject.getRecipeParamXsd()); + + StringEntity input = new StringEntity(jsonReq); + input.setContentType(CommonConstants.CONTENT_TYPE_JSON); + + String encryptedCredentials = null; + if(props!=null){ + encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH); + if(encryptedCredentials != null){ + String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); + if(userCredentials != null){ + post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes()))); + } + } + } + + post.setEntity(input); + HttpResponse response = client.execute(post); + msoLogger.debug("Response is: " + response); + + return response; + } + + @Override + public HttpResponse get() { + return null; + } + + protected String wrapRequest(String reqXML, String requestId, String serviceInstanceId, String requestTimeout, String schemaVersion){ + String jsonReq = null; + + try{ + CamundaRequest camundaRequest = new CamundaRequest(); + CamundaInput camundaInput = new CamundaInput(); + CamundaInput host = new CamundaInput(); + CamundaInput schema = new CamundaInput(); + CamundaInput reqid = new CamundaInput(); + CamundaInput svcid = new CamundaInput(); + CamundaInput timeout = new CamundaInput(); + camundaInput.setValue(StringUtils.defaultString(reqXML)); + host.setValue(parseURL()); + schema.setValue(StringUtils.defaultString(schemaVersion)); + reqid.setValue(requestId); + svcid.setValue(serviceInstanceId); + timeout.setValue(StringUtils.defaultString(requestTimeout)); + camundaRequest.setServiceInput(camundaInput); + camundaRequest.setHost(host); + camundaRequest.setReqid(reqid); + camundaRequest.setSvcid(svcid); + camundaRequest.setSchema(schema); + camundaRequest.setTimeout(timeout); + ObjectMapper mapper = new ObjectMapper(); + + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + + jsonReq = mapper.writeValueAsString(camundaRequest); + msoLogger.trace("request body is " + jsonReq); + }catch(Exception e){ + msoLogger.error(MessageEnum.APIH_WARP_REQUEST, "Camunda", "wrapRequest", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH Warp request", e); + } + return jsonReq; + } + + + protected String wrapVIDRequest(String requestId, boolean isBaseVfModule, + int recipeTimeout, String requestAction, String serviceInstanceId, String correlationId, + String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, + String serviceType, String vnfType, String vfModuleType, String networkType, + String requestDetails, String apiVersion, boolean aLaCarte, String requestUri, String paramXsd){ + String jsonReq = null; + + try{ + CamundaVIDRequest camundaRequest = new CamundaVIDRequest(); + CamundaInput serviceInput = new CamundaInput(); + CamundaInput host = new CamundaInput(); + CamundaInput requestIdInput= new CamundaInput(); + CamundaBooleanInput isBaseVfModuleInput = new CamundaBooleanInput(); + CamundaIntegerInput recipeTimeoutInput = new CamundaIntegerInput(); + CamundaInput requestActionInput = new CamundaInput(); + CamundaInput serviceInstanceIdInput = new CamundaInput(); + CamundaInput correlationIdInput = new CamundaInput(); + CamundaInput vnfIdInput = new CamundaInput(); + CamundaInput vfModuleIdInput = new CamundaInput(); + CamundaInput volumeGroupIdInput = new CamundaInput(); + CamundaInput networkIdInput = new CamundaInput(); + CamundaInput configurationIdInput = new CamundaInput(); + CamundaInput serviceTypeInput = new CamundaInput(); + CamundaInput vnfTypeInput = new CamundaInput(); + CamundaInput vfModuleTypeInput = new CamundaInput(); + CamundaInput networkTypeInput = new CamundaInput(); + CamundaBooleanInput aLaCarteInput = new CamundaBooleanInput(); + CamundaInput apiVersionInput = new CamundaInput(); + CamundaInput requestUriInput = new CamundaInput(); + CamundaInput recipeParamsInput = new CamundaInput(); + + //host.setValue(parseURL()); + requestIdInput.setValue(StringUtils.defaultString(requestId)); + isBaseVfModuleInput.setValue(isBaseVfModule); + recipeTimeoutInput.setValue(recipeTimeout); + requestActionInput.setValue(StringUtils.defaultString(requestAction)); + serviceInstanceIdInput.setValue(StringUtils.defaultString(serviceInstanceId)); + correlationIdInput.setValue(StringUtils.defaultString(correlationId)); + vnfIdInput.setValue(StringUtils.defaultString(vnfId)); + vfModuleIdInput.setValue(StringUtils.defaultString(vfModuleId)); + volumeGroupIdInput.setValue(StringUtils.defaultString(volumeGroupId)); + networkIdInput.setValue(StringUtils.defaultString(networkId)); + configurationIdInput.setValue(StringUtils.defaultString(configurationId)); + serviceTypeInput.setValue(StringUtils.defaultString(serviceType)); + vnfTypeInput.setValue(StringUtils.defaultString(vnfType)); + vfModuleTypeInput.setValue(StringUtils.defaultString(vfModuleType)); + networkTypeInput.setValue(StringUtils.defaultString(networkType)); + aLaCarteInput.setValue(aLaCarte); + apiVersionInput.setValue(StringUtils.defaultString(apiVersion)); + requestUriInput.setValue(StringUtils.defaultString(requestUri)); + recipeParamsInput.setValue(paramXsd); + + serviceInput.setValue(requestDetails); + camundaRequest.setServiceInput(serviceInput); + camundaRequest.setHost(host); + camundaRequest.setRequestId(requestIdInput); + camundaRequest.setMsoRequestId(requestIdInput); + camundaRequest.setIsBaseVfModule(isBaseVfModuleInput); + camundaRequest.setRecipeTimeout(recipeTimeoutInput); + camundaRequest.setRequestAction(requestActionInput); + camundaRequest.setServiceInstanceId(serviceInstanceIdInput); + camundaRequest.setCorrelationId(correlationIdInput); + camundaRequest.setVnfId(vnfIdInput); + camundaRequest.setVfModuleId(vfModuleIdInput); + camundaRequest.setVolumeGroupId(volumeGroupIdInput); + camundaRequest.setNetworkId(networkIdInput); + camundaRequest.setConfigurationId(configurationIdInput); + camundaRequest.setServiceType(serviceTypeInput); + camundaRequest.setVnfType(vnfTypeInput); + camundaRequest.setVfModuleType(vfModuleTypeInput); + camundaRequest.setNetworkType(networkTypeInput); + camundaRequest.setaLaCarte(aLaCarteInput); + camundaRequest.setApiVersion(apiVersionInput); + camundaRequest.setRequestUri(requestUriInput); + camundaRequest.setRecipeParams(recipeParamsInput); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + + jsonReq = mapper.writeValueAsString(camundaRequest); + msoLogger.trace("request body is " + jsonReq); + }catch(Exception e){ + msoLogger.error(MessageEnum.APIH_WARP_REQUEST, "Camunda", "wrapVIDRequest", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH Warp request", e); + } + return jsonReq; + } + + private String parseURL(){ + String[] parts = url.split(":"); + String host = ""; + if(parts.length>=2){ + host = parts[1]; + if(host.length()>2){ + host = host.substring(2); + } + } + return host; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaTaskClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaTaskClient.java new file mode 100644 index 0000000000..166a5c4d10 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaTaskClient.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + +import java.io.IOException; + +import javax.xml.bind.DatatypeConverter; + +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.onap.so.logger.MsoLogger; + +public class CamundaTaskClient extends RequestClient{ + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CamundaTaskClient.class); + + public CamundaTaskClient() { + super(CommonConstants.CAMUNDATASK); + } + + @Override + public HttpResponse post(String jsonReq) throws IOException{ + HttpPost post = new HttpPost(url); + msoLogger.debug("Camunda Task url is: "+ url); + + StringEntity input = new StringEntity(jsonReq); + input.setContentType(CommonConstants.CONTENT_TYPE_JSON); + + String encryptedCredentials; + if(props!=null){ + encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH); + if(encryptedCredentials != null){ + String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); + if(userCredentials != null){ + post.addHeader("Authorization", "Basic " + DatatypeConverter + .printBase64Binary(userCredentials.getBytes())); + } + } + } + + post.setEntity(input); + return client.execute(post); + } + + @Override + public HttpResponse post(String camundaReqXML, String requestId, + String requestTimeout, String schemaVersion, String serviceInstanceId, String action) { + throw new UnsupportedOperationException("Method not supported."); + } + + @Override + public HttpResponse post(RequestClientParameter params) { + throw new UnsupportedOperationException("Method not supported."); + } + + @Override + public HttpResponse get() throws IOException { + HttpGet get = new HttpGet(url); + msoLogger.debug("Camunda Task url is: "+ url); + String encryptedCredentials; + if(props!=null){ + encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH); + if(encryptedCredentials != null){ + String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); + if(userCredentials != null){ + get.addHeader("Authorization", "Basic " + new String(DatatypeConverter + .printBase64Binary(userCredentials.getBytes()))); + } + } + } + return client.execute(get); + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java new file mode 100644 index 0000000000..d5540ddbaa --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CommonConstants.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + + +public final class CommonConstants { + + public static final String DEFAULT_BPEL_AUTH = "admin:admin"; + public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + + public static final String REQUEST_ID_HEADER = "mso-request-id"; + public static final String REQUEST_TIMEOUT_HEADER = "mso-service-request-timeout"; + public static final String SCHEMA_VERSION_HEADER = "mso-schema-version"; + public static final String SERVICE_INSTANCE_ID_HEADER = "mso-service-instance-id"; + public static final String ACTION_HEADER = "mso-action"; + + public static final String G_REQUEST_ID = "mso-request-id"; + public static final String G_SERVICEINSTANCEID = "serviceInstanceId"; + public static final String G_ACTION = "gAction"; + + public static final String CAMUNDA_SERVICE_INPUT = "bpmnRequest"; + public static final String CAMUNDA_ROOT_INPUT = "variables"; + public static final String CONTENT_TYPE_JSON= "application/json"; + public static final String CAMUNDA_TYPE = "type"; + public static final String CAMUNDA_VALUE = "value"; + public static final String CAMUNDA_URL = "mso.camundaURL"; + public static final String CAMUNDA_AUTH = "mso.camundaAuth"; + public static final String BPEL_SEARCH_STR = "active-bpel"; + public static final String TASK_SEARCH_STR = "task"; + public static final String BPEL_URL = "bpelURL"; + public static final String BPEL_AUTH = "bpelAuth"; + public static final int BPEL = 0; + public static final int CAMUNDA = 1; + public static final int CAMUNDATASK = 2; + public static final String CAMUNDA_HOST = "host"; + public static final String REQUEST_ID_VARIABLE = "requestId"; + public static final String IS_BASE_VF_MODULE_VARIABLE = "isBaseVfModule"; + public static final String RECIPE_TIMEOUT_VARIABLE = "recipeTimeout"; + public static final String REQUEST_ACTION_VARIABLE = "requestAction"; + public static final String SERVICE_INSTANCE_ID_VARIABLE = "serviceInstanceId"; + public static final String CORRELATION_ID = "correlationId"; + public static final String VNF_ID_VARIABLE = "vnfId"; + public static final String VF_MODULE_ID_VARIABLE = "vfModuleId"; + public static final String VOLUME_GROUP_ID_VARIABLE = "volumeGroupId"; + public static final String NETWORK_ID_VARIABLE = "networkId"; + public static final String CONFIGURATION_ID_VARIABLE = "configurationId"; + public static final String SERVICE_TYPE_VARIABLE = "serviceType"; + public static final String VNF_TYPE_VARIABLE = "vnfType"; + public static final String VF_MODULE_TYPE_VARIABLE = "vfModuleType"; + public static final String NETWORK_TYPE_VARIABLE = "networkType"; + public static final String REQUEST_DETAILS_VARIABLE = "requestDetails"; + public static final String ALACARTE_ORCHESTRATION = "mso.infra.default.alacarte.orchestrationUri"; + public static final String ALACARTE_RECIPE_TIMEOUT = "mso.infra.default.alacarte.recipeTimeout"; + public static final String RECIPE_PARAMS = "recipeParams"; + public static final String ALACARTE_TEST_API = "mso.infra.default.alacarte.testApi"; + public static final String MACRO_TEST_API = "mso.infra.service.macro.default.testApi"; + public static final String ALACARTE = "aLaCarte"; + public static final String API_VERSION = "apiVersion"; + public static final String REQUEST_URI = "requestUri"; + public static final String API_MINOR_VERSION = "mso.infra.default.versions.apiMinorVersion"; + public static final String API_PATCH_VERSION = "mso.infra.default.versions.apiPatchVersion"; + public static final String X_TRANSACTION_ID = "X-TransactionID"; + public static final String X_MINOR_VERSION = "X-MinorVersion"; + public static final String X_PATCH_VERSION = "X-PatchVersion"; + public static final String X_LATEST_VERSION = "X-LatestVersion"; + + private CommonConstants () { + // prevent creating an instance of this class + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ErrorNumbers.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ErrorNumbers.java new file mode 100644 index 0000000000..5d755b9529 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ErrorNumbers.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.onap.so.apihandler.common; + +public final class ErrorNumbers { + + private ErrorNumbers() { + } + + public static final String REQUEST_FAILED_SCHEMA_VALIDATION = "1000"; + public static final String RECIPE_DOES_NOT_EXIST = "1010"; + public static final String VFMODULE_TYPE_DOES_NOT_EXIST = "1011"; + public static final String REQUEST_DOES_NOT_EXIST = "1012"; + public static final String SERVICE_DOES_NOT_EXIST = "1013"; + public static final String SERVICE_PARAMETERS_FAILED_SCHEMA_VALIDATION = "1020"; + public static final String LOCKED_SAME_SERVICE_TYPE_AND_REQUEST_ACTION = "1030"; + public static final String LOCKED_CANCEL_ON_REQUEST_IN_PROGRESS = "1031"; + public static final String LOCKED_REQUEST_IN_PROGRESS_TIMEOUT = "1032"; + public static final String LOCKED_NOT_ALLOWED_FOR_REQUEST_IN_PROGRESS = "1033"; + public static final String WITHDRAW_AFTER_COMPLETE = "1034"; + public static final String COMPLETE_AFTER_WITHDRAW = "1035"; // NOT USED + public static final String REQUEST_PREVIOUSLY_COMPLETED = "1036"; + public static final String CANNOT_RETRY_FINAL_ACTIVATION = "1037"; + public static final String PREVIOUSLY_COMPLETED_WITH_DIFF_ORDER_VERSION = "1038"; + public static final String LOCKED_DIFFERENT_REQUEST_ACTION = "1040"; + public static final String LOCKED_DIFF_REQUEST_ACTION_SAME_SERVICE_INSTANCE_ID = "1041"; + public static final String LOCKED_DIFFERENT_REQUEST_SAME_VPN_ID = "1042"; + public static final String REQUEST_TIMED_OUT = "1050"; + + + public static final String DISCONNECT_ALREADY_COMPLETE = "1100"; + public static final String CANCEL_ALREADY_COMPLETE = "1110"; + + public static final String LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS = "1400"; + public static final String LOCKED_SAME_ACTION_AND_VNF_ID = "1410"; + + public static final String ERROR_FROM_BPEL = "2000"; + public static final String NO_COMMUNICATION_TO_BPEL = "2010"; + public static final String NO_RESPONSE_FROM_BPEL = "2020"; + + public static final String COULD_NOT_WRITE_TO_REQUESTS_DB = "4000"; + public static final String NO_COMMUNICATION_TO_REQUESTS_DB = "4010"; + public static final String NO_COMMUNICATION_TO_CATALOG_DB = "4020"; + public static final String ERROR_FROM_CATALOG_DB = "4030"; + + public static final String ERROR_FROM_SDNC = "5300"; + public static final String NO_COMMUNICATION_TO_SDNC = "5310"; + public static final String NO_RESPONSE_FROM_SDNC = "5320"; + + public static final String NO_COMMUNICATION_TO_SDNC_ADAPTER = "7000"; + public static final String NO_RESPONSE_FROM_SDNC_ADAPTER = "7010"; + public static final String ERROR_FROM_SDNC_ADAPTER = "7020"; + + public static final String SVC_GENERAL_SERVICE_ERROR = "SVC0001"; + public static final String SVC_BAD_PARAMETER = "SVC0002"; + public static final String SVC_NO_SERVER_RESOURCES = "SVC1000"; + public static final String SVC_DETAILED_SERVICE_ERROR = "SVC2000"; + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/LSInputImpl.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/LSInputImpl.java new file mode 100644 index 0000000000..60473fb8c4 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/LSInputImpl.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + + +import java.io.InputStream; +import java.io.Reader; + +import org.w3c.dom.ls.LSInput; + +public class LSInputImpl implements LSInput { + + protected String fPublicId; + protected String fSystemId; + protected String fBaseSystemId; + protected InputStream fByteStream; + protected Reader fCharStream; + protected String fData; + protected String fEncoding; + protected boolean fCertifiedText; + + @Override + public InputStream getByteStream () { + return fByteStream; + } + + @Override + public void setByteStream (InputStream byteStream) { + fByteStream = byteStream; + } + + @Override + public Reader getCharacterStream () { + return fCharStream; + } + + @Override + public void setCharacterStream (Reader characterStream) { + fCharStream = characterStream; + } + + @Override + public String getStringData () { + return fData; + } + + @Override + public void setStringData (String stringData) { + fData = stringData; + } + + @Override + public String getEncoding () { + return fEncoding; + } + + @Override + public void setEncoding (String encoding) { + fEncoding = encoding; + } + + @Override + public String getPublicId () { + return fPublicId; + } + + @Override + public void setPublicId (String publicId) { + fPublicId = publicId; + } + + @Override + public String getSystemId () { + return fSystemId; + } + + @Override + public void setSystemId (String systemId) { + fSystemId = systemId; + } + + @Override + public String getBaseURI () { + return fBaseSystemId; + } + + @Override + public void setBaseURI (String baseURI) { + fBaseSystemId = baseURI; + } + + @Override + public boolean getCertifiedText () { + return fCertifiedText; + } + + @Override + public void setCertifiedText (boolean certifiedText) { + fCertifiedText = certifiedText; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/PathResourceResolver.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/PathResourceResolver.java new file mode 100644 index 0000000000..4e37561891 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/PathResourceResolver.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.onap.so.logger.MsoLogger; +import org.w3c.dom.ls.LSInput; +import org.w3c.dom.ls.LSResourceResolver; + +public class PathResourceResolver implements LSResourceResolver { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, PathResourceResolver.class); + + private String path; + + public PathResourceResolver(String path) { + + this.path = path; + } + + @Override + public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { + + LSInputImpl input = new LSInputImpl(); + + InputStream stream = null; + try { + stream = new FileInputStream(path + systemId); + } catch (FileNotFoundException e) { + msoLogger.debug ("Could not resolve resource based on file: " + path + systemId, e); + } + + input.setPublicId(publicId); + input.setSystemId(systemId); + input.setBaseURI(baseURI); + input.setCharacterStream(new InputStreamReader(stream)); + + return input; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClient.java new file mode 100644 index 0000000000..ca1ad7a277 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClient.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + +import java.io.IOException; +import java.security.GeneralSecurityException; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.onap.so.logger.MsoLogger; +import org.onap.so.utils.CryptoUtils; +import org.springframework.core.env.Environment; + +public abstract class RequestClient { + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH,RequestClient.class); + protected Environment props; + protected String url; + protected HttpClient client; + private int type; + + public RequestClient(int type){ + this.type = type; + } + + public void setProps(Environment env) { + this.props = env; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUrl() { + return url; + } + + public int getType(){ + return type; + } + + public HttpClient getClient() { + return client; + } + + public void setClient(HttpClient client) { + this.client = client; + } + + public abstract HttpResponse post(String request, String requestId, String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws IOException; + + public abstract HttpResponse post(String request) throws ClientProtocolException, IOException; + + public abstract HttpResponse post(RequestClientParameter parameterObject) throws ClientProtocolException, IOException; + + public abstract HttpResponse get() + throws IOException; + + protected String decryptPropValue(String prop, String defaultValue, String encryptionKey) { + try { + String result = CryptoUtils.decrypt(prop, encryptionKey); + return result; + } + catch (GeneralSecurityException e) { + msoLogger.debug("Security exception", e); + } + return defaultValue; + } + + protected String getEncryptedPropValue (String prop, String defaultValue, String encryptionKey) { + try { + String result = CryptoUtils.decrypt(prop, encryptionKey); + return result; + } + catch (GeneralSecurityException e) { + msoLogger.debug("Security exception", e); + } + return defaultValue; + } + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientFactory.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientFactory.java new file mode 100644 index 0000000000..e94f186c60 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientFactory.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + + + + +import org.apache.http.impl.client.DefaultHttpClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class RequestClientFactory { + + @Autowired + private Environment env; + + //based on URI, returns BPEL, CamundaTask or Camunda client + public RequestClient getRequestClient(String orchestrationURI) throws IllegalStateException{ + RequestClient retClient; + + String url; + if(orchestrationURI.contains(CommonConstants.TASK_SEARCH_STR)){ + url = env.getProperty(CommonConstants.CAMUNDA_URL) + orchestrationURI; + retClient = new CamundaTaskClient(); + } + else{ + url = env.getProperty(CommonConstants.CAMUNDA_URL) + orchestrationURI; + retClient = new CamundaClient(); + } + retClient.setClient(new DefaultHttpClient()); + retClient.setProps(env); + retClient.setUrl(url); + return retClient; + + } + + public Environment getEnv() { + return env; + } + + public void setEnv(Environment env) { + this.env = env; + } + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java new file mode 100644 index 0000000000..89db934985 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/RequestClientParameter.java @@ -0,0 +1,279 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + +public class RequestClientParameter { + + private String requestId; + private boolean isBaseVfModule; + private int recipeTimeout; + private String requestAction; + private String serviceInstanceId; + private String correlationId; + private String vnfId; + private String vfModuleId; + private String volumeGroupId; + private String networkId; + private String configurationId; + private String serviceType; + private String vnfType; + private String vfModuleType; + private String networkType; + private String requestDetails; + private String apiVersion; + private boolean aLaCarte; + private String recipeParamXsd; + private String requestUri; + + private RequestClientParameter(Builder builder) { + requestId = builder.requestId; + isBaseVfModule = builder.isBaseVfModule; + recipeTimeout = builder.recipeTimeout; + requestAction = builder.requestAction; + serviceInstanceId = builder.serviceInstanceId; + correlationId = builder.correlationId; + vnfId = builder.vnfId; + vfModuleId = builder.vfModuleId; + volumeGroupId = builder.volumeGroupId; + networkId = builder.networkId; + configurationId = builder.configurationId; + serviceType = builder.serviceType; + vnfType = builder.vnfType; + vfModuleType = builder.vfModuleType; + networkType = builder.networkType; + requestDetails = builder.requestDetails; + recipeParamXsd = builder.recipeParamXsd; + apiVersion = builder.apiVersion; + aLaCarte = builder.aLaCarte; + requestUri = builder.requestUri; + + } + + public String getRequestId() { + return requestId; + } + + public boolean isBaseVfModule() { + return isBaseVfModule; + } + + public int getRecipeTimeout() { + return recipeTimeout; + } + + public String getRequestAction() { + return requestAction; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public String getCorrelationId() { + return correlationId; + } + + public String getVnfId() { + return vnfId; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public String getNetworkId() { + return networkId; + } + + public String getConfigurationId() { + return configurationId; + } + + public String getServiceType() { + return serviceType; + } + + public String getVnfType() { + return vnfType; + } + + public String getVfModuleType() { + return vfModuleType; + } + + public String getNetworkType() { + return networkType; + } + + public String getRequestDetails() { + return requestDetails; + } + + public String getRecipeParamXsd() { + return recipeParamXsd; + } + + public String getApiVersion() { + return apiVersion; + } + + public boolean isaLaCarte() { + return aLaCarte; + } + + public String getRequestUri() { + return requestUri; + } + + public static class Builder { + private String requestId; + private boolean isBaseVfModule = false; + private int recipeTimeout; + private String requestAction; + private String serviceInstanceId; + private String correlationId; + private String vnfId; + private String vfModuleId; + private String volumeGroupId; + private String networkId; + private String configurationId; + private String serviceType; + private String vnfType; + private String vfModuleType; + private String networkType; + private String requestDetails; + private String apiVersion; + private boolean aLaCarte = false; + private String recipeParamXsd; + private String requestUri; + + public Builder setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public Builder setBaseVfModule(boolean baseVfModule) { + isBaseVfModule = baseVfModule; + return this; + } + + public Builder setRecipeTimeout(int recipeTimeout) { + this.recipeTimeout = recipeTimeout; + return this; + } + + public Builder setRequestAction(String requestAction) { + this.requestAction = requestAction; + return this; + } + + public Builder setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + return this; + } + + public Builder setCorrelationId(String correlationId) { + this.correlationId = correlationId; + return this; + } + + public Builder setVnfId(String vnfId) { + this.vnfId = vnfId; + return this; + } + + public Builder setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + return this; + } + + public Builder setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + return this; + } + + public Builder setNetworkId(String networkId) { + this.networkId = networkId; + return this; + } + + public Builder setConfigurationId(String configurationId) { + this.configurationId = configurationId; + return this; + } + + public Builder setServiceType(String serviceType) { + this.serviceType = serviceType; + return this; + } + + public Builder setVnfType(String vnfType) { + this.vnfType = vnfType; + return this; + } + + public Builder setVfModuleType(String vfModuleType) { + this.vfModuleType = vfModuleType; + return this; + } + + public Builder setNetworkType(String networkType) { + this.networkType = networkType; + return this; + } + + public Builder setRequestDetails(String requestDetails) { + this.requestDetails = requestDetails; + return this; + } + + public Builder setRecipeParamXsd(String recipeParamXsd) { + this.recipeParamXsd = recipeParamXsd; + return this; + } + + public Builder setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + return this; + } + + public Builder setALaCarte(boolean aLaCarte) { + this.aLaCarte = aLaCarte; + return this; + } + + public Builder setRequestUri(String requestUri) { + this.requestUri = requestUri; + return this; + } + + public RequestClientParameter build(){ + return new RequestClientParameter(this); + } + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java new file mode 100644 index 0000000000..fc6da3fa7d --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/ResponseHandler.java @@ -0,0 +1,221 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + + +import java.io.IOException; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.util.EntityUtils; +import org.onap.so.apihandler.camundabeans.CamundaResponse; +import org.onap.so.apihandlerinfra.Constants; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; +import org.onap.so.apihandlerinfra.exceptions.ValidateException; +import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class ResponseHandler { + + private CamundaResponse response; + private int status; + private String responseBody=""; + private HttpResponse httpResponse; + private int type; + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ResponseHandler.class); + + public ResponseHandler(HttpResponse httpResponse, int type) throws ApiException{ + this.httpResponse = httpResponse; + this.type=type; + parseResponse(); + } + + + private void parseResponse() throws ApiException{ + int statusCode = httpResponse.getStatusLine().getStatusCode(); + status = setStatus(statusCode); + if(type==CommonConstants.CAMUNDA){ + parseCamunda(); + }else if(type==CommonConstants.CAMUNDATASK){ + parseCamundaTask(); + }else { + parseBpel(); + } + + } + + + + private void parseCamunda() throws ApiException{ + try{ + HttpEntity entity = httpResponse.getEntity(); + responseBody = EntityUtils.toString(entity); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + + ValidateException validateException = new ValidateException.Builder("IOException getting Camunda response body", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + throw validateException; + } + + ObjectMapper mapper = new ObjectMapper(); + try { + response = mapper.readValue(responseBody, CamundaResponse.class); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + + ValidateException validateException = new ValidateException.Builder("JSON Object Mapping Request", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + throw validateException; + } + if(response!=null){ + responseBody = response.getResponse(); + }else{ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_ERROR_FROM_BPEL_SERVER, MsoLogger.ErrorCode.BusinessProcesssError) + .targetEntity("Camunda").targetServiceName("parseCamunda").build(); + BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(status), status, ErrorNumbers.ERROR_FROM_BPEL) + .errorInfo(errorLoggerInfo).build(); + } + } + + private void parseBpel() throws ApiException{ + + HttpEntity bpelEntity = httpResponse.getEntity(); + + try { + if (bpelEntity != null) { + responseBody = EntityUtils.toString(bpelEntity); + + } + }catch(IOException e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build(); + ValidateException validateException = new ValidateException.Builder("Could not convert BPEL response to string", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + throw validateException; + } + if(status!=HttpStatus.SC_ACCEPTED){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_ERROR_FROM_BPEL_SERVER, MsoLogger.ErrorCode.BusinessProcesssError) + .targetEntity("BPEL").targetServiceName("parseBpel").build(); + + + BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(status), status, ErrorNumbers.ERROR_FROM_BPEL) + .errorInfo(errorLoggerInfo).build(); + + throw bpmnFailureException; + } + + } + + private void parseCamundaTask() throws ApiException{ + + HttpEntity camundataskEntity = httpResponse.getEntity(); + + try { + if (camundataskEntity != null) { + responseBody = EntityUtils.toString(camundataskEntity); + } + }catch(IOException e) { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build(); + + + ValidateException validateException = new ValidateException.Builder("Could not convert CamundaTask response to string", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + throw validateException; + } + if(status!=HttpStatus.SC_NO_CONTENT && status != HttpStatus.SC_ACCEPTED){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_ERROR_FROM_BPEL_SERVER, MsoLogger.ErrorCode.BusinessProcesssError) + .targetEntity("CAMUNDATASK").targetServiceName("parseCamundaTask").build(); + + + BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(status), status, ErrorNumbers.ERROR_FROM_BPEL) + .errorInfo(errorLoggerInfo).build(); + + throw bpmnFailureException; + } + + } + + private int setStatus(int statusCode){ + int httpStatus; + switch(statusCode) { + case HttpStatus.SC_ACCEPTED: + case HttpStatus.SC_OK: + httpStatus = HttpStatus.SC_ACCEPTED; + break; + case HttpStatus.SC_BAD_REQUEST: + httpStatus = HttpStatus.SC_BAD_REQUEST; + break; + case HttpStatus.SC_UNAUTHORIZED: + case HttpStatus.SC_FORBIDDEN: + httpStatus = HttpStatus.SC_INTERNAL_SERVER_ERROR; + break; + case HttpStatus.SC_NOT_FOUND: + httpStatus = HttpStatus.SC_NOT_IMPLEMENTED; + break; + case HttpStatus.SC_INTERNAL_SERVER_ERROR: + httpStatus = HttpStatus.SC_BAD_GATEWAY; + break; + case HttpStatus.SC_SERVICE_UNAVAILABLE: + httpStatus = HttpStatus.SC_SERVICE_UNAVAILABLE; + break; + case HttpStatus.SC_NO_CONTENT: + httpStatus = HttpStatus.SC_NO_CONTENT; + break; + default: + httpStatus = HttpStatus.SC_INTERNAL_SERVER_ERROR; + break; + } + return httpStatus; + } + + + public CamundaResponse getResponse() { + return response; + } + + + public void setResponse(CamundaResponse response) { + this.response = response; + } + + + public String getResponseBody() { + return responseBody; + } + + + public void setResponseBody(String responseBody) { + this.responseBody = responseBody; + } + + + public int getStatus() { + return status; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java new file mode 100644 index 0000000000..3c72e479c7 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/XMLValidator.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + + +import java.io.FileInputStream; +import java.io.IOException; + +import javax.xml.XMLConstants; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +import org.apache.commons.io.IOUtils; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoAlarmLogger; +import org.onap.so.logger.MsoLogger; +import org.xml.sax.SAXException; + +public class XMLValidator { + + private static String XSDS_PATH; + + static { + String prefixMsoPropertiesPath = System.getProperty ("mso.config.path"); + if (prefixMsoPropertiesPath == null) { + prefixMsoPropertiesPath = ""; + } + XSDS_PATH = prefixMsoPropertiesPath + "xsds/"; + } + + private String stringXsd; + private String errorMsg = null; + private SchemaFactory factory; + private Schema schema; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, XMLValidator.class); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + + public XMLValidator (String xsdFile){ + + try (FileInputStream xsdStream = new FileInputStream (XSDS_PATH + xsdFile)) { + + stringXsd = IOUtils.toString (xsdStream); + + factory = SchemaFactory.newInstance (XMLConstants.W3C_XML_SCHEMA_NS_URI); + factory.setResourceResolver (new PathResourceResolver (XSDS_PATH)); + factory.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true); + + String quotedXsd = stringXsd.replaceAll (""", "\""); + Source src = new StreamSource (new java.io.StringReader (quotedXsd)); + schema = factory.newSchema (src); + + } catch (IOException | SAXException e) { + + msoLogger.debug ("Cannot open file " + XSDS_PATH + xsdFile, e); + errorMsg = "ErrorDetails: xsd file " + xsdFile + "could not be opened - " + e.getMessage (); + } + } + + // Returns null when XML valid, otherwise returns error details. + public String isXmlValid (String stringXml) { + try { + if (errorMsg != null && !errorMsg.isEmpty ()) { + return errorMsg; + } + Source src2 = new StreamSource (new java.io.StringReader (stringXml)); + Validator validator = schema.newValidator (); + validator.validate (src2); + + } catch (IOException | SAXException e) { + msoLogger.debug ("Exception: ", e); + return "ErrorDetails: " + e.getMessage (); + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_CANNOT_READ_SCHEMA, "", "", MsoLogger.ErrorCode.SchemaError, "APIH cannot read schema file", e); + alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, "Unable to read the schema file"); + return "ErrorDetails: " + "Unable to read the schema file"; + } + + return null; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java new file mode 100644 index 0000000000..d801a94c9b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.recipe; + +import java.io.IOException; + +import org.onap.so.logger.MsoLogger; +import org.springframework.http.HttpStatus; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.web.client.ResponseErrorHandler; + + + +public class CamundaClientErrorHandler implements ResponseErrorHandler{ + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CamundaClientErrorHandler.class); + + @Override + public void handleError(ClientHttpResponse response) throws IOException { + + msoLogger.debug(response.getBody().toString()); + //msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, + // MsoLogger.ResponseCode.CommunicationError, e.getMessage(), "BPMN", fullURL, null); + } + + @Override + public boolean hasError(ClientHttpResponse response) throws IOException { + HttpStatus.Series series = response.getStatusCode().series(); + return (HttpStatus.Series.CLIENT_ERROR.equals(series) + || HttpStatus.Series.SERVER_ERROR.equals(series)); + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.java new file mode 100644 index 0000000000..e920db2fd2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Action.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.onap.so.apihandlerinfra; + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum Action { + createInstance, + updateInstance, + deleteInstance, + configureInstance, + replaceInstance, + activateInstance, + deactivateInstance, + enablePort, + disablePort, + addRelationships, + removeRelationships, + inPlaceSoftwareUpdate, + applyUpdatedConfig, + completeTask, + assignInstance, + unassignInstance, + compareModel, + scaleInstance +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Constants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Constants.java new file mode 100644 index 0000000000..fe105a7637 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Constants.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra; + + +public class Constants { + + private Constants() { + } + + public static final String REQUEST_ID_PATH = "/{request-id}"; + + public static final String STATUS_SUCCESS = "SUCCESS"; + + public static final String MODIFIED_BY_APIHANDLER = "APIH"; + + public static final long PROGRESS_REQUEST_COMPLETED = 100L; + public static final long PROGRESS_REQUEST_RECEIVED = 0L; + public static final long PROGRESS_REQUEST_IN_PROGRESS = 20L; + + public static final String VNF_TYPE_WILDCARD = "*"; + + public static final String VOLUME_GROUP_COMPONENT_TYPE = "VOLUME_GROUP"; + + public static final String VALID_INSTANCE_NAME_FORMAT = "^[a-zA-Z][a-zA-Z0-9._-]*$"; + + public static final String A_LA_CARTE = "aLaCarte"; + + public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + public final static String VNF_REQUEST_SCOPE = "vnf"; + public final static String SERVICE_INSTANCE_PATH = "/serviceInstances"; + public final static String SERVICE_INSTANTIATION_PATH = "/serviceInstantiation"; +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Messages.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Messages.java new file mode 100644 index 0000000000..555c536efb --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Messages.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.onap.so.apihandlerinfra; + + +import java.util.HashMap; +import java.util.Map; + +import org.onap.so.apihandler.common.ErrorNumbers; + +public class Messages { + + protected static final Map errors = new HashMap<>(); + static { + errors.put(ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + "_service", "Service request FAILED schema validation. %s"); + errors.put(ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + "_feature", "Feature request FAILED schema validation. %s"); + errors.put(ErrorNumbers.RECIPE_DOES_NOT_EXIST, "Recipe for %s-type and action specified does not exist in catalog %s"); + errors.put(ErrorNumbers.SERVICE_PARAMETERS_FAILED_SCHEMA_VALIDATION, "Service specific parameters passed in request FAILED schema validation. %s"); + + errors.put(ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS, "%s-name (%s) is locked (status = %s) because already working on a CREATE request with same %s-name."); + errors.put(ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID, "%s-id (%s) is locked (status = %s) because already working on a request with same action (%s) for this %s-id."); + errors.put(ErrorNumbers.REQUEST_TIMED_OUT, "Service request timed out before completing"); + errors.put(ErrorNumbers.ERROR_FROM_BPEL, "BPEL returned an error: %s"); + errors.put(ErrorNumbers.NO_COMMUNICATION_TO_BPEL, "Could not communicate with BPEL %s"); + errors.put(ErrorNumbers.NO_RESPONSE_FROM_BPEL, "No response from BPEL %s"); + errors.put(ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, "Could not insert or update record in MSO_REQUESTS DB %s"); + errors.put(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, "Could not communicate with MSO_REQUESTS DB %s"); + errors.put(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB, "Could not communicate with MSO_CATALOG DB %s"); + errors.put(ErrorNumbers.ERROR_FROM_CATALOG_DB, "Received error from MSO_CATALOG DB %s"); + } + + private Messages(){ + } + + public static Map getErrors() { + return errors; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/ModelType.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/ModelType.java new file mode 100644 index 0000000000..7b3ea3a181 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/ModelType.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra; + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum ModelType { + service, + vnf, + vfModule, + volumeGroup, + network +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/MsoException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/MsoException.java new file mode 100644 index 0000000000..defc904b05 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/MsoException.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra; + +public enum MsoException { + ServiceException, + PolicyException, +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Status.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Status.java new file mode 100644 index 0000000000..fe9764a2f2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Status.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.onap.so.apihandlerinfra; + + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum Status { + PENDING, + IN_PROGRESS, + COMPLETE, + COMPLETED, + FAILED, + TIMEOUT, + UNLOCKED, + PENDING_MANUAL_TASK +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java new file mode 100644 index 0000000000..dc52bfcc6b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiException.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra.exceptions; + + +import java.util.List; + +import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; +import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; + +public abstract class ApiException extends Exception{ + /** + * + */ + private static final long serialVersionUID = 683162058616691134L; + private int httpResponseCode; + private String messageID; + private ErrorLoggerInfo errorLoggerInfo; + private AlarmLoggerInfo alarmLoggerInfo; + private List variables; + + public ApiException(Builder builder){ + super(builder.message, builder.cause); + + this.httpResponseCode = builder.httpResponseCode; + this.messageID = builder.messageID; + this.variables = builder.variables; + this.errorLoggerInfo = builder.errorLoggerInfo; + this.alarmLoggerInfo = builder.alarmLoggerInfo; + this.variables = builder.variables; + } + + public ApiException(String message, Throwable cause) { + super(message, cause); + } + + public String getMessageID() { + return messageID; + } + + public int getHttpResponseCode() { + return httpResponseCode; + } + + public ErrorLoggerInfo getErrorLoggerInfo() { + return errorLoggerInfo; + } + + public AlarmLoggerInfo getAlarmLoggerInfo() { + return alarmLoggerInfo; + } + + public List getVariables() { + return variables; + } + + public static class Builder> { + private String message; + private Throwable cause = null; + private int httpResponseCode; + private String messageID; + private ErrorLoggerInfo errorLoggerInfo = null; + private AlarmLoggerInfo alarmLoggerInfo = null; + private List variables = null; + + public Builder(String message, int httpResponseCode, String messageID) { + this.message = message; + this.httpResponseCode = httpResponseCode; + this.messageID = messageID; + } + + public T message(String message) { + this.message = message; + return (T) this; + } + + public T cause(Throwable cause) { + this.cause = cause; + return (T) this; + } + + public T httpResponseCode(int httpResponseCode) { + this.httpResponseCode = httpResponseCode; + return (T) this; + } + + public T messageID(String messageID) { + this.messageID = messageID; + return (T) this; + } + + public T errorInfo(ErrorLoggerInfo errorLoggerInfo){ + this.errorLoggerInfo = errorLoggerInfo; + return (T) this; + } + + public T alarmInfo(AlarmLoggerInfo alarmLoggerInfo){ + this.alarmLoggerInfo = alarmLoggerInfo; + return (T) this; + } + + public T variables(List variables) { + this.variables = variables; + return (T) this; + } + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java new file mode 100644 index 0000000000..e0bcc71736 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ApiExceptionMapper.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra.exceptions; + +import java.util.List; + +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; +import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoAlarmLogger; +import org.onap.so.logger.MsoLogger; +import org.onap.so.serviceinstancebeans.RequestError; +import org.onap.so.serviceinstancebeans.ServiceException; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +@Provider +public class ApiExceptionMapper implements ExceptionMapper { + + private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, ApiExceptionMapper.class); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + @Override + public Response toResponse(ApiException exception) { + + return Response.status(exception.getHttpResponseCode()).entity(buildErrorString(exception)).build(); + } + + protected String buildErrorString(ApiException exception) { + String errorText = exception.getMessage(); + String messageId = exception.getMessageID(); + List variables = exception.getVariables(); + ErrorLoggerInfo errorLoggerInfo = exception.getErrorLoggerInfo(); + AlarmLoggerInfo alarmLoggerInfo = exception.getAlarmLoggerInfo(); + + + if (errorText.length() > 1999) { + errorText = errorText.substring(0, 1999); + } + + writeErrorLog(errorText, errorLoggerInfo, alarmLoggerInfo); + + return buildServiceErrorResponse(errorText,messageId,variables); + + } + + protected String buildServiceErrorResponse(String errorText, String messageId, List variables){ + RequestError re = new RequestError(); + ServiceException se = new ServiceException(); + se.setMessageId(messageId); + se.setText(errorText); + if (variables != null) { + for (String variable : variables) { + se.getVariables().add(variable); + } + } + re.setServiceException(se); + String requestErrorStr; + + ObjectMapper mapper = createObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT); + try { + requestErrorStr = mapper.writeValueAsString(re); + } catch (JsonProcessingException e) { + String errorMsg = "Exception in buildServiceErrorResponse writing exceptionType to string " + e.getMessage(); + logger.error(MessageEnum.GENERAL_EXCEPTION, "BuildServiceErrorResponse", "", "", MsoLogger.ErrorCode.DataError, errorMsg, e); + return errorMsg; + } + + return requestErrorStr; + } + + protected void writeErrorLog(String errorText, ErrorLoggerInfo errorLogInfo, AlarmLoggerInfo alarmLogInfo) { + + if(errorLogInfo != null) + logger.error(errorLogInfo.getLoggerMessageType().toString(), errorLogInfo.getErrorSource(), errorLogInfo.getTargetEntity(), errorLogInfo.getTargetServiceName(), errorLogInfo.getErrorCode(), errorText); + if(alarmLogInfo != null){ + alarmLogger.sendAlarm(alarmLogInfo.getAlarm(),alarmLogInfo.getState(),alarmLogInfo.getDetail()); + } + } + + public ObjectMapper createObjectMapper(){ + return new ObjectMapper(); + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/BPMNFailureException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/BPMNFailureException.java new file mode 100644 index 0000000000..8c215de213 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/BPMNFailureException.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.onap.so.apihandlerinfra.exceptions; + +public class BPMNFailureException extends ApiException { + + private static final String bpmnFailMessage = "Request Failed due to BPEL error with HTTP Status = $HTTPSTATUS"; + + private BPMNFailureException(Builder builder) { + super(builder); + } + + public static class Builder extends ApiException.Builder{ + + + public Builder(String message, int httpResponseCode, String messageID) { + super(bpmnFailMessage.replaceAll ("\\$HTTPSTATUS", message),httpResponseCode,messageID); + } + + public BPMNFailureException build() { + return new BPMNFailureException(this); + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ClientConnectionException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ClientConnectionException.java new file mode 100644 index 0000000000..cf4c9168ea --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ClientConnectionException.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.onap.so.apihandlerinfra.exceptions; + +public class ClientConnectionException extends ApiException { + + /** + * + */ + private static final long serialVersionUID = 1L; + private static final String clientFailMessage = "Client from $URL failed to connect"; + + private ClientConnectionException(Builder builder) { + super(builder); + } + + public static class Builder extends ApiException.Builder{ + + public Builder(String message, int httpResponseCode, String messageID) { + super(clientFailMessage.replaceAll ("\\$URL", message),httpResponseCode,messageID); + } + + public ClientConnectionException build() { + return new ClientConnectionException(this); + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java new file mode 100644 index 0000000000..718dc6421d --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.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.onap.so.apihandlerinfra.exceptions; + +public class DuplicateRequestException extends ApiException { + + private static final String duplicateFailMessage = "Error: Locked instance - This %s (%s) " + "already has a request being worked with a status of %s (RequestId - %s). The existing request must finish or be cleaned up before proceeding."; + + private DuplicateRequestException(Builder builder) { + super(builder); + } + + + public static class Builder extends ApiException.Builder{ + + + public Builder(String requestScope,String instance, String requestStatus, String requestID, int httpResponseCode, String messageID) { + super(String.format(duplicateFailMessage,requestScope,instance,requestStatus,requestID),httpResponseCode,messageID); + + } + + + public DuplicateRequestException build() { + + return new DuplicateRequestException(this); + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RecipeNotFoundException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RecipeNotFoundException.java new file mode 100644 index 0000000000..620103be4e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RecipeNotFoundException.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.onap.so.apihandlerinfra.exceptions; + + +public class RecipeNotFoundException extends ApiException { + + private RecipeNotFoundException(Builder builder) { + super(builder); + } + + public static class Builder extends ApiException.Builder { + + + public Builder(String message, int httpResponseCode, String messageID) { + super(message, httpResponseCode, messageID); + } + + public RecipeNotFoundException build() { + + return new RecipeNotFoundException(this); + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ValidateException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ValidateException.java new file mode 100644 index 0000000000..b0cf39e1a2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/ValidateException.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.onap.so.apihandlerinfra.exceptions; + +public class ValidateException extends ApiException { + + + private ValidateException(Builder builder) { + super(builder); + } + + + public static class Builder extends ApiException.Builder{ + + public Builder(String message, int httpResponseCode, String messageID) { + super(message,httpResponseCode,messageID); + } + + public ValidateException build() { + + return new ValidateException(this); + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/VfModuleNotFoundException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/VfModuleNotFoundException.java new file mode 100644 index 0000000000..d80f2f7b48 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/VfModuleNotFoundException.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.onap.so.apihandlerinfra.exceptions; + +public class VfModuleNotFoundException extends ApiException { + + + /** + * + */ + private static final long serialVersionUID = 1L; + + private VfModuleNotFoundException(Builder builder) { + super(builder); + } + + public static class Builder extends ApiException.Builder{ + + public Builder(String message, int httpResponseCode, String messageID) { + super(message,httpResponseCode,messageID); + } + public VfModuleNotFoundException build() { + + return new VfModuleNotFoundException(this); + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/AlarmLoggerInfo.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/AlarmLoggerInfo.java new file mode 100644 index 0000000000..2746da4f2d --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/AlarmLoggerInfo.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra.logging; + +import java.io.Serializable; + +public class AlarmLoggerInfo implements Serializable{ + /** + * + */ + private static final long serialVersionUID = -6730979289437576112L; + private String alarm; + private int state; + private String detail; + + + private AlarmLoggerInfo(String alarm, int state, String detail){ + this.alarm = alarm; + this.state = state; + this.detail = detail; + } + + public int getState() { + return state; + } + + public String getAlarm() { + return alarm; + } + + public String getDetail() { + return detail; + } + + public static class Builder{ + private String alarm = ""; + private int state; + private String detail = ""; + + public Builder(String alarm, int state, String detail){ + this.alarm = alarm; + this.state = state; + this.detail = detail; + } + + public Builder alarm(String alarm){ + this.alarm = alarm; + return this; + } + + public Builder state(int state){ + this.state = state; + return this; + } + + public Builder detail(String detail){ + this.detail = detail; + return this; + } + + public AlarmLoggerInfo build(){ + return new AlarmLoggerInfo(alarm, state, detail); + } + + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/ErrorLoggerInfo.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/ErrorLoggerInfo.java new file mode 100644 index 0000000000..b0b154bc5c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/logging/ErrorLoggerInfo.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra.logging; + +import java.io.Serializable; + +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger.ErrorCode; + + + +public class ErrorLoggerInfo implements Serializable{ + /** + * + */ + private static final long serialVersionUID = -2917784544098682110L; + private MessageEnum loggerMessageType; + private String errorSource; + private String targetEntity; + private String targetServiceName; + private ErrorCode errorCode; + + private ErrorLoggerInfo(MessageEnum loggerMessageType, String errorSource, String targetEntity, String targetServiceName, ErrorCode errorCode){ + this.loggerMessageType = loggerMessageType; + this.errorSource = errorSource; + this.targetEntity = targetEntity; + this.targetServiceName = targetServiceName; + this.errorCode = errorCode; + } + + public MessageEnum getLoggerMessageType() { + return loggerMessageType; + } + + public String getErrorSource() { + return errorSource; + } + + public String getTargetEntity() { + return targetEntity; + } + + public String getTargetServiceName() { + return targetServiceName; + } + + public ErrorCode getErrorCode() { + return errorCode; + } + + public static class Builder{ + private MessageEnum loggerMessageType; + private String errorSource = ""; + private String targetEntity = ""; + private String targetServiceName = ""; + private ErrorCode errorCode; + + public Builder(MessageEnum loggerMessageType, ErrorCode errorCode){ + this.loggerMessageType = loggerMessageType; + this.errorCode = errorCode; + } + + public Builder loggerMessageType(MessageEnum loggerMessageType){ + this.loggerMessageType = loggerMessageType; + return this; + } + + public Builder errorSource(String errorSource){ + this.errorSource = errorSource; + return this; + } + + public Builder targetEntity(String targetEntity){ + this.targetEntity = targetEntity; + return this; + } + + public Builder targetServiceName(String targetServiceName){ + this.targetServiceName = targetServiceName; + return this; + } + + public Builder errorCode(ErrorCode errorCode){ + this.errorCode = errorCode; + return this; + } + + public ErrorLoggerInfo build(){ + return new ErrorLoggerInfo(loggerMessageType, errorSource, targetEntity, targetServiceName, errorCode); + } + + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequest.java deleted file mode 100644 index e4db35bcca..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequest.java +++ /dev/null @@ -1,252 +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.apihandler.camundabeans; - -import org.openecomp.mso.apihandler.common.CommonConstants; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonRootName; - -/** - * JavaBean JSON class for a "bpmnRequest" which contains the JSON payload that - * will be passed to the Camunda process - */ -@JsonPropertyOrder({CommonConstants.REQUEST_ID_VARIABLE, - CommonConstants.IS_BASE_VF_MODULE_VARIABLE, CommonConstants.RECIPE_TIMEOUT_VARIABLE, - CommonConstants.REQUEST_ACTION_VARIABLE, CommonConstants.SERVICE_INSTANCE_ID_VARIABLE, - CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, - CommonConstants.VOLUME_GROUP_ID_VARIABLE, CommonConstants.NETWORK_ID_VARIABLE, - CommonConstants.SERVICE_TYPE_VARIABLE, CommonConstants.VNF_TYPE_VARIABLE, - CommonConstants.VF_MODULE_TYPE_VARIABLE, CommonConstants.NETWORK_TYPE_VARIABLE, - CommonConstants.REQUEST_DETAILS_VARIABLE}) -@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) -public class BpmnRequest { - - @JsonProperty(CommonConstants.CAMUNDA_HOST) - private CamundaInput host; - - @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) - private CamundaInput requestId; - - @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) - private CamundaBooleanInput isBaseVfModule; - - @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) - private CamundaIntegerInput recipeTimeout; - - @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) - private CamundaInput requestAction; - - @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) - private CamundaInput serviceInstanceId; - - @JsonProperty(CommonConstants.VNF_ID_VARIABLE) - private CamundaInput vnfId; - - @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) - private CamundaInput vfModuleId; - - @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) - private CamundaInput volumeGroupId; - - @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) - private CamundaInput networkId; - - @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) - private CamundaInput serviceType; - - @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) - private CamundaInput vnfType; - - @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) - private CamundaInput vfModuleType; - - @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) - private CamundaInput networkType; - - @JsonProperty(CommonConstants.REQUEST_DETAILS_VARIABLE) - private CamundaInput requestDetails; - - public BpmnRequest() { - /* Empty constructor */ - - } - - @JsonProperty(CommonConstants.CAMUNDA_HOST) - public CamundaInput getHost() { - return host; - } - - @JsonProperty(CommonConstants.CAMUNDA_HOST) - public void setHost(CamundaInput host) { - this.host = host; - } - - @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) - public CamundaInput getRequestId() { - return requestId; - } - - @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) - public void setRequestId(CamundaInput requestId) { - this.requestId = requestId; - } - - @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) - public CamundaBooleanInput getIsBaseVfModule() { - return isBaseVfModule; - } - - @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) - public void setIsBaseVfModule(CamundaBooleanInput isBaseVfModule) { - this.isBaseVfModule = isBaseVfModule; - } - - @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) - public CamundaIntegerInput getRecipeTimeout() { - return recipeTimeout; - } - - @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) - public void setRecipeTimeout(CamundaIntegerInput recipeTimeout) { - this.recipeTimeout = recipeTimeout; - } - - @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) - public CamundaInput getRequestAction() { - return requestAction; - } - - @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) - public void setRequestAction(CamundaInput requestAction) { - this.requestAction = requestAction; - } - @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) - public CamundaInput getServiceInstanceId() { - return serviceInstanceId; - } - - @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) - public void setServiceInstanceId(CamundaInput serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } - - @JsonProperty(CommonConstants.VNF_ID_VARIABLE) - public CamundaInput getVnfId() { - return vnfId; - } - - @JsonProperty(CommonConstants.VNF_ID_VARIABLE) - public void setVnfId(CamundaInput vnfId) { - this.vnfId = vnfId; - } - - @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) - public CamundaInput getVfModuleId() { - return vfModuleId; - } - - @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) - public void setVfModuleId(CamundaInput vfModuleId) { - this.vfModuleId = vfModuleId; - } - - @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) - public CamundaInput getVolumeGroupId() { - return volumeGroupId; - } - - @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) - public void setVolumeGroupId(CamundaInput volumeGroupId) { - this.volumeGroupId = volumeGroupId; - } - - @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) - public CamundaInput getNetworkId() { - return networkId; - } - - @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) - public void setNetworkId(CamundaInput networkId) { - this.networkId = networkId; - } - - @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) - public CamundaInput getServiceType() { - return serviceType; - } - - @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) - public void setServiceType(CamundaInput serviceType) { - this.serviceType = serviceType; - } - - @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) - public CamundaInput getVnfType() { - return vnfType; - } - - @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) - public void setVnfType(CamundaInput vnfType) { - this.vnfType = vnfType; - } - - @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) - public CamundaInput getVfModuleType() { - return vfModuleType; - } - - @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) - public void setVfModuleType(CamundaInput vfModuleType) { - this.vfModuleType = vfModuleType; - } - - @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) - public CamundaInput getNetworkType() { - return networkType; - } - - @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) - public void setNetworkType(CamundaInput networkType) { - this.networkType = networkType; - } - - @JsonProperty(CommonConstants.REQUEST_DETAILS_VARIABLE) - public CamundaInput getRequestDetails() { - return requestDetails; - } - - @JsonProperty(CommonConstants.REQUEST_DETAILS_VARIABLE) - public void setRequestDetails(CamundaInput requestDetails) { - this.requestDetails = requestDetails; - } - - - - - @Override - public String toString() { - - return "BpmnRequest"; - } - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBooleanInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBooleanInput.java deleted file mode 100644 index 07b72f0678..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBooleanInput.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.apihandler.camundabeans; - -import org.openecomp.mso.apihandler.common.CommonConstants; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that - * will be passed to the Camunda process - */ - - -public class CamundaBooleanInput { - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - private boolean value; - @JsonProperty(CommonConstants.CAMUNDA_TYPE) - private final String type = "Boolean"; - - - public CamundaBooleanInput() { - } - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - public boolean getValue() { - return value; - } - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - public void setValue(boolean value) { - this.value = value; - } - - @Override - public String toString() { - return "CamundaInput [value=" + value + ", type=" + type + "]"; - } - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBpmnRequestInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBpmnRequestInput.java deleted file mode 100644 index e93e6c1c15..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBpmnRequestInput.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.apihandler.camundabeans; - -import org.openecomp.mso.apihandler.common.CommonConstants; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that - * will be passed to the Camunda process - */ -public class CamundaBpmnRequestInput { - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - private BpmnRequest value; - @JsonProperty(CommonConstants.CAMUNDA_TYPE) - private final String type = "String"; - - - public CamundaBpmnRequestInput() { - /* Empty constructor */ - } - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - public BpmnRequest getValue() { - return value; - } - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - public void setValue(BpmnRequest value) { - this.value = value; - } - - @Override - public String toString() { - return "CamundaInput [value=" + value + ", type=" + type + "]"; - } - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaInput.java deleted file mode 100644 index 07a3fa4a76..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaInput.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.apihandler.camundabeans; - - -import org.openecomp.mso.apihandler.common.CommonConstants; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that - * will be passed to the Camunda process - * - */ - - -public class CamundaInput { - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - private String value; - @JsonProperty(CommonConstants.CAMUNDA_TYPE) - private final String type = "String"; - - - public CamundaInput() { - /* Empty constructor */ - } - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - public String getValue() { - return value; - } - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - public void setValue(String value) { - this.value = value; - } - - @Override - public String toString() { - return "CamundaInput [value=" + value + ", type=" + type + "]"; - } - - - - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaIntegerInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaIntegerInput.java deleted file mode 100644 index 9a1bbca77a..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaIntegerInput.java +++ /dev/null @@ -1,58 +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.apihandler.camundabeans; - -import org.openecomp.mso.apihandler.common.CommonConstants; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that - * will be passed to the Camunda process - */ -public class CamundaIntegerInput { - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - private int value; - @JsonProperty(CommonConstants.CAMUNDA_TYPE) - private final String type = "Integer"; - - - public CamundaIntegerInput() { - } - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - public int getValue() { - return value; - } - - @JsonProperty(CommonConstants.CAMUNDA_VALUE) - public void setValue(int value) { - this.value = value; - } - - @Override - public String toString() { - return "CamundaInput [value=" + Integer.toString(value) + ", type=" + type + "]"; - } - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaRequest.java deleted file mode 100644 index 60a9efe9b6..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaRequest.java +++ /dev/null @@ -1,133 +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.apihandler.camundabeans; - - - -import org.openecomp.mso.apihandler.common.CommonConstants; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonRootName; - -/** - * JavaBean JSON class for a "variables" which contains the xml payload that - * will be passed to the Camunda process - * - */ -@JsonPropertyOrder({ CommonConstants.CAMUNDA_SERVICE_INPUT, CommonConstants.CAMUNDA_HOST, - CommonConstants.SCHEMA_VERSION_HEADER, CommonConstants.REQUEST_ID_HEADER, CommonConstants.SERVICE_INSTANCE_ID_HEADER, - CommonConstants. REQUEST_TIMEOUT_HEADER, CommonConstants.CAMUNDA_SERVICE_INPUT}) -@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) -public class CamundaRequest { - - @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) - private CamundaInput serviceInput; - - @JsonProperty(CommonConstants.CAMUNDA_HOST) - private CamundaInput host; - - @JsonProperty(CommonConstants.SCHEMA_VERSION_HEADER) - private CamundaInput schema; - - @JsonProperty(CommonConstants.REQUEST_ID_HEADER) - private CamundaInput reqid; - - @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_HEADER) - private CamundaInput svcid; - - @JsonProperty(CommonConstants.REQUEST_TIMEOUT_HEADER) - private CamundaInput timeout; - - public CamundaRequest() { - } - - @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) - public CamundaInput getServiceInput() { - return serviceInput; - } - - @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) - public void setServiceInput(CamundaInput serviceInput) { - this.serviceInput = serviceInput; - } - - @JsonProperty(CommonConstants.CAMUNDA_HOST) - public CamundaInput getHost() { - return host; - } - - @JsonProperty(CommonConstants.CAMUNDA_HOST) - public void setHost(CamundaInput host) { - this.host = host; - } - - @JsonProperty(CommonConstants.SCHEMA_VERSION_HEADER) - public CamundaInput getSchema() { - return schema; - } - - @JsonProperty(CommonConstants.SCHEMA_VERSION_HEADER) - public void setSchema(CamundaInput schema) { - this.schema = schema; - } - - @JsonProperty(CommonConstants.REQUEST_ID_HEADER) - public CamundaInput getReqid() { - return reqid; - } - - @JsonProperty(CommonConstants.REQUEST_ID_HEADER) - public void setReqid(CamundaInput reqid) { - this.reqid = reqid; - } - - @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_HEADER) - public CamundaInput getSvcid() { - return svcid; - } - - @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_HEADER) - public void setSvcid(CamundaInput svcid) { - this.svcid = svcid; - } - - - @JsonProperty(CommonConstants.REQUEST_TIMEOUT_HEADER) - public CamundaInput getTimeout() { - return timeout; - } - - @JsonProperty(CommonConstants.REQUEST_TIMEOUT_HEADER) - public void setTimeout(CamundaInput timeout) { - this.timeout = timeout; - } - - - - @Override - public String toString() { - return "CamundaRequest [serviceInput=" + serviceInput + ", host=" - + host + ", schema=" + schema + ", reqid=" + reqid + ", svcid=" - + svcid + ", timeout=" + timeout + "]"; - } - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaResponse.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaResponse.java deleted file mode 100644 index 64b7d86b59..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaResponse.java +++ /dev/null @@ -1,102 +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.apihandler.camundabeans; - -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; - -// This class must be 100% JSON-compatible with the BPMN WorkflowResponse class. -// TODO: BPMN and the API-H should use a common class. - -/** - * A synchronous response from a workflow. - */ -@JsonRootName(value = "WorkflowResponse") -public class CamundaResponse { - - @JsonProperty("processInstanceId") - private String processInstanceId; - - @JsonProperty("messageCode") - private int messageCode; - - @JsonProperty("message") - private String message; - - @JsonProperty("variables") - private Map variables; - - @JsonProperty("content") - private String content; - - public String getProcessInstanceId() { - return processInstanceId; - } - - public void setProcessInstanceId(String processInstanceId) { - this.processInstanceId = processInstanceId; - } - - public int getMessageCode() { - return messageCode; - } - - public void setMessageCode(int messageCode) { - this.messageCode = messageCode; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public Map getVariables() { - return variables; - } - - public void setVariables(Map variables) { - this.variables = variables; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" - + "processInstanceId=" + processInstanceId - + ",messageCode=" + messageCode - + ",message=" + message - + ",variables=" + variables - + ",content=" + content - + "]"; - } -} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java deleted file mode 100644 index 9f30e67897..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java +++ /dev/null @@ -1,300 +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.apihandler.camundabeans; - -import org.openecomp.mso.apihandler.common.CommonConstants; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonRootName; - -/** - * JavaBean JSON class for a "variables" which contains the JSON payload that - * will be passed to the Camunda process - */ -@JsonPropertyOrder({CommonConstants.CAMUNDA_SERVICE_INPUT, CommonConstants.REQUEST_ID_VARIABLE, - CommonConstants.REQUEST_ID_HEADER, - CommonConstants.IS_BASE_VF_MODULE_VARIABLE, CommonConstants.RECIPE_TIMEOUT_VARIABLE, - CommonConstants.REQUEST_ACTION_VARIABLE, CommonConstants.SERVICE_INSTANCE_ID_VARIABLE, - CommonConstants.CORRELATION_ID, CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, - CommonConstants.VOLUME_GROUP_ID_VARIABLE, CommonConstants.NETWORK_ID_VARIABLE, - CommonConstants.CONFIGURATION_ID_VARIABLE, CommonConstants.SERVICE_TYPE_VARIABLE, - CommonConstants.VNF_TYPE_VARIABLE, CommonConstants.VF_MODULE_TYPE_VARIABLE, - CommonConstants.NETWORK_TYPE_VARIABLE, CommonConstants.CAMUNDA_SERVICE_INPUT, - CommonConstants.CAMUNDA_SERVICE_INPUT, CommonConstants.RECIPE_PARAMS}) -@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) -public class CamundaVIDRequest { - - @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) - private CamundaInput serviceInput; - - @JsonProperty(CommonConstants.CAMUNDA_HOST) - private CamundaInput host; - - @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) - private CamundaInput requestId; - - @JsonProperty(CommonConstants.REQUEST_ID_HEADER) - private CamundaInput msoRequestId; - - @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) - private CamundaBooleanInput isBaseVfModule; - - @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) - private CamundaIntegerInput recipeTimeout; - - @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) - private CamundaInput requestAction; - - @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) - private CamundaInput serviceInstanceId; - - @JsonProperty(CommonConstants.CORRELATION_ID) - private CamundaInput correlationId; - - @JsonProperty(CommonConstants.VNF_ID_VARIABLE) - private CamundaInput vnfId; - - @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) - private CamundaInput vfModuleId; - - @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) - private CamundaInput volumeGroupId; - - @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) - private CamundaInput networkId; - - @JsonProperty(CommonConstants.CONFIGURATION_ID_VARIABLE) - private CamundaInput configurationId; - - @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) - private CamundaInput serviceType; - - @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) - private CamundaInput vnfType; - - @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) - private CamundaInput vfModuleType; - - @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) - private CamundaInput networkType; - - @JsonProperty(CommonConstants.RECIPE_PARAMS) - private CamundaInput recipeParams; - - @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) - public CamundaInput getServiceInput() { - return serviceInput; - } - - @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) - public void setServiceInput(CamundaInput serviceInput) { - this.serviceInput = serviceInput; - } - - @JsonProperty(CommonConstants.CAMUNDA_HOST) - public CamundaInput getHost() { - return host; - } - - @JsonProperty(CommonConstants.CAMUNDA_HOST) - public void setHost(CamundaInput host) { - this.host = host; - } - - @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) - public CamundaInput getRequestId() { - return requestId; - } - - @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) - public void setRequestId(CamundaInput requestId) { - this.requestId = requestId; - } - - @JsonProperty(CommonConstants.REQUEST_ID_HEADER) - public CamundaInput getMsoRequestId() { - return msoRequestId; - } - - @JsonProperty(CommonConstants.REQUEST_ID_HEADER) - public void setMsoRequestId(CamundaInput msoRequestIdp) { - this.msoRequestId = msoRequestIdp; - } - - @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) - public CamundaBooleanInput getIsBaseVfModule() { - return isBaseVfModule; - } - - @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) - public void setIsBaseVfModule(CamundaBooleanInput isBaseVfModule) { - this.isBaseVfModule = isBaseVfModule; - } - - @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) - public CamundaIntegerInput getRecipeTimeout() { - return recipeTimeout; - } - - @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) - public void setRecipeTimeout(CamundaIntegerInput recipeTimeout) { - this.recipeTimeout = recipeTimeout; - } - - @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) - public CamundaInput getRequestAction() { - return requestAction; - } - - @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) - public void setRequestAction(CamundaInput requestAction) { - this.requestAction = requestAction; - } - @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) - public CamundaInput getServiceInstanceId() { - return serviceInstanceId; - } - - @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) - public void setServiceInstanceId(CamundaInput serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } - - @JsonProperty(CommonConstants.CORRELATION_ID) - public CamundaInput getCorrelationId() { - return correlationId; - } - - @JsonProperty(CommonConstants.CORRELATION_ID) - public void setCorrelationId(CamundaInput correlationId) { - this.correlationId = correlationId; - } - - @JsonProperty(CommonConstants.VNF_ID_VARIABLE) - public CamundaInput getVnfId() { - return vnfId; - } - - @JsonProperty(CommonConstants.VNF_ID_VARIABLE) - public void setVnfId(CamundaInput vnfId) { - this.vnfId = vnfId; - } - - @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) - public CamundaInput getVfModuleId() { - return vfModuleId; - } - - @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) - public void setVfModuleId(CamundaInput vfModuleId) { - this.vfModuleId = vfModuleId; - } - - @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) - public CamundaInput getVolumeGroupId() { - return volumeGroupId; - } - - @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) - public void setVolumeGroupId(CamundaInput volumeGroupId) { - this.volumeGroupId = volumeGroupId; - } - - @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) - public CamundaInput getNetworkId() { - return networkId; - } - - @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) - public void setNetworkId(CamundaInput networkId) { - this.networkId = networkId; - } - - @JsonProperty(CommonConstants.CONFIGURATION_ID_VARIABLE) - public CamundaInput getConfigurationId() { - return configurationId; - } - - @JsonProperty(CommonConstants.CONFIGURATION_ID_VARIABLE) - public void setConfigurationId(CamundaInput configurationId) { - this.configurationId = configurationId; - } - - @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) - public CamundaInput getServiceType() { - return serviceType; - } - - @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) - public void setServiceType(CamundaInput serviceType) { - this.serviceType = serviceType; - } - - @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) - public CamundaInput getVnfType() { - return vnfType; - } - - @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) - public void setVnfType(CamundaInput vnfType) { - this.vnfType = vnfType; - } - - @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) - public CamundaInput getVfModuleType() { - return vfModuleType; - } - - @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) - public void setVfModuleType(CamundaInput vfModuleType) { - this.vfModuleType = vfModuleType; - } - - @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) - public CamundaInput getNetworkType() { - return networkType; - } - - @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) - public void setNetworkType(CamundaInput networkType) { - this.networkType = networkType; - } - - @JsonProperty(CommonConstants.RECIPE_PARAMS) - public CamundaInput getRecipeParams() { - return recipeParams; - } - - @JsonProperty(CommonConstants.RECIPE_PARAMS) - public void setRecipeParams(CamundaInput recipeParams) { - this.recipeParams = recipeParams; - } - - @Override - public String toString() { - //return "CamundaRequest [requestId=" + + ", host=" - // + host + ", schema=" + schema + ", reqid=" + reqid + ", svcid=" - // + svcid + ", timeout=" + timeout + "]"; - return "CamundaRequest"; - } - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/Track.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/Track.java deleted file mode 100644 index e1928ebc76..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/Track.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.apihandler.camundabeans; - -public class Track { - - String title; - String singer; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getSinger() { - return singer; - } - - public void setSinger(String singer) { - this.singer = singer; - } - - @Override - public String toString() { - return "Track [title=" + title + ", singer=" + singer + "]"; - } - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java deleted file mode 100644 index 85fe52f24c..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java +++ /dev/null @@ -1,96 +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.apihandler.common; - -import java.io.IOException; - -import javax.ws.rs.core.MediaType; -import javax.xml.bind.DatatypeConverter; - -import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; - -import org.openecomp.mso.logger.MsoLogger; - -public class BPELRestClient extends RequestClient { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - - public BPELRestClient () { - super (CommonConstants.BPEL); - } - - @Override - public HttpResponse post (String bpelReqXML, - String requestId, - String requestTimeout, - String schemaVersion, - String serviceInstanceId, - String action) throws ClientProtocolException, IOException { - String encryptedCredentials; - HttpPost post = new HttpPost (url); - msoLogger.debug ("BPEL url is: " + url); - StringEntity input = new StringEntity (bpelReqXML); - input.setContentType (MediaType.TEXT_XML); - if (props != null) { - encryptedCredentials = props.getProperty (CommonConstants.BPEL_AUTH,null); - if (encryptedCredentials != null) { - String userCredentials = getEncryptedPropValue (encryptedCredentials, - CommonConstants.DEFAULT_BPEL_AUTH, - CommonConstants.ENCRYPTION_KEY); - if (userCredentials != null) { - post.addHeader ("Authorization", - "Basic " + DatatypeConverter.printBase64Binary (userCredentials.getBytes ())); - } - } - } - post.addHeader (CommonConstants.REQUEST_ID_HEADER, requestId); - post.addHeader (CommonConstants.REQUEST_TIMEOUT_HEADER, requestTimeout); - post.addHeader (CommonConstants.SCHEMA_VERSION_HEADER, schemaVersion); - if (serviceInstanceId != null) { - post.addHeader (CommonConstants.SERVICE_INSTANCE_ID_HEADER, serviceInstanceId); - } - if (action != null) { - post.addHeader (CommonConstants.ACTION_HEADER, action); - } - post.setEntity (input); - HttpResponse response = client.execute (post); - msoLogger.debug ("bpel response " + response); - return response; - } - - @Override - public HttpResponse post (String bpelReqXML) { - return null; - } - - @Override - public HttpResponse post(RequestClientParamater params) { - return null; - } - - @Override - public HttpResponse get() { - return null; - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java deleted file mode 100644 index c0cfdf9bec..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java +++ /dev/null @@ -1,254 +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.apihandler.common; - -import java.io.IOException; - -import javax.xml.bind.DatatypeConverter; - -import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.openecomp.mso.apihandler.camundabeans.CamundaBooleanInput; -import org.openecomp.mso.apihandler.camundabeans.CamundaInput; -import org.openecomp.mso.apihandler.camundabeans.CamundaIntegerInput; -import org.openecomp.mso.apihandler.camundabeans.CamundaRequest; -import org.openecomp.mso.apihandler.camundabeans.CamundaVIDRequest; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -public class CamundaClient extends RequestClient{ - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); - private static final String CAMUNDA_URL_MESAGE = "Camunda url is: "; - - public CamundaClient() { - super(CommonConstants.CAMUNDA); - } - - - @Override - public HttpResponse post(String camundaReqXML, String requestId, - String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws IOException { - HttpPost post = new HttpPost(url); - msoLogger.debug(CAMUNDA_URL_MESAGE + url); - String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion); - - StringEntity input = new StringEntity(jsonReq); - input.setContentType(CommonConstants.CONTENT_TYPE_JSON); - - String encryptedCredentials; - if(props!=null){ - encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); - if(encryptedCredentials != null){ - String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); - if(userCredentials != null){ - post.addHeader("Authorization", "Basic " + DatatypeConverter - .printBase64Binary(userCredentials.getBytes())); - } - } - } - - post.setEntity(input); - return client.execute(post); - } - - @Override - public HttpResponse post(String jsonReq) throws IOException { - HttpPost post = new HttpPost(url); - msoLogger.debug(CAMUNDA_URL_MESAGE + url); - - StringEntity input = new StringEntity(jsonReq); - input.setContentType(CommonConstants.CONTENT_TYPE_JSON); - - String encryptedCredentials; - if(props!=null){ - encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); - if(encryptedCredentials != null){ - String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); - if(userCredentials != null){ - post.addHeader("Authorization", "Basic " + DatatypeConverter - .printBase64Binary(userCredentials.getBytes())); - } - } - } - - post.setEntity(input); - - return client.execute(post); - } - - @Override - public HttpResponse post(RequestClientParamater params) throws IOException { - HttpPost post = new HttpPost(url); - msoLogger.debug(CAMUNDA_URL_MESAGE + url); - String jsonReq = wrapVIDRequest(params); - - StringEntity input = new StringEntity(jsonReq); - input.setContentType(CommonConstants.CONTENT_TYPE_JSON); - String encryptedCredentials; - if(props!=null){ - encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); - if(encryptedCredentials != null){ - String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); - if(userCredentials != null){ - post.addHeader("Authorization", "Basic " + DatatypeConverter - .printBase64Binary(userCredentials.getBytes())); - } - } - } - post.setEntity(input); - return client.execute(post); - } - - @Override - public HttpResponse get() { - return null; - } - - private String wrapRequest(String reqXML, String requestId, String serviceInstanceId, String requestTimeout, String schemaVersion){ - String jsonReq = null; - if(reqXML == null){ - reqXML =""; - } - if(requestTimeout == null){ - requestTimeout =""; - } - if(schemaVersion == null){ - schemaVersion = ""; - } - try{ - CamundaRequest camundaRequest = new CamundaRequest(); - CamundaInput camundaInput = new CamundaInput(); - CamundaInput host = new CamundaInput(); - CamundaInput schema = new CamundaInput(); - CamundaInput reqid = new CamundaInput(); - CamundaInput svcid = new CamundaInput(); - CamundaInput timeout = new CamundaInput(); - camundaInput.setValue(reqXML); - host.setValue(parseURL()); - schema.setValue(schemaVersion); - reqid.setValue(requestId); - svcid.setValue(serviceInstanceId); - timeout.setValue(requestTimeout); - camundaRequest.setServiceInput(camundaInput); - camundaRequest.setHost(host); - camundaRequest.setReqid(reqid); - camundaRequest.setSvcid(svcid); - camundaRequest.setSchema(schema); - camundaRequest.setTimeout(timeout); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - - jsonReq = mapper.writeValueAsString(camundaRequest); - msoLogger.debug("request body is " + jsonReq); - }catch(Exception e){ - msoLogger.error(MessageEnum.APIH_WARP_REQUEST, "Camunda", "wrapRequest", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH Warp request", e); - } - return jsonReq; - } - - private String wrapVIDRequest(RequestClientParamater requestClientParamater) { - String jsonReq = null; - try{ - CamundaVIDRequest camundaRequest = new CamundaVIDRequest(); - CamundaInput serviceInput = new CamundaInput(); - CamundaInput host = new CamundaInput(); - CamundaInput requestIdInput= new CamundaInput(); - CamundaBooleanInput isBaseVfModuleInput = new CamundaBooleanInput(); - CamundaIntegerInput recipeTimeoutInput = new CamundaIntegerInput(); - CamundaInput requestActionInput = new CamundaInput(); - CamundaInput serviceInstanceIdInput = new CamundaInput(); - CamundaInput correlationIdInput = new CamundaInput(); - CamundaInput vnfIdInput = new CamundaInput(); - CamundaInput vfModuleIdInput = new CamundaInput(); - CamundaInput volumeGroupIdInput = new CamundaInput(); - CamundaInput networkIdInput = new CamundaInput(); - CamundaInput configurationIdInput = new CamundaInput(); - CamundaInput serviceTypeInput = new CamundaInput(); - CamundaInput vnfTypeInput = new CamundaInput(); - CamundaInput vfModuleTypeInput = new CamundaInput(); - CamundaInput networkTypeInput = new CamundaInput(); - CamundaInput recipeParamsInput = new CamundaInput(); - host.setValue(parseURL()); - requestIdInput.setValue(StringUtils.defaultString(requestClientParamater.getRequestId())); - isBaseVfModuleInput.setValue(requestClientParamater.isBaseVfModule()); - recipeTimeoutInput.setValue(requestClientParamater.getRecipeTimeout()); - requestActionInput.setValue(StringUtils.defaultString(requestClientParamater.getRequestAction())); - serviceInstanceIdInput.setValue(StringUtils.defaultString(requestClientParamater.getServiceInstanceId())); - correlationIdInput.setValue(StringUtils.defaultString(requestClientParamater.getCorrelationId())); - vnfIdInput.setValue(StringUtils.defaultString(requestClientParamater.getVnfId())); - vfModuleIdInput.setValue(StringUtils.defaultString(requestClientParamater.getVfModuleId())); - volumeGroupIdInput.setValue(StringUtils.defaultString(requestClientParamater.getVolumeGroupId())); - networkIdInput.setValue(StringUtils.defaultString(requestClientParamater.getNetworkId())); - configurationIdInput.setValue(StringUtils.defaultString(requestClientParamater.getConfigurationId())); - serviceTypeInput.setValue(StringUtils.defaultString(requestClientParamater.getServiceType())); - vnfTypeInput.setValue(StringUtils.defaultString(requestClientParamater.getVnfType())); - vfModuleTypeInput.setValue(StringUtils.defaultString(requestClientParamater.getVfModuleType())); - networkTypeInput.setValue(StringUtils.defaultString(requestClientParamater.getNetworkType())); - recipeParamsInput.setValue(requestClientParamater.getRecipeParamXsd()); - serviceInput.setValue(StringUtils.defaultString(requestClientParamater.getRequestDetails())); - camundaRequest.setServiceInput(serviceInput); - camundaRequest.setHost(host); - camundaRequest.setRequestId(requestIdInput); - camundaRequest.setMsoRequestId(requestIdInput); - camundaRequest.setIsBaseVfModule(isBaseVfModuleInput); - camundaRequest.setRecipeTimeout(recipeTimeoutInput); - camundaRequest.setRequestAction(requestActionInput); - camundaRequest.setServiceInstanceId(serviceInstanceIdInput); - camundaRequest.setCorrelationId(correlationIdInput); - camundaRequest.setVnfId(vnfIdInput); - camundaRequest.setVfModuleId(vfModuleIdInput); - camundaRequest.setVolumeGroupId(volumeGroupIdInput); - camundaRequest.setNetworkId(networkIdInput); - camundaRequest.setConfigurationId(configurationIdInput); - camundaRequest.setServiceType(serviceTypeInput); - camundaRequest.setVnfType(vnfTypeInput); - camundaRequest.setVfModuleType(vfModuleTypeInput); - camundaRequest.setNetworkType(networkTypeInput); - camundaRequest.setRecipeParams(recipeParamsInput); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - - jsonReq = mapper.writeValueAsString(camundaRequest); - msoLogger.debug("request body is " + jsonReq); - }catch(Exception e){ - msoLogger.error(MessageEnum.APIH_WARP_REQUEST, "Camunda", "wrapVIDRequest", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH Warp request", e); - } - return jsonReq; - } - - private String parseURL(){ - String[] parts = url.split(":"); - String host = ""; - if(parts.length>=2){ - host = parts[1]; - if(host.length()>2){ - host = host.substring(2); - } - } - return host; - } - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java deleted file mode 100644 index cbbbff3dff..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.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.apihandler.common; - -import java.io.IOException; - -import javax.xml.bind.DatatypeConverter; - -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.openecomp.mso.logger.MsoLogger; - -public class CamundaTaskClient extends RequestClient{ - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); - - public CamundaTaskClient() { - super(CommonConstants.CAMUNDATASK); - } - - @Override - public HttpResponse post(String jsonReq) throws IOException{ - HttpPost post = new HttpPost(url); - msoLogger.debug("Camunda Task url is: "+ url); - - StringEntity input = new StringEntity(jsonReq); - input.setContentType(CommonConstants.CONTENT_TYPE_JSON); - - String encryptedCredentials; - if(props!=null){ - encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); - if(encryptedCredentials != null){ - String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); - if(userCredentials != null){ - post.addHeader("Authorization", "Basic " + DatatypeConverter - .printBase64Binary(userCredentials.getBytes())); - } - } - } - - post.setEntity(input); - return client.execute(post); - } - - @Override - public HttpResponse post(String camundaReqXML, String requestId, - String requestTimeout, String schemaVersion, String serviceInstanceId, String action) { - throw new UnsupportedOperationException("Method not supported."); - } - - @Override - public HttpResponse post(RequestClientParamater params) { - throw new UnsupportedOperationException("Method not supported."); - } - - @Override - public HttpResponse get() throws IOException { - HttpGet get = new HttpGet(url); - msoLogger.debug("Camunda Task url is: "+ url); - String encryptedCredentials; - if(props!=null){ - encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); - if(encryptedCredentials != null){ - String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); - if(userCredentials != null){ - get.addHeader("Authorization", "Basic " + new String(DatatypeConverter - .printBase64Binary(userCredentials.getBytes()))); - } - } - } - return client.execute(get); - } - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java deleted file mode 100644 index daa411a963..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.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.apihandler.common; - - -public final class CommonConstants { - - public static final String DEFAULT_BPEL_AUTH = "admin:admin"; - public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; - public static final String REQUEST_ID_HEADER = "mso-request-id"; - public static final String REQUEST_TIMEOUT_HEADER = "mso-service-request-timeout"; - public static final String SCHEMA_VERSION_HEADER = "mso-schema-version"; - public static final String SERVICE_INSTANCE_ID_HEADER = "mso-service-instance-id"; - public static final String ACTION_HEADER = "mso-action"; - public static final String CAMUNDA_SERVICE_INPUT = "bpmnRequest"; - public static final String CAMUNDA_ROOT_INPUT = "variables"; - public static final String CONTENT_TYPE_JSON= "application/json"; - public static final String CAMUNDA_TYPE = "type"; - public static final String CAMUNDA_VALUE = "value"; - public static final String CAMUNDA_URL = "camundaURL"; - public static final String CAMUNDA_AUTH = "camundaAuth"; - public static final String BPEL_SEARCH_STR = "active-bpel"; - public static final String TASK_SEARCH_STR = "task"; - public static final String BPEL_URL = "bpelURL"; - public static final String BPEL_AUTH = "bpelAuth"; - public static final int BPEL = 0; - public static final int CAMUNDA = 1; - public static final int CAMUNDATASK = 2; - public static final String CAMUNDA_HOST = "host"; - public static final String REQUEST_ID_VARIABLE = "requestId"; - public static final String IS_BASE_VF_MODULE_VARIABLE = "isBaseVfModule"; - public static final String RECIPE_TIMEOUT_VARIABLE = "recipeTimeout"; - public static final String REQUEST_ACTION_VARIABLE = "requestAction"; - public static final String SERVICE_INSTANCE_ID_VARIABLE = "serviceInstanceId"; - public static final String CORRELATION_ID = "correlationId"; - public static final String VNF_ID_VARIABLE = "vnfId"; - public static final String VF_MODULE_ID_VARIABLE = "vfModuleId"; - public static final String VOLUME_GROUP_ID_VARIABLE = "volumeGroupId"; - public static final String NETWORK_ID_VARIABLE = "networkId"; - public static final String CONFIGURATION_ID_VARIABLE = "configurationId"; - public static final String SERVICE_TYPE_VARIABLE = "serviceType"; - public static final String VNF_TYPE_VARIABLE = "vnfType"; - public static final String VF_MODULE_TYPE_VARIABLE = "vfModuleType"; - public static final String NETWORK_TYPE_VARIABLE = "networkType"; - public static final String REQUEST_DETAILS_VARIABLE = "requestDetails"; - public static final String ALACARTE_ORCHESTRATION = "mso.infra.default.alacarte.orchestrationUri"; - public static final String ALACARTE_RECIPE_TIMEOUT = "mso.infra.default.alacarte.recipeTimeout"; - public static final String RECIPE_PARAMS = "recipeParams"; - - private CommonConstants () { - // prevent creating an instance of this class - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java deleted file mode 100644 index 2cafef3253..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.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.apihandler.common; - -public final class ErrorNumbers { - - private ErrorNumbers() { - } - - public static final String REQUEST_FAILED_SCHEMA_VALIDATION = "1000"; - public static final String RECIPE_DOES_NOT_EXIST = "1010"; - public static final String VFMODULE_TYPE_DOES_NOT_EXIST = "1011"; - public static final String SERVICE_PARAMETERS_FAILED_SCHEMA_VALIDATION = "1020"; - public static final String LOCKED_SAME_SERVICE_TYPE_AND_REQUEST_ACTION = "1030"; - public static final String LOCKED_CANCEL_ON_REQUEST_IN_PROGRESS = "1031"; - public static final String LOCKED_REQUEST_IN_PROGRESS_TIMEOUT = "1032"; - public static final String LOCKED_NOT_ALLOWED_FOR_REQUEST_IN_PROGRESS = "1033"; - public static final String WITHDRAW_AFTER_COMPLETE = "1034"; - public static final String COMPLETE_AFTER_WITHDRAW = "1035"; // NOT USED - public static final String REQUEST_PREVIOUSLY_COMPLETED = "1036"; - public static final String CANNOT_RETRY_FINAL_ACTIVATION = "1037"; - public static final String PREVIOUSLY_COMPLETED_WITH_DIFF_ORDER_VERSION = "1038"; - public static final String LOCKED_DIFFERENT_REQUEST_ACTION = "1040"; - public static final String LOCKED_DIFF_REQUEST_ACTION_SAME_SERVICE_INSTANCE_ID = "1041"; - public static final String REQUEST_TIMED_OUT = "1050"; - - public static final String DISCONNECT_ALREADY_COMPLETE = "1100"; - public static final String CANCEL_ALREADY_COMPLETE = "1110"; - - public static final String LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS = "1400"; - public static final String LOCKED_SAME_ACTION_AND_VNF_ID = "1410"; - - public static final String ERROR_FROM_BPEL = "2000"; - public static final String NO_COMMUNICATION_TO_BPEL = "2010"; - public static final String NO_RESPONSE_FROM_BPEL = "2020"; - - public static final String COULD_NOT_WRITE_TO_REQUESTS_DB = "4000"; - public static final String NO_COMMUNICATION_TO_REQUESTS_DB = "4010"; - public static final String NO_COMMUNICATION_TO_CATALOG_DB = "4020"; - public static final String ERROR_FROM_CATALOG_DB = "4030"; - - public static final String ERROR_FROM_SDNC = "5300"; - public static final String NO_COMMUNICATION_TO_SDNC = "5310"; - public static final String NO_RESPONSE_FROM_SDNC = "5320"; - - public static final String NO_COMMUNICATION_TO_SDNC_ADAPTER = "7000"; - public static final String NO_RESPONSE_FROM_SDNC_ADAPTER = "7010"; - public static final String ERROR_FROM_SDNC_ADAPTER = "7020"; - - public static final String SVC_GENERAL_SERVICE_ERROR = "SVC0001"; - public static final String SVC_BAD_PARAMETER = "SVC0002"; - public static final String SVC_NO_SERVER_RESOURCES = "SVC1000"; - public static final String SVC_DETAILED_SERVICE_ERROR = "SVC2000"; - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java deleted file mode 100644 index b39b5347ee..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java +++ /dev/null @@ -1,119 +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.apihandler.common; - - -import java.io.InputStream; -import java.io.Reader; - -import org.w3c.dom.ls.LSInput; - -public class LSInputImpl implements LSInput { - - protected String fPublicId; - protected String fSystemId; - protected String fBaseSystemId; - protected InputStream fByteStream; - protected Reader fCharStream; - protected String fData; - protected String fEncoding; - protected boolean fCertifiedText; - - @Override - public InputStream getByteStream () { - return fByteStream; - } - - @Override - public void setByteStream (InputStream byteStream) { - fByteStream = byteStream; - } - - @Override - public Reader getCharacterStream () { - return fCharStream; - } - - @Override - public void setCharacterStream (Reader characterStream) { - fCharStream = characterStream; - } - - @Override - public String getStringData () { - return fData; - } - - @Override - public void setStringData (String stringData) { - fData = stringData; - } - - @Override - public String getEncoding () { - return fEncoding; - } - - @Override - public void setEncoding (String encoding) { - fEncoding = encoding; - } - - @Override - public String getPublicId () { - return fPublicId; - } - - @Override - public void setPublicId (String publicId) { - fPublicId = publicId; - } - - @Override - public String getSystemId () { - return fSystemId; - } - - @Override - public void setSystemId (String systemId) { - fSystemId = systemId; - } - - @Override - public String getBaseURI () { - return fBaseSystemId; - } - - @Override - public void setBaseURI (String baseURI) { - fBaseSystemId = baseURI; - } - - @Override - public boolean getCertifiedText () { - return fCertifiedText; - } - - @Override - public void setCertifiedText (boolean certifiedText) { - fCertifiedText = certifiedText; - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/PathResourceResolver.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/PathResourceResolver.java deleted file mode 100644 index c8c1ef08c9..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/PathResourceResolver.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.apihandler.common; - - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.InputStreamReader; - -import org.w3c.dom.ls.LSInput; -import org.w3c.dom.ls.LSResourceResolver; - -import org.openecomp.mso.logger.MsoLogger; - -public class PathResourceResolver implements LSResourceResolver { - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); - - private String path; - - public PathResourceResolver(String path) { - - this.path = path; - } - - @Override - public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { - - LSInputImpl input = new LSInputImpl(); - - InputStream stream = null; - try { - stream = new FileInputStream(path + systemId); - } catch (FileNotFoundException e) { - msoLogger.debug ("Could not resolve resource based on file: " + path + systemId, e); - } - - input.setPublicId(publicId); - input.setSystemId(systemId); - input.setBaseURI(baseURI); - input.setCharacterStream(new InputStreamReader(stream)); - - return input; - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java deleted file mode 100644 index 66369a8b69..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java +++ /dev/null @@ -1,84 +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.apihandler.common; - -import java.io.IOException; -import java.security.GeneralSecurityException; - -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.utils.CryptoUtils; - -public abstract class RequestClient { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); - protected MsoJavaProperties props; - protected String url; - protected HttpClient client; - private int type; - - public RequestClient(int type){ - this.type = type; - } - - public void setProps(MsoJavaProperties props) { - this.props = props; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getUrl() { - return url; - } - - public int getType(){ - return type; - } - - public HttpClient getClient() { - return client; - } - - public void setClient(HttpClient client) { - this.client = client; - } - - public abstract HttpResponse post(String request, String requestId, String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws IOException; - - public abstract HttpResponse post(String request) throws IOException; - - public abstract HttpResponse post(RequestClientParamater params) throws IOException; - - public abstract HttpResponse get() throws IOException; - - protected String getEncryptedPropValue (String prop, String defaultValue, String encryptionKey) { - try { - return CryptoUtils.decrypt(prop, encryptionKey); - } - catch (GeneralSecurityException e) { - msoLogger.debug("Security exception", e); - } - return defaultValue; - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java deleted file mode 100644 index 8f919861dc..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java +++ /dev/null @@ -1,61 +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.apihandler.common; - - -import org.apache.http.impl.client.DefaultHttpClient; - -import org.openecomp.mso.properties.MsoJavaProperties; - -public class RequestClientFactory { - - private RequestClientFactory() { - } - - //based on URI, returns BPEL, CamundaTask or Camunda client - public static RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{ - RequestClient retClient; - if(props ==null){ - throw new IllegalStateException("properties is null"); - } - String url; - if(orchestrationURI.contains(CommonConstants.BPEL_SEARCH_STR)){ - url = props.getProperty(CommonConstants.BPEL_URL,null) + orchestrationURI; - retClient= new BPELRestClient(); - - }else if(orchestrationURI.contains(CommonConstants.TASK_SEARCH_STR)){ - url = props.getProperty(CommonConstants.CAMUNDA_URL,null) + orchestrationURI; - retClient = new CamundaTaskClient(); - } - else{ - url = props.getProperty(CommonConstants.CAMUNDA_URL,null) + orchestrationURI; - retClient = new CamundaClient(); - } - retClient.setClient(new DefaultHttpClient()); - retClient.setProps(props); - retClient.setUrl(url); - return retClient; - - } - - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientParamater.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientParamater.java deleted file mode 100644 index 4db69199da..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientParamater.java +++ /dev/null @@ -1,242 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.apihandler.common; - -public class RequestClientParamater { - - private String requestId; - private boolean isBaseVfModule; - private int recipeTimeout; - private String requestAction; - private String serviceInstanceId; - private String correlationId; - private String vnfId; - private String vfModuleId; - private String volumeGroupId; - private String networkId; - private String configurationId; - private String serviceType; - private String vnfType; - private String vfModuleType; - private String networkType; - private String requestDetails; - private String recipeParamXsd; - - private RequestClientParamater(Builder builder) { - requestId = builder.requestId; - isBaseVfModule = builder.isBaseVfModule; - recipeTimeout = builder.recipeTimeout; - requestAction = builder.requestAction; - serviceInstanceId = builder.serviceInstanceId; - correlationId = builder.correlationId; - vnfId = builder.vnfId; - vfModuleId = builder.vfModuleId; - volumeGroupId = builder.volumeGroupId; - networkId = builder.networkId; - configurationId = builder.configurationId; - serviceType = builder.serviceType; - vnfType = builder.vnfType; - vfModuleType = builder.vfModuleType; - networkType = builder.networkType; - requestDetails = builder.requestDetails; - recipeParamXsd = builder.recipeParamXsd; - } - - public String getRequestId() { - return requestId; - } - - public boolean isBaseVfModule() { - return isBaseVfModule; - } - - public int getRecipeTimeout() { - return recipeTimeout; - } - - public String getRequestAction() { - return requestAction; - } - - public String getServiceInstanceId() { - return serviceInstanceId; - } - - public String getCorrelationId() { - return correlationId; - } - - public String getVnfId() { - return vnfId; - } - - public String getVfModuleId() { - return vfModuleId; - } - - public String getVolumeGroupId() { - return volumeGroupId; - } - - public String getNetworkId() { - return networkId; - } - - public String getConfigurationId() { - return configurationId; - } - - public String getServiceType() { - return serviceType; - } - - public String getVnfType() { - return vnfType; - } - - public String getVfModuleType() { - return vfModuleType; - } - - public String getNetworkType() { - return networkType; - } - - public String getRequestDetails() { - return requestDetails; - } - - public String getRecipeParamXsd() { - return recipeParamXsd; - } - - public static class Builder { - private String requestId; - private boolean isBaseVfModule; - private int recipeTimeout; - private String requestAction; - private String serviceInstanceId; - private String correlationId; - private String vnfId; - private String vfModuleId; - private String volumeGroupId; - private String networkId; - private String configurationId; - private String serviceType; - private String vnfType; - private String vfModuleType; - private String networkType; - private String requestDetails; - private String recipeParamXsd; - - public Builder setRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - public Builder setBaseVfModule(boolean baseVfModule) { - isBaseVfModule = baseVfModule; - return this; - } - - public Builder setRecipeTimeout(int recipeTimeout) { - this.recipeTimeout = recipeTimeout; - return this; - } - - public Builder setRequestAction(String requestAction) { - this.requestAction = requestAction; - return this; - } - - public Builder setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - return this; - } - - public Builder setCorrelationId(String correlationId) { - this.correlationId = correlationId; - return this; - } - - public Builder setVnfId(String vnfId) { - this.vnfId = vnfId; - return this; - } - - public Builder setVfModuleId(String vfModuleId) { - this.vfModuleId = vfModuleId; - return this; - } - - public Builder setVolumeGroupId(String volumeGroupId) { - this.volumeGroupId = volumeGroupId; - return this; - } - - public Builder setNetworkId(String networkId) { - this.networkId = networkId; - return this; - } - - public Builder setConfigurationId(String configurationId) { - this.configurationId = configurationId; - return this; - } - - public Builder setServiceType(String serviceType) { - this.serviceType = serviceType; - return this; - } - - public Builder setVnfType(String vnfType) { - this.vnfType = vnfType; - return this; - } - - public Builder setVfModuleType(String vfModuleType) { - this.vfModuleType = vfModuleType; - return this; - } - - public Builder setNetworkType(String networkType) { - this.networkType = networkType; - return this; - } - - public Builder setRequestDetails(String requestDetails) { - this.requestDetails = requestDetails; - return this; - } - - public Builder setRecipeParamXsd(String recipeParamXsd) { - this.recipeParamXsd = recipeParamXsd; - return this; - } - - public RequestClientParamater build(){ - return new RequestClientParamater(this); - } - } - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java deleted file mode 100644 index a8b8984343..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java +++ /dev/null @@ -1,194 +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.apihandler.common; - - -import java.io.IOException; - -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.util.EntityUtils; -import org.openecomp.mso.apihandler.camundabeans.CamundaResponse; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.utils.RootIgnoringObjectMapper; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ResponseHandler { - - private CamundaResponse response; - private int status; - private String content = ""; - private HttpResponse httpResponse; - private int type; - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); - private static final String RESPONSE_CONTENT_MSG = "response content is: "; - - public ResponseHandler(HttpResponse httpResponse, int type) { - this.httpResponse = httpResponse; - this.type=type; - parseResponse(); - } - - - private void parseResponse() { - int statusCode = httpResponse.getStatusLine().getStatusCode(); - msoLogger.debug("Returned status is: " + statusCode); - status = setStatus(statusCode); - msoLogger.debug("Parsed status is: " + status); - if(type==CommonConstants.CAMUNDA){ - parseCamunda(); - }else if(type==CommonConstants.CAMUNDATASK){ - parseCamundaTask(); - }else { - parseBpel(); - } - - } - - - - @SuppressWarnings("unchecked") - private void parseCamunda(){ - try{ - HttpEntity entity = httpResponse.getEntity(); - content = EntityUtils.toString(entity); - } catch (IOException e) { - msoLogger.debug("IOException getting Camunda response content", e); - } - - ObjectMapper mapper = new RootIgnoringObjectMapper(CamundaResponse.class); - - try { - response = mapper.readValue(content, CamundaResponse.class); - } catch (IOException e) { - msoLogger.debug("IOException getting Camunda response content", e); - } - msoLogger.debug("json response is: " + content); - if(response!=null){ - content = response.getContent(); - } - msoLogger.debug(RESPONSE_CONTENT_MSG + content); - - - if(status!=HttpStatus.SC_ACCEPTED){ - msoLogger.error(MessageEnum.APIH_ERROR_FROM_BPEL_SERVER, "Camunda", String.valueOf(status), content, "Camunda", "parseCamunda", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH from Camunda"); - } - } - - private void parseBpel(){ - - HttpEntity bpelEntity = httpResponse.getEntity(); - - try { - if (bpelEntity!=null) { - content = EntityUtils.toString(bpelEntity); - msoLogger.debug(RESPONSE_CONTENT_MSG + content); - - } - if(status!=HttpStatus.SC_ACCEPTED){ - msoLogger.error(MessageEnum.APIH_ERROR_FROM_BPEL_SERVER, "BPEL", String.valueOf(status), content, "BPEL", "parseBpel", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH from BPEL"); - } - } - catch (IOException e) { - msoLogger.debug("IOException getting BPEL response content", e); - } - } - - private void parseCamundaTask(){ - - HttpEntity camundataskEntity = httpResponse.getEntity(); - - try { - if (camundataskEntity!=null) { - content = EntityUtils.toString(camundataskEntity); - msoLogger.debug(RESPONSE_CONTENT_MSG + content); - - } - if(status!=HttpStatus.SC_NO_CONTENT && status != HttpStatus.SC_ACCEPTED){ - msoLogger.error(MessageEnum.APIH_ERROR_FROM_BPEL_SERVER, "CAMUNDATASK", String.valueOf(status), content, "CAMUNDATASK", "parseCamundaTask", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH from Camunda Task"); - } - } - catch (IOException e) { - msoLogger.debug("IOException getting Camunda Task response content", e); - } - } - - private int setStatus(int statusCode){ - int httpStatus; - switch(statusCode) { - case HttpStatus.SC_ACCEPTED: - case HttpStatus.SC_OK: - httpStatus = HttpStatus.SC_ACCEPTED; - break; - case HttpStatus.SC_BAD_REQUEST: - httpStatus = HttpStatus.SC_BAD_REQUEST; - break; - case HttpStatus.SC_UNAUTHORIZED: - case HttpStatus.SC_FORBIDDEN: - httpStatus = HttpStatus.SC_INTERNAL_SERVER_ERROR; - break; - case HttpStatus.SC_NOT_FOUND: - httpStatus = HttpStatus.SC_NOT_IMPLEMENTED; - break; - case HttpStatus.SC_INTERNAL_SERVER_ERROR: - httpStatus = HttpStatus.SC_BAD_GATEWAY; - break; - case HttpStatus.SC_SERVICE_UNAVAILABLE: - httpStatus = HttpStatus.SC_SERVICE_UNAVAILABLE; - break; - case HttpStatus.SC_NO_CONTENT: - httpStatus = HttpStatus.SC_NO_CONTENT; - break; - default: - httpStatus = HttpStatus.SC_INTERNAL_SERVER_ERROR; - break; - } - return httpStatus; - } - - - public CamundaResponse getResponse() { - return response; - } - - - public void setResponse(CamundaResponse response) { - this.response = response; - } - - - public String getContent() { - return content; - } - - - public void setContent(String content) { - this.content = content; - } - - - public int getStatus() { - return status; - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java deleted file mode 100644 index 73bf020c21..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.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.apihandler.common; - - -public class ValidationException extends Exception { - - /** - * This class simply extends Exception (without addition additional functionality) - * to provide an identifier for RequestsDB related exceptions on create, delete, query. - * - * - **/ - - private static final long serialVersionUID = 1L; - private static final String VALIDATION_FAIL_MESSAGE = "No valid $ELEMENT is specified"; - private static final String INVALID_ELEMENT_MESSAGE = "$ELEMENT is not valid in the $VERSION version"; - private static final String ELEMENT_MESSAGE = "\\$ELEMENT"; - - public ValidationException (String msg) { - super (VALIDATION_FAIL_MESSAGE.replaceAll (ELEMENT_MESSAGE, msg)); - } - - public ValidationException (String msg, Exception cause) { - super (VALIDATION_FAIL_MESSAGE.replaceAll (ELEMENT_MESSAGE, msg), cause); - } - public ValidationException(String msg, String version) { - super(INVALID_ELEMENT_MESSAGE.replaceAll(ELEMENT_MESSAGE, msg).replaceAll("\\$VERSION", version)); - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java deleted file mode 100644 index ebb1dd28cf..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java +++ /dev/null @@ -1,103 +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.apihandler.common; - - -import java.io.FileInputStream; -import java.io.IOException; - -import javax.xml.XMLConstants; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; - -import org.apache.commons.io.IOUtils; -import org.xml.sax.SAXException; - -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoAlarmLogger; -import org.openecomp.mso.logger.MsoLogger; - -public class XMLValidator { - - private static String xsdsPath; - - static { - String prefixMsoPropertiesPath = System.getProperty ("mso.config.path"); - if (prefixMsoPropertiesPath == null) { - prefixMsoPropertiesPath = ""; - } - xsdsPath = prefixMsoPropertiesPath + "xsds/"; - } - - private String stringXsd; - private String errorMsg = null; - private SchemaFactory factory; - private Schema schema; - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); - - public XMLValidator (String xsdFile) { - - try (FileInputStream xsdStream = new FileInputStream (xsdsPath + xsdFile)) { - - stringXsd = IOUtils.toString (xsdStream); - - factory = SchemaFactory.newInstance (XMLConstants.W3C_XML_SCHEMA_NS_URI); - factory.setResourceResolver (new PathResourceResolver (xsdsPath)); - factory.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true); - - String quotedXsd = stringXsd.replaceAll (""", "\""); - Source src = new StreamSource (new java.io.StringReader (quotedXsd)); - schema = factory.newSchema (src); - - } catch (IOException | SAXException e) { - msoLogger.debug ("Cannot open file " + xsdsPath + xsdFile, e); - errorMsg = "ErrorDetails: xsd file " + xsdFile + "could not be opened - " + e.getMessage (); - } - } - - // Returns null when XML valid, otherwise returns error details. - public String isXmlValid (String stringXml) { - try { - if (errorMsg != null && !errorMsg.isEmpty ()) { - return errorMsg; - } - Source src2 = new StreamSource (new java.io.StringReader (stringXml)); - Validator validator = schema.newValidator (); - validator.validate (src2); - - } catch (IOException | SAXException e) { - msoLogger.debug ("Exception: ", e); - return "ErrorDetails: " + e.getMessage (); - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_CANNOT_READ_SCHEMA, "", "", MsoLogger.ErrorCode.SchemaError, "APIH cannot read schema file", e); - alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, "Unable to read the schema file"); - return "ErrorDetails: " + "Unable to read the schema file"; - } - - return null; - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/package-info.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/package-info.java deleted file mode 100644 index 7859412ead..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/package-info.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========================================================= - */ - -/** - * Common classes for API Handlers. - */ -package org.openecomp.mso.apihandler.common; - diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/BeansTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/BeansTest.java new file mode 100644 index 0000000000..b596636f6d --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/BeansTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + +import org.junit.Test; + +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterNonConcrete; +import com.openpojo.reflection.filters.FilterPackageInfo; +import org.onap.so.openpojo.rules.HasToStringRule; +import org.onap.so.openpojo.rules.ToStringTester; + +public class BeansTest { + + + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + private PojoClassFilter enumFilter = new FilterEnum(); + + + @Test + public void pojoStructure() { + test("org.onap.so.apihandler.camundabeans"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create() + + + + + .with(new SetterTester()) + .with(new GetterTester()) + .with(new ToStringTester()) + + .build(); + + + validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete()); + } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/BpmnRequestTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/BpmnRequestTest.java new file mode 100644 index 0000000000..7087e90b73 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/BpmnRequestTest.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.apihandler.camundabeans; + +import org.junit.Test; + +public class BpmnRequestTest { + + BpmnRequest bpmnRequest = new BpmnRequest(); + + @Test + public void getHostTest() throws Exception { + bpmnRequest.getHost(); + } + + @Test + public void setHostTest() throws Exception { + bpmnRequest.setHost(new CamundaInput()); + } + + @Test + public void getRequestIdTest() throws Exception { + bpmnRequest.getRequestId(); + } + + @Test + public void setRequestIdTest() throws Exception { + bpmnRequest.setRequestId(new CamundaInput()); + } + + @Test + public void getIsBaseVfModuleTest() throws Exception { + bpmnRequest.getIsBaseVfModule(); + } + + @Test + public void setIsBaseVfModuleTest() throws Exception { + bpmnRequest.setIsBaseVfModule(new CamundaBooleanInput()); + } + + @Test + public void getRecipeTimeoutTest() throws Exception { + bpmnRequest.getRecipeTimeout(); + } + + @Test + public void setRecipeTimeoutTest() throws Exception { + bpmnRequest.setRecipeTimeout(new CamundaIntegerInput()); + } + + @Test + public void getRequestActionTest() throws Exception { + bpmnRequest.getRequestAction(); + } + + @Test + public void setRequestActionTest() throws Exception { + bpmnRequest.setRequestAction(new CamundaInput()); + } + + @Test + public void getServiceInstanceIdTest() throws Exception { + bpmnRequest.getServiceInstanceId(); + } + + @Test + public void setServiceInstanceIdTest() throws Exception { + bpmnRequest.setServiceInstanceId(new CamundaInput()); + } + + @Test + public void getVnfIdTest() throws Exception { + bpmnRequest.getVnfId(); + } + + @Test + public void setVnfIdTest() throws Exception { + bpmnRequest.setVnfId(new CamundaInput()); + } + + @Test + public void getVfModuleIdTest() throws Exception { + bpmnRequest.getVnfId(); + } + + @Test + public void setVfModuleIdTest() throws Exception { + bpmnRequest.setVfModuleId(new CamundaInput()); + } + + @Test + public void getVolumeGroupIdTest() throws Exception { + bpmnRequest.getVolumeGroupId(); + } + + @Test + public void setVolumeGroupIdTest() throws Exception { + bpmnRequest.setVolumeGroupId(new CamundaInput()); + } + + @Test + public void getNetworkIdTest() throws Exception { + bpmnRequest.getNetworkId(); + } + + @Test + public void setNetworkIdTest() throws Exception { + bpmnRequest.setNetworkId(new CamundaInput()); + } + + @Test + public void getServiceTypeTest() throws Exception { + bpmnRequest.getServiceType(); + } + + @Test + public void setServiceTypeTest() throws Exception { + bpmnRequest.setServiceType(new CamundaInput()); + } + + @Test + public void getVnfTypeTest() throws Exception { + bpmnRequest.getVnfType(); + } + + @Test + public void setVnfTypeTest() throws Exception { + bpmnRequest.setVnfType(new CamundaInput()); + } + + @Test + public void getVfModuleTypeTest() throws Exception { + bpmnRequest.getVfModuleType(); + } + + @Test + public void setVfModuleTypeTest() throws Exception { + bpmnRequest.setVfModuleType(new CamundaInput()); + } + + @Test + public void getNetworkTypeTest() throws Exception { + bpmnRequest.getNetworkType(); + } + + @Test + public void setNetworkTypeTest() throws Exception { + bpmnRequest.setNetworkType(new CamundaInput()); + } + + @Test + public void getRequestDetailsTest() throws Exception { + bpmnRequest.getRequestDetails(); + } + + @Test + public void setRequestDetailsTest() throws Exception { + bpmnRequest.setRequestDetails(new CamundaInput()); + } + +} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequestSerializerTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequestSerializerTest.java new file mode 100644 index 0000000000..36966342b2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/camundabeans/CamundaMacroRequestSerializerTest.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.camundabeans; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by ANANDSAN on 4/10/2018. + */ +public class CamundaMacroRequestSerializerTest { + @Test + public void testWithAllParameters() throws Exception{ + String jsonRequest = CamundaMacroRequestSerializer.getJsonRequest("requestId", "action", "serviceInstanceId"); + Assert.assertNotNull(jsonRequest); + Assert.assertEquals("{\"variables\":{\"mso-request-id\":{\"value\":\"requestId\",\"type\":\"String\"},\"gAction\":{\"value\":\"action\",\"type\":\"String\"},\"serviceInstanceId\":{\"value\":\"serviceInstanceId\",\"type\":\"String\"}}}", jsonRequest); + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/AllTestsTestSuite.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/AllTestsTestSuite.java new file mode 100644 index 0000000000..47c166eff9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/AllTestsTestSuite.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + +import org.junit.runner.RunWith; + +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +@RunWith(WildcardPatternSuite.class) +@SuiteClasses("**/*Test.class") +public class AllTestsTestSuite { + // the class remains empty, + // used only as a holder for the above annotations +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java new file mode 100644 index 0000000000..d7052762ab --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaClientTest.java @@ -0,0 +1,166 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.ProtocolVersion; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.message.BasicHttpResponse; +import org.apache.http.message.BasicStatusLine; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.so.apihandler.common.CamundaClient; +import org.onap.so.apihandler.common.CommonConstants; +import org.onap.so.apihandler.common.RequestClient; +import org.onap.so.apihandler.common.RequestClientFactory; +import org.springframework.mock.env.MockEnvironment; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; + + +/** + * This class implements test methods of Camunda Beans. + * + * + */ +public class CamundaClientTest{ + + + + @Mock + private HttpClient mockHttpClient; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void tesCamundaPost() throws JsonGenerationException, + JsonMappingException, IOException { + + + String responseBody ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; + + HttpResponse mockResponse = createResponse(200, responseBody); + mockHttpClient = Mockito.mock(HttpClient.class); + Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) + .thenReturn(mockResponse); + + String reqXML = "test"; + String orchestrationURI = "/engine-rest/process-definition/key/dummy/start"; + MockEnvironment environment = new MockEnvironment(); + + environment.setProperty("mso.camundaUR", "yourValue1"); + + + RequestClientFactory reqClientFactory = new RequestClientFactory(); + reqClientFactory.setEnv(environment); + RequestClient requestClient = reqClientFactory.getRequestClient(orchestrationURI); + + requestClient.setClient(mockHttpClient); + HttpResponse response = requestClient.post(reqXML, "reqId", "timeout", "version", null, null); + + + int statusCode = response.getStatusLine().getStatusCode(); + assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); + assertEquals(statusCode, HttpStatus.SC_OK); + + + requestClient = reqClientFactory.getRequestClient(orchestrationURI); + requestClient.setClient(mockHttpClient); + response = requestClient.post(null, "reqId", null, null, null, null); + assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); + assertEquals(statusCode, HttpStatus.SC_OK); + } + + private HttpResponse createResponse(int respStatus, + String respBody) { + HttpResponse response = new BasicHttpResponse( + new BasicStatusLine( + new ProtocolVersion("HTTP", 1, 1), respStatus, "")); + response.setStatusCode(respStatus); + try { + response.setEntity(new StringEntity(respBody)); + response.setHeader("Content-Type", "application/json"); + } catch (Exception e) { + e.printStackTrace(); + } + return response; + } + + public String inputStream(String JsonInput)throws IOException{ + JsonInput = "src/test/resources/CamundaClientTest" + JsonInput; + String input = new String(Files.readAllBytes(Paths.get(JsonInput))); + return input; + } + + @Test + public void wrapVIDRequestTest() throws IOException{ + CamundaClient testClient = new CamundaClient(); + testClient.setUrl("/mso/async/services/CreateGenericALaCarteServiceInstance"); + + String requestId = "f7ce78bb-423b-11e7-93f8-0050569a796"; + boolean isBaseVfModule = true; + int recipeTimeout = 10000; + String requestAction = "createInstance"; + String serviceInstanceId = "12345679"; + String correlationId = "12345679"; + String vnfId = "234567891"; + String vfModuleId = "345678912"; + String volumeGroupId = "456789123"; + String networkId = "567891234"; + String configurationId = "678912345"; + String serviceType = "testService"; + String vnfType = "testVnf"; + String vfModuleType = "vfModuleType"; + String networkType = "networkType"; + String requestDetails = "{requestDetails: }"; + String apiVersion = "6"; + boolean aLaCarte = true; + String requestUri = "v7/serviceInstances/assign"; + + String testResult = testClient.wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction, serviceInstanceId, correlationId, + vnfId, vfModuleId, volumeGroupId, networkId, configurationId, serviceType, + vnfType, vfModuleType, networkType, requestDetails, apiVersion, aLaCarte, requestUri, ""); + String expected = inputStream("/WrappedVIDRequest.json"); + + assertEquals(expected, testResult); + } + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaTaskClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaTaskClientTest.java new file mode 100644 index 0000000000..69772ee7e6 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/CamundaTaskClientTest.java @@ -0,0 +1,139 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import org.apache.http.HttpEntity; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpRequestBase; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.apihandler.common.CamundaTaskClient; +import org.onap.so.apihandler.common.CommonConstants; +import org.onap.so.apihandler.common.RequestClientParameter; +import org.springframework.core.env.Environment; + +@RunWith(MockitoJUnitRunner.class) +public class CamundaTaskClientTest { + + @Mock + private Environment env; + private CamundaTaskClient testedObject = new CamundaTaskClient(); + private HttpClient httpClientMock; + private static final String JSON_REQUEST = "{\"value1\": \"aaa\",\"value2\": \"bbb\"}"; + private static final String URL_SCHEMA = "http"; + private static final String HOST = "testhost"; + private static final int PORT = 1234; + private static final String URL_PATH = "/requestMethodSuccessful"; + private static final String URL = URL_SCHEMA + "://" + HOST + ":" + PORT + URL_PATH; + private static final String AUTHORIZATION_HEADER_NAME = "Authorization"; + + @Before + public void init() { + when(env.getProperty(eq(CommonConstants.CAMUNDA_AUTH))).thenReturn(""); + testedObject = new CamundaTaskClient(); + httpClientMock = mock(HttpClient.class); + testedObject.setClient(httpClientMock); + testedObject.setUrl(URL); + } + + @Test + public void postMethodSuccessful() throws IOException { + ArgumentCaptor httpPostCaptor = ArgumentCaptor.forClass(HttpPost.class); + testedObject.post(JSON_REQUEST); + verify(httpClientMock).execute(httpPostCaptor.capture()); + checkUri(httpPostCaptor.getValue()); + assertThat(httpPostCaptor.getValue().getEntity().getContentType().getValue()). + isEqualTo(CommonConstants.CONTENT_TYPE_JSON); + assertThat(getJsonFromEntity(httpPostCaptor.getValue().getEntity())).isEqualTo(JSON_REQUEST); + } + + @Test + public void postMethodSuccessfulWithCredentials() throws IOException { + ArgumentCaptor httpPostCaptor = ArgumentCaptor.forClass(HttpPost.class); + testedObject.setProps(env); + testedObject.post(JSON_REQUEST); + verify(httpClientMock).execute(httpPostCaptor.capture()); + assertThat(httpPostCaptor.getValue().getHeaders(AUTHORIZATION_HEADER_NAME)).isNotEmpty(); + } + + @Test + public void getMethodSuccessful() throws IOException { + ArgumentCaptor httpGetCaptor = ArgumentCaptor.forClass(HttpGet.class); + testedObject.get(); + verify(httpClientMock).execute(httpGetCaptor.capture()); + checkUri(httpGetCaptor.getValue()); + } + + @Test + public void getMethodSuccessfulWithCredentials() throws IOException { + ArgumentCaptor httpGetCaptor = ArgumentCaptor.forClass(HttpGet.class); + testedObject.setUrl(URL); + testedObject.setProps(env); + testedObject.get(); + verify(httpClientMock).execute(httpGetCaptor.capture()); + assertThat(httpGetCaptor.getValue().getHeaders(AUTHORIZATION_HEADER_NAME)).isNotEmpty(); + } + + @Test(expected = UnsupportedOperationException.class) + public void postMethodUnsupported() { + testedObject.post("", "", "", "", "", ""); + } + + @Test(expected = UnsupportedOperationException.class) + public void postMethodUnsupported2() { + testedObject.post(new RequestClientParameter.Builder().build()); + } + + private void checkUri(HttpRequestBase httpRequestBase) { + assertThat(httpRequestBase.getURI().getScheme()).isEqualTo(URL_SCHEMA); + assertThat(httpRequestBase.getURI().getHost()).isEqualTo(HOST); + assertThat(httpRequestBase.getURI().getPort()).isEqualTo(PORT); + assertThat(httpRequestBase.getURI().getPath()).isEqualTo(URL_PATH); + } + + private String getJsonFromEntity(HttpEntity httpEntity) throws IOException { + BufferedReader rd = new BufferedReader( + new InputStreamReader(httpEntity.getContent())); + StringBuilder result = new StringBuilder(); + String line; + while ((line = rd.readLine()) != null) { + result.append(line); + } + return result.toString(); + } + +} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/ResponseHandlerTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/ResponseHandlerTest.java new file mode 100644 index 0000000000..7bb054c297 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/common/ResponseHandlerTest.java @@ -0,0 +1,139 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.common; + + +import static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.startsWith; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.ProtocolVersion; +import org.apache.http.entity.StringEntity; +import org.apache.http.message.BasicHttpResponse; +import org.apache.http.message.BasicStatusLine; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.apihandler.common.ResponseHandler; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; +import org.onap.so.apihandlerinfra.exceptions.ValidateException; + +/** + * This class implements test methods of CamundaResoponseHandler. + * + * + */ +public class ResponseHandlerTest{ + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void tesParseCamundaResponse () throws ApiException { + // String body + // ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; + + String body = "{ \"response\": \"xml\"," + "\"messageCode\": 200," + + "\"message\": \"Successfully started the process\"}"; + + HttpResponse response = createResponse (200, body, "application/json"); + + ResponseHandler respHandler = new ResponseHandler (response, 1); + + int status = respHandler.getStatus (); + assertEquals (status, HttpStatus.SC_ACCEPTED); + assertEquals (respHandler.getResponse ().getMessage (), "Successfully started the process"); + + } + + @Test + public void tesParseBpelResponse () throws ApiException{ + String body = "" + + "req5" + + "test" + + "test" + + "n" + + ""; + + HttpResponse response = createResponse (200, body, "text/xml"); + + ResponseHandler respHandler = new ResponseHandler (response, 0); + + int status = respHandler.getStatus (); + assertEquals (status, HttpStatus.SC_ACCEPTED); + assertTrue (respHandler.getResponseBody () != null); + } + + @Test + public void tesMappingErrorResponse () throws ApiException { + thrown.expect(ValidateException.class); + thrown.expectMessage(startsWith("JSON Object Mapping Request")); + thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_BAD_REQUEST))); + thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); + + HttpResponse response = createResponse (HttpStatus.SC_NOT_FOUND, "error", "text/html"); + ResponseHandler respHandler = new ResponseHandler (response, 1); + + int status = respHandler.getStatus (); + + assertEquals (HttpStatus.SC_NOT_IMPLEMENTED, status); + + } + + @Test + public void tesGenricErrorResponse () throws ApiException { + + String body = "{ \"response\": \"xml\"," + "\"messageCode\": 500," + + "\"message\": \"Something went wrong\"}"; + + HttpResponse response = createResponse (500, body, "application/json"); + ResponseHandler respHandler = new ResponseHandler (response, 1); + int status = respHandler.getStatus (); + assertEquals (status, HttpStatus.SC_BAD_GATEWAY); + assertEquals (respHandler.getResponse ().getMessage (), "Something went wrong"); + } + + private HttpResponse createResponse (int respStatus, String respBody, String contentType) { + HttpResponse response = new BasicHttpResponse (new BasicStatusLine (new ProtocolVersion ("HTTP", 1, 1), + respStatus, + "")); + response.setStatusCode (respStatus); + try { + response.setEntity (new StringEntity (respBody)); + response.setHeader ("Content-Type", contentType); + } catch (Exception e) { + e.printStackTrace (); + } + return response; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandlerTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandlerTest.java new file mode 100644 index 0000000000..564121b7b5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandlerTest.java @@ -0,0 +1,72 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandler.recipe; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.client.ClientHttpResponse; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +public class CamundaClientErrorHandlerTest { + + private ClientHttpResponse clientHttpResponse; + private CamundaClientErrorHandler clientErrorHandler; + + @Before + public void before() { + clientHttpResponse = Mockito.mock(ClientHttpResponse.class); + clientErrorHandler = new CamundaClientErrorHandler(); + } + + @Test + public void handleError_SERVER_ERROR_Test() throws IOException { + Mockito.when(clientHttpResponse.getStatusCode()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR); + Mockito.when(clientHttpResponse.getBody()).thenReturn(new ByteArrayInputStream("{}".getBytes())); + clientErrorHandler.handleError(clientHttpResponse); + boolean serverHasError = clientErrorHandler.hasError(clientHttpResponse); + assertEquals(true, serverHasError); + } + + @Test + public void handleError_CLIENT_ERROR_Test() throws IOException { + Mockito.when(clientHttpResponse.getStatusCode()).thenReturn(HttpStatus.BAD_REQUEST); + Mockito.when(clientHttpResponse.getBody()).thenReturn(new ByteArrayInputStream("{}".getBytes())); + clientErrorHandler.handleError(clientHttpResponse); + boolean clientHasError = clientErrorHandler.hasError(clientHttpResponse); + assertEquals(true, clientHasError); + } + + @Test + public void handleError_SUCCESS_Test() throws IOException { + Mockito.when(clientHttpResponse.getStatusCode()).thenReturn(HttpStatus.ACCEPTED); + Mockito.when(clientHttpResponse.getBody()).thenReturn(new ByteArrayInputStream("{}".getBytes())); + clientErrorHandler.handleError(clientHttpResponse); + boolean hasNoError = clientErrorHandler.hasError(clientHttpResponse); + assertEquals(false, hasNoError); + } + +} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.java new file mode 100644 index 0000000000..b98c47490a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionMapperTest.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.onap.so.apihandlerinfra; + + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.apihandlerinfra.exceptions.*; + +import org.apache.http.HttpStatus; +import javax.ws.rs.core.Response; + + +import java.io.IOException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.anyObject; +import static org.hamcrest.core.StringStartsWith.startsWith; + +public class ApiExceptionMapperTest { + + ApiExceptionMapper mapper = new ApiExceptionMapper(); + + + @Test + public void testObjectMapperError() throws JsonProcessingException { + ObjectMapper mockedMapper = Mockito.mock(ObjectMapper.class); + Mockito.when(mockedMapper.writeValueAsString(anyObject())).thenThrow(JsonProcessingException.class); + ValidateException validateException = new ValidateException.Builder("Test", 0 , null).build(); + ApiExceptionMapper mockedException = Mockito.spy(new ApiExceptionMapper()); + Mockito.doReturn(mockedMapper).when(mockedException).createObjectMapper(); + Response resp = mockedException.toResponse((ApiException) validateException); + + /// assertEquals(resp.getStatus(), HttpStatus.SC_BAD_REQUEST); + assertThat(resp.getEntity().toString(),startsWith("Exception in buildServiceErrorResponse writing exceptionType to string")); + } + + @Test + public void testValidateResponse(){ + ValidateException validateException = new ValidateException.Builder("Test Message", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).build(); + Response resp = mapper.toResponse((ApiException) validateException); + + assertEquals(resp.getStatus(), HttpStatus.SC_BAD_REQUEST); + } + + @Test + public void testBPMNFailureResponse(){ + BPMNFailureException bpmnException = new BPMNFailureException.Builder("Test Message", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).build(); + Response resp = mapper.toResponse((ApiException) bpmnException); + + assertEquals(resp.getStatus(), HttpStatus.SC_NOT_FOUND); + } + @Test + public void testClientConnectionResponse(){ + ClientConnectionException clientConnectionException = new ClientConnectionException.Builder("test", HttpStatus.SC_INTERNAL_SERVER_ERROR,ErrorNumbers.SVC_BAD_PARAMETER).build(); + Response resp = mapper.toResponse((ApiException) clientConnectionException); + + assertEquals(resp.getStatus(), HttpStatus.SC_INTERNAL_SERVER_ERROR); + } + @Test + public void testVFModuleResponse() { + VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder("Test Message", HttpStatus.SC_CONFLICT,ErrorNumbers.SVC_BAD_PARAMETER).build(); + Response resp = mapper.toResponse((ApiException) vfModuleException); + + assertEquals(resp.getStatus(), HttpStatus.SC_CONFLICT); + } + @Test + public void testDuplicateRequestResponse() throws IOException { + DuplicateRequestException duplicateRequestException = new DuplicateRequestException.Builder("Test1", "Test2","Test3","Test4", HttpStatus.SC_BAD_GATEWAY,ErrorNumbers.SVC_BAD_PARAMETER).build(); + Response resp = mapper.toResponse((ApiException) duplicateRequestException); + + assertEquals(resp.getStatus(), HttpStatus.SC_BAD_GATEWAY); + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.java new file mode 100644 index 0000000000..bd3728c599 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/ApiExceptionTest.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.onap.so.apihandlerinfra; + +import org.apache.http.HttpStatus; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.so.apihandler.common.ErrorNumbers; +import org.onap.so.apihandlerinfra.exceptions.*; +import org.onap.so.apihandlerinfra.logging.AlarmLoggerInfo; +import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoAlarmLogger; +import org.onap.so.logger.MsoLogger; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; + +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.startsWith; + + +public class ApiExceptionTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void testRecipeNotFoundException() throws ApiException { + thrown.expect(RecipeNotFoundException.class); + thrown.expectMessage("Message rewritten"); + thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND))); + thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); + RecipeNotFoundException testException = new RecipeNotFoundException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).message("Message rewritten").build(); + throw testException; + } + + + @Test + public void testBPMNFailureException() throws ApiException { + List testVariables = new LinkedList<>(); + testVariables.add("hello"); + thrown.expect(BPMNFailureException.class); + thrown.expectMessage(startsWith("Request Failed due to BPEL error with HTTP Status =")); + thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND))); + thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); + thrown.expect(hasProperty("variables",sameBeanAs(testVariables))); + BPMNFailureException testException = new BPMNFailureException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).variables(testVariables).build(); + throw testException; + } + + + @Test + public void testClientConnectionException() throws ApiException { + IOException ioException = new IOException(); + thrown.expect(ClientConnectionException.class); + thrown.expectMessage("Client from test failed to connect"); + thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND))); + thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); + thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND))); + thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); + thrown.expect(hasProperty("cause", sameBeanAs(ioException))); + ClientConnectionException testException = new ClientConnectionException.Builder("test", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).cause(ioException).build(); + throw testException; + } + + + @Test + public void testDuplicateRequestException() throws ApiException { + ErrorLoggerInfo testLog = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + thrown.expect(DuplicateRequestException.class); + thrown.expectMessage(startsWith("Error: Locked instance")); + thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND))); + thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); + thrown.expect(hasProperty("errorLoggerInfo", sameBeanAs(testLog))); + DuplicateRequestException testException = new DuplicateRequestException.Builder("Test1", "Test2","Test3","Test4", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(testLog).build(); + throw testException; + } + + + @Test + public void testValidateException() throws ApiException { + AlarmLoggerInfo testLog = new AlarmLoggerInfo.Builder("MsoConfigurationError", MsoAlarmLogger.CRITICAL, + Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_SDNC_ADAPTER)).build(); + thrown.expect(ValidateException.class); + thrown.expectMessage("Test Message"); + thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_NOT_FOUND))); + thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR))); + thrown.expect(hasProperty("alarmLoggerInfo", sameBeanAs(testLog))); + ValidateException testException = new ValidateException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).messageID(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).alarmInfo(testLog).build(); + throw testException; + } + + + @Test + public void testVfModuleNotFoundException() throws ApiException { + thrown.expect(VfModuleNotFoundException.class); + thrown.expectMessage("Test Message"); + thrown.expect(hasProperty("httpResponseCode", is(HttpStatus.SC_CONFLICT))); + thrown.expect(hasProperty("messageID", is(ErrorNumbers.SVC_BAD_PARAMETER))); + VfModuleNotFoundException testException = new VfModuleNotFoundException.Builder("Test Message", HttpStatus.SC_NOT_FOUND,ErrorNumbers.SVC_BAD_PARAMETER).httpResponseCode(HttpStatus.SC_CONFLICT).build(); + throw testException; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/TestAppender.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/TestAppender.java new file mode 100644 index 0000000000..48711a2595 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/onap/so/apihandlerinfra/TestAppender.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra; + +import java.util.ArrayList; +import java.util.List; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.AppenderBase; + + + +public class TestAppender extends AppenderBase { + public static List events = new ArrayList<>(); + + @Override + protected void append(ILoggingEvent loggingEvent) { + events.add(loggingEvent); + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/camundabeans/BeansTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/camundabeans/BeansTest.java deleted file mode 100644 index f9d7f87e53..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/camundabeans/BeansTest.java +++ /dev/null @@ -1,72 +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.apihandler.camundabeans; - -import org.junit.Test; - -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterNonConcrete; -import com.openpojo.reflection.filters.FilterPackageInfo; -import org.openecomp.mso.openpojo.rules.HasToStringRule; -import org.openecomp.mso.openpojo.rules.ToStringTester; - -public class BeansTest { - - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - private PojoClassFilter enumFilter = new FilterEnum(); - - - @Test - public void pojoStructure() { - test("org.openecomp.mso.apihandler.camundabeans"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - - - - - .with(new SetterTester()) - .with(new GetterTester()) - .with(new ToStringTester()) - - .build(); - - - validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete()); - } - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequestTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequestTest.java deleted file mode 100644 index 6490f52a02..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequestTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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.apihandler.camundabeans; - -import org.junit.Test; - -public class BpmnRequestTest { - - BpmnRequest bpmnRequest = new BpmnRequest(); - - @Test - public void getHostTest() throws Exception { - bpmnRequest.getHost(); - } - - @Test - public void setHostTest() throws Exception { - bpmnRequest.setHost(new CamundaInput()); - } - - @Test - public void getRequestIdTest() throws Exception { - bpmnRequest.getRequestId(); - } - - @Test - public void setRequestIdTest() throws Exception { - bpmnRequest.setRequestId(new CamundaInput()); - } - - @Test - public void getIsBaseVfModuleTest() throws Exception { - bpmnRequest.getIsBaseVfModule(); - } - - @Test - public void setIsBaseVfModuleTest() throws Exception { - bpmnRequest.setIsBaseVfModule(new CamundaBooleanInput()); - } - - @Test - public void getRecipeTimeoutTest() throws Exception { - bpmnRequest.getRecipeTimeout(); - } - - @Test - public void setRecipeTimeoutTest() throws Exception { - bpmnRequest.setRecipeTimeout(new CamundaIntegerInput()); - } - - @Test - public void getRequestActionTest() throws Exception { - bpmnRequest.getRequestAction(); - } - - @Test - public void setRequestActionTest() throws Exception { - bpmnRequest.setRequestAction(new CamundaInput()); - } - - @Test - public void getServiceInstanceIdTest() throws Exception { - bpmnRequest.getServiceInstanceId(); - } - - @Test - public void setServiceInstanceIdTest() throws Exception { - bpmnRequest.setServiceInstanceId(new CamundaInput()); - } - - @Test - public void getVnfIdTest() throws Exception { - bpmnRequest.getVnfId(); - } - - @Test - public void setVnfIdTest() throws Exception { - bpmnRequest.setVnfId(new CamundaInput()); - } - - @Test - public void getVfModuleIdTest() throws Exception { - bpmnRequest.getVnfId(); - } - - @Test - public void setVfModuleIdTest() throws Exception { - bpmnRequest.setVfModuleId(new CamundaInput()); - } - - @Test - public void getVolumeGroupIdTest() throws Exception { - bpmnRequest.getVolumeGroupId(); - } - - @Test - public void setVolumeGroupIdTest() throws Exception { - bpmnRequest.setVolumeGroupId(new CamundaInput()); - } - - @Test - public void getNetworkIdTest() throws Exception { - bpmnRequest.getNetworkId(); - } - - @Test - public void setNetworkIdTest() throws Exception { - bpmnRequest.setNetworkId(new CamundaInput()); - } - - @Test - public void getServiceTypeTest() throws Exception { - bpmnRequest.getServiceType(); - } - - @Test - public void setServiceTypeTest() throws Exception { - bpmnRequest.setServiceType(new CamundaInput()); - } - - @Test - public void getVnfTypeTest() throws Exception { - bpmnRequest.getVnfType(); - } - - @Test - public void setVnfTypeTest() throws Exception { - bpmnRequest.setVnfType(new CamundaInput()); - } - - @Test - public void getVfModuleTypeTest() throws Exception { - bpmnRequest.getVfModuleType(); - } - - @Test - public void setVfModuleTypeTest() throws Exception { - bpmnRequest.setVfModuleType(new CamundaInput()); - } - - @Test - public void getNetworkTypeTest() throws Exception { - bpmnRequest.getNetworkType(); - } - - @Test - public void setNetworkTypeTest() throws Exception { - bpmnRequest.setNetworkType(new CamundaInput()); - } - - @Test - public void getRequestDetailsTest() throws Exception { - bpmnRequest.getRequestDetails(); - } - - @Test - public void setRequestDetailsTest() throws Exception { - bpmnRequest.setRequestDetails(new CamundaInput()); - } - -} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/common/CamundaTaskClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/common/CamundaTaskClientTest.java deleted file mode 100644 index f892d13599..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/apihandler/common/CamundaTaskClientTest.java +++ /dev/null @@ -1,132 +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.apihandler.common; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import org.apache.http.HttpEntity; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpRequestBase; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.openecomp.mso.properties.MsoJavaProperties; - -public class CamundaTaskClientTest { - - private CamundaTaskClient testedObject = new CamundaTaskClient(); - private HttpClient httpClientMock; - private static final String JSON_REQUEST = "{\"value1\": \"aaa\",\"value2\": \"bbb\"}"; - private static final String URL_SCHEMA = "http"; - private static final String HOST = "testhost"; - private static final int PORT = 1234; - private static final String URL_PATH = "/requestMethodSuccessful"; - private static final String URL = URL_SCHEMA + "://" + HOST + ":" + PORT + URL_PATH; - private static final String AUTHORIZATION_HEADER_NAME = "Authorization"; - - @Before - public void init() { - testedObject = new CamundaTaskClient(); - httpClientMock = mock(HttpClient.class); - testedObject.setClient(httpClientMock); - testedObject.setUrl(URL); - } - - @Test - public void postMethodSuccessful() throws IOException { - ArgumentCaptor httpPostCaptor = ArgumentCaptor.forClass(HttpPost.class); - testedObject.post(JSON_REQUEST); - verify(httpClientMock).execute(httpPostCaptor.capture()); - checkUri(httpPostCaptor.getValue()); - assertThat(httpPostCaptor.getValue().getEntity().getContentType().getValue()). - isEqualTo(CommonConstants.CONTENT_TYPE_JSON); - assertThat(getJsonFromEntity(httpPostCaptor.getValue().getEntity())).isEqualTo(JSON_REQUEST); - } - - @Test - public void postMethodSuccessfulWithCredentials() throws IOException { - ArgumentCaptor httpPostCaptor = ArgumentCaptor.forClass(HttpPost.class); - testedObject.setProps(createMsoJavaProperties()); - testedObject.post(JSON_REQUEST); - verify(httpClientMock).execute(httpPostCaptor.capture()); - assertThat(httpPostCaptor.getValue().getHeaders(AUTHORIZATION_HEADER_NAME)).isNotEmpty(); - } - - @Test - public void getMethodSuccessful() throws IOException { - ArgumentCaptor httpGetCaptor = ArgumentCaptor.forClass(HttpGet.class); - testedObject.get(); - verify(httpClientMock).execute(httpGetCaptor.capture()); - checkUri(httpGetCaptor.getValue()); - } - - @Test - public void getMethodSuccessfulWithCredentials() throws IOException { - ArgumentCaptor httpGetCaptor = ArgumentCaptor.forClass(HttpGet.class); - testedObject.setUrl(URL); - testedObject.setProps(createMsoJavaProperties()); - testedObject.get(); - verify(httpClientMock).execute(httpGetCaptor.capture()); - assertThat(httpGetCaptor.getValue().getHeaders(AUTHORIZATION_HEADER_NAME)).isNotEmpty(); - } - - @Test(expected = UnsupportedOperationException.class) - public void postMethodUnsupported() { - testedObject.post("", "", "", "", "", ""); - } - - @Test(expected = UnsupportedOperationException.class) - public void postMethodUnsupported2() { - testedObject.post(new RequestClientParamater.Builder().build()); - } - - private void checkUri(HttpRequestBase httpRequestBase) { - assertThat(httpRequestBase.getURI().getScheme()).isEqualTo(URL_SCHEMA); - assertThat(httpRequestBase.getURI().getHost()).isEqualTo(HOST); - assertThat(httpRequestBase.getURI().getPort()).isEqualTo(PORT); - assertThat(httpRequestBase.getURI().getPath()).isEqualTo(URL_PATH); - } - - private MsoJavaProperties createMsoJavaProperties() { - MsoJavaProperties msoJavaProperties = new MsoJavaProperties(); - msoJavaProperties.setProperty(CommonConstants.CAMUNDA_AUTH, ""); - return msoJavaProperties; - } - - private String getJsonFromEntity(HttpEntity httpEntity) throws IOException { - BufferedReader rd = new BufferedReader( - new InputStreamReader(httpEntity.getContent())); - StringBuilder result = new StringBuilder(); - String line; - while ((line = rd.readLine()) != null) { - result.append(line); - } - return result.toString(); - } - -} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java deleted file mode 100644 index 6cc6c562e5..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java +++ /dev/null @@ -1,125 +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.camunda.tests; - - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; - -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolVersion; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicHttpResponse; -import org.apache.http.message.BasicStatusLine; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.apihandler.common.CommonConstants; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.properties.MsoJavaProperties; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; - - -/** - * This class implements test methods of Camunda Beans. - * - * - */ -public class BPELRestClientTest { - - - - @Mock - private HttpClient mockHttpClient; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void tesBPELPost() throws JsonGenerationException, - JsonMappingException, IOException { - - - String responseBody ="" - + "req5" - + "Layer3ServiceActivateRequest" - + "OMX" - + "n" - + ""; - - HttpResponse mockResponse = createResponse(200, responseBody); - mockHttpClient = Mockito.mock(HttpClient.class); - Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) - .thenReturn(mockResponse); - - String reqXML = "test"; - String orchestrationURI = "/active-bpel/services/REST/MsoLayer3ServiceActivate"; - - MsoJavaProperties props = new MsoJavaProperties(); - props.setProperty(CommonConstants.BPEL_URL, "http://localhost:8089"); - props.setProperty("bpelAuth", "786864AA53D0DCD881AED1154230C0C3058D58B9339D2EFB6193A0F0D82530E1"); - - RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); - requestClient.setClient(mockHttpClient); - HttpResponse response = requestClient.post(reqXML, "reqId", "timeout", "version", null, null); - - - int statusCode = response.getStatusLine().getStatusCode(); - assertEquals(requestClient.getType(), CommonConstants.BPEL); - assertEquals(statusCode, HttpStatus.SC_OK); - - - } - - private HttpResponse createResponse(int respStatus, - String respBody) { - HttpResponse response = new BasicHttpResponse( - new BasicStatusLine( - new ProtocolVersion("HTTP", 1, 1), respStatus, "")); - response.setStatusCode(respStatus); - try { - response.setEntity(new StringEntity(respBody)); - response.setHeader("Content-Type", "text/xml"); - } catch (Exception e) { - e.printStackTrace(); - } - return response; - } - - - - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java deleted file mode 100644 index 69927e2126..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java +++ /dev/null @@ -1,144 +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.camunda.tests; - - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; - -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolVersion; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicHttpResponse; -import org.apache.http.message.BasicStatusLine; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.apihandler.common.CommonConstants; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.apihandler.common.RequestClientParamater; -import org.openecomp.mso.properties.MsoJavaProperties; - -/** - * This class implements test methods of Camunda Beans. - * - * - */ -public class CamundaClientTest { - - - - @Mock - private HttpClient mockHttpClient; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void tesCamundaPost() throws IOException { - String responseBody ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; - - HttpResponse mockResponse = createResponse(200, responseBody); - mockHttpClient = Mockito.mock(HttpClient.class); - Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) - .thenReturn(mockResponse); - - String reqXML = "test"; - String orchestrationURI = "/engine-rest/process-definition/key/dummy/start"; - - MsoJavaProperties props = new MsoJavaProperties(); - props.setProperty(CommonConstants.CAMUNDA_URL, "http://localhost:8089"); - - RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); - requestClient.setClient(mockHttpClient); - HttpResponse response = requestClient.post(reqXML, "reqId", "timeout", "version", null, null); - - - int statusCode = response.getStatusLine().getStatusCode(); - assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); - assertEquals(statusCode, HttpStatus.SC_OK); - - props.setProperty (CommonConstants.CAMUNDA_AUTH, "ABCD1234"); - requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); - requestClient.setClient(mockHttpClient); - response = requestClient.post(null, "reqId", null, null, null, null); - assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); - assertEquals(statusCode, HttpStatus.SC_OK); - } - - @Test - public void testCamundaPostJson() throws IOException { - String responseBody ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; - - HttpResponse mockResponse = createResponse(200, responseBody); - mockHttpClient = Mockito.mock(HttpClient.class); - Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) - .thenReturn(mockResponse); - String orchestrationURI = "/engine-rest/process-definition/key/dummy/start"; - - MsoJavaProperties props = new MsoJavaProperties(); - props.setProperty(CommonConstants.CAMUNDA_URL, "http://localhost:8089"); - - RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); - requestClient.setClient(mockHttpClient); - HttpResponse response = requestClient.post(createParams()); - assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); - assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_OK); - } - - private HttpResponse createResponse(int respStatus, - String respBody) { - HttpResponse response = new BasicHttpResponse( - new BasicStatusLine( - new ProtocolVersion("HTTP", 1, 1), respStatus, "")); - response.setStatusCode(respStatus); - try { - response.setEntity(new StringEntity(respBody)); - response.setHeader("Content-Type", "application/json"); - } catch (Exception e) { - e.printStackTrace(); - } - return response; - } - - private RequestClientParamater createParams(){ - return new RequestClientParamater.Builder().setRequestId("mso-req-id").setBaseVfModule(false). - setRecipeTimeout(180).setRequestAction("createInstance").setServiceInstanceId("svc-inst-id"). - setVnfId("vnf-id").setVfModuleId("vf-module-id").setVolumeGroupId("vg-id").setNetworkId("nw-id"). - setConfigurationId("conf-id").setServiceType("svc-type").setVnfType("vnf-type"). - setVfModuleType("vf-module-type").setNetworkType("nw-type").setRequestDetails(""). - setRecipeParamXsd("").build(); - } - - - - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaRequestTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaRequestTest.java deleted file mode 100644 index 622bb1e242..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaRequestTest.java +++ /dev/null @@ -1,81 +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.camunda.tests; - - - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; - -import org.junit.Test; -import org.openecomp.mso.apihandler.camundabeans.CamundaInput; -import org.openecomp.mso.apihandler.camundabeans.CamundaRequest; -import org.openecomp.mso.apihandler.common.CommonConstants; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -/** - * This class implements test methods of Camunda Beans. - * - * - */ -public class CamundaRequestTest { - - @Test - public final void testSerialization() throws JsonGenerationException, - JsonMappingException, IOException { - CamundaRequest camundaRequest = new CamundaRequest(); - CamundaInput camundaInput = new CamundaInput(); - CamundaInput host = new CamundaInput(); - CamundaInput schema = new CamundaInput(); - CamundaInput reqid = new CamundaInput(); - CamundaInput svcid = new CamundaInput(); - CamundaInput timeout = new CamundaInput(); - camundaInput - .setValue(" 155415ab-b4a7-4382-b4c6-d17d950604Layer3ServiceActivateRequestOMXhttps://localhost:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws50515631 SDN-ETHERNET-INTERNETHI/VLXM/950604//SW_INTERNETSubName01 MTSNJA4LCP1 "); - camundaRequest.setServiceInput(camundaInput); - host.setValue("localhost"); - camundaRequest.setHost(host); - schema.setValue("v1"); - camundaRequest.setSchema(schema); - reqid.setValue("reqid123"); - camundaRequest.setReqid(reqid); - svcid.setValue("svcid123"); - camundaRequest.setSvcid(svcid); - timeout.setValue(""); - camundaRequest.setTimeout(timeout); - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - - String json = mapper.writeValueAsString(camundaRequest); - System.out.println(json); - assertEquals( - "{\"variables\":{\""+CommonConstants.CAMUNDA_SERVICE_INPUT+"\":{\"value\":\" 155415ab-b4a7-4382-b4c6-d17d950604Layer3ServiceActivateRequestOMXhttps://localhost:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws50515631 SDN-ETHERNET-INTERNETHI/VLXM/950604//SW_INTERNETSubName01 MTSNJA4LCP1 \",\"type\":\"String\"}" + - ",\"host\":{\"value\":\"localhost\",\"type\":\"String\"},\"mso-schema-version\":{\"value\":\"v1\",\"type\":\"String\"},\"mso-request-id\":{\"value\":\"reqid123\",\"type\":\"String\"},\"mso-service-instance-id\":{\"value\":\"svcid123\",\"type\":\"String\"},\"mso-service-request-timeout\":{\"value\":\"\",\"type\":\"String\"}}}", - json); - - } - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java deleted file mode 100644 index 7fc2815b4b..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.camunda.tests; - - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.openecomp.mso.apihandler.camundabeans.CamundaResponse; -import org.openecomp.mso.utils.RootIgnoringObjectMapper; - -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * This class implements test methods of Camunda Beans. - * - * - */ -public class CamundaResponseTest { - - @Test - public final void testDeserializationWithoutRootElement() throws Exception { - - ObjectMapper mapper = new RootIgnoringObjectMapper(CamundaResponse.class); - - String content = "{" - + "\"messageCode\":202" - + ",\"message\":\"Successfully started the process\"" - + ",\"content\":\"xml\"" - + ",\"processInstanceId\":\"4d3b3201a7ce\"" - + ",\"variables\":null" - + "}"; - - CamundaResponse response = mapper.readValue(content, CamundaResponse.class); - - assertEquals( - "CamundaResponse[processInstanceId=4d3b3201a7ce,messageCode=202,message=Successfully started the process,variables=null,content=xml]", - response.toString()); - } - - @Test - public final void testDeserializationWithRootElement() throws Exception { - - ObjectMapper mapper = new RootIgnoringObjectMapper(CamundaResponse.class); - - String content = "{\"WorkflowResponse\":{" - + "\"messageCode\":202" - + ",\"message\":\"Successfully started the process\"" - + ",\"content\":\"xml\"" - + ",\"processInstanceId\":\"4d3b3201a7ce\"" - + ",\"variables\":null" - + "}}"; - - CamundaResponse response = mapper.readValue(content, CamundaResponse.class); - - assertEquals( - "CamundaResponse[processInstanceId=4d3b3201a7ce,messageCode=202,message=Successfully started the process,variables=null,content=xml]", - response.toString()); - } -} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/ResponseHandlerTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/ResponseHandlerTest.java deleted file mode 100644 index e04aba0ede..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/ResponseHandlerTest.java +++ /dev/null @@ -1,137 +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.camunda.tests; - - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; - -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolVersion; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicHttpResponse; -import org.apache.http.message.BasicStatusLine; -import org.junit.Test; -import org.openecomp.mso.apihandler.common.ResponseHandler; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; - -/** - * This class implements test methods of CamundaResoponseHandler. - * - * - */ -public class ResponseHandlerTest { - - @Test - public void tesParseCamundaResponse () throws JsonGenerationException, JsonMappingException, IOException { - - String content = "{\"WorkflowResponse\":{" - + "\"messageCode\":202" - + ",\"message\":\"Successfully started the process\"" - + ",\"content\":\"xml\"" - + ",\"processInstanceId\":\"4d3b3201a7ce\"" - + "}}"; - - HttpResponse response = createResponse (200, content, "application/json"); - - ResponseHandler respHandler = new ResponseHandler (response, 1); - - int status = respHandler.getStatus (); - assertEquals (status, HttpStatus.SC_ACCEPTED); - assertEquals (respHandler.getResponse ().getMessage (), "Successfully started the process"); - - } - - @Test - public void tesParseBpelResponse () throws JsonGenerationException, JsonMappingException, IOException { - String body = "" - + "req5" - + "Layer3ServiceActivateRequest" - + "OMX" - + "n" - + ""; - - HttpResponse response = createResponse (200, body, "text/xml"); - - ResponseHandler respHandler = new ResponseHandler (response, 0); - - int status = respHandler.getStatus (); - assertEquals (status, HttpStatus.SC_ACCEPTED); - assertTrue (respHandler.getContent() != null); - } - - @Test - public void tes404ErrorResponse () throws JsonGenerationException, JsonMappingException, IOException { - - - HttpResponse response = createResponse (HttpStatus.SC_NOT_FOUND, "error", "text/html"); - ResponseHandler respHandler = new ResponseHandler (response, 1); - - int status = respHandler.getStatus (); - - assertEquals (HttpStatus.SC_NOT_IMPLEMENTED, status); - - } - - @Test - public void tesGenricErrorResponse () throws JsonGenerationException, JsonMappingException, IOException { - - String content = "{\"WorkflowResponse\":{" - + "\"messageCode\":500" - + ",\"message\":\"Something went wrong\"" - + ",\"content\":\"xml\"" - + ",\"processInstanceId\":\"4d3b3201a7ce\"" - + "}}"; - - HttpResponse response = createResponse (500, content, "application/json"); - - ResponseHandler respHandler = new ResponseHandler (response, 1); - - int status = respHandler.getStatus (); - assertEquals (HttpStatus.SC_BAD_GATEWAY, status); - assertEquals (respHandler.getResponse ().getMessage (), "Something went wrong"); - System.out.println (respHandler.getContent()); - - } - - private HttpResponse createResponse (int respStatus, String respBody, String contentType) { - HttpResponse response = new BasicHttpResponse (new BasicStatusLine (new ProtocolVersion ("HTTP", 1, 1), - respStatus, - "")); - response.setStatusCode (respStatus); - try { - response.setEntity (new StringEntity (respBody)); - response.setHeader ("Content-Type", contentType); - } catch (Exception e) { - e.printStackTrace (); - } - return response; - } - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json b/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json new file mode 100644 index 0000000000..c4c7b030f9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/resources/CamundaClientTest/WrappedVIDRequest.json @@ -0,0 +1 @@ +{"variables":{"bpmnRequest":{"value":"{requestDetails: }","type":"String"},"requestId":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"mso-request-id":{"value":"f7ce78bb-423b-11e7-93f8-0050569a796","type":"String"},"isBaseVfModule":{"value":true,"type":"Boolean"},"recipeTimeout":{"value":10000,"type":"Integer"},"requestAction":{"value":"createInstance","type":"String"},"serviceInstanceId":{"value":"12345679","type":"String"},"correlationId":{"value":"12345679","type":"String"},"vnfId":{"value":"234567891","type":"String"},"vfModuleId":{"value":"345678912","type":"String"},"volumeGroupId":{"value":"456789123","type":"String"},"networkId":{"value":"567891234","type":"String"},"configurationId":{"value":"678912345","type":"String"},"serviceType":{"value":"testService","type":"String"},"vnfType":{"value":"testVnf","type":"String"},"vfModuleType":{"value":"vfModuleType","type":"String"},"networkType":{"value":"networkType","type":"String"},"recipeParams":{"value":"","type":"String"},"host":{"value":null,"type":"String"},"apiVersion":{"value":"6","type":"String"},"aLaCarte":{"value":true,"type":"Boolean"},"requestUri":{"value":"v7/serviceInstances/assign","type":"String"}}} \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/test/resources/logback-test.xml b/mso-api-handlers/mso-api-handler-common/src/test/resources/logback-test.xml deleted file mode 100644 index d2c17192ea..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/resources/logback-test.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - %d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n - - - - - - - - - - - - - - - - - - - - - - -- cgit 1.2.3-korg