diff options
author | xg353y <xg353y@intl.att.com> | 2017-04-11 13:30:42 +0200 |
---|---|---|
committer | xg353y <xg353y@intl.att.com> | 2017-04-11 15:34:19 +0200 |
commit | b6b7bef8bdcad15af01ac88a038dd763ce59f68f (patch) | |
tree | 399d39da23aaa37701e487df064e3e0c27709ef3 /mso-api-handlers | |
parent | 19340cad94eeaa1b580f7c0c99531de499e8ca14 (diff) |
[MSO-8] Update the maven dependency
Update the maven depenency for sdc-distribution-client to cooperate with the sdc changes.
Change-Id: I2da936e5c40cb68c7181bb78307192dd5655b5dc
Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'mso-api-handlers')
68 files changed, 1698 insertions, 3493 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/pom.xml b/mso-api-handlers/mso-api-handler-common/pom.xml index 859155a..e11fbb8 100644 --- a/mso-api-handlers/mso-api-handler-common/pom.xml +++ b/mso-api-handlers/mso-api-handler-common/pom.xml @@ -47,16 +47,6 @@ </dependency> <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpcore</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - </dependency> - - <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> 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 index 5cf859d..00e52ab 100644 --- 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 @@ -52,7 +52,7 @@ public class CamundaVIDRequest { private CamundaInput requestId; @JsonProperty(CommonConstants.REQUEST_ID_HEADER) - private CamundaInput attMsoRequestId; + private CamundaInput msoRequestId; @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) @@ -122,13 +122,13 @@ public class CamundaVIDRequest { } @JsonProperty(CommonConstants.REQUEST_ID_HEADER) - public CamundaInput getAttMsoRequestId() { - return attMsoRequestId; + public CamundaInput getMsoRequestId() { + return msoRequestId; } @JsonProperty(CommonConstants.REQUEST_ID_HEADER) - public void setAttMsoRequestId(CamundaInput attMsoRequestId) { - this.attMsoRequestId = attMsoRequestId; + public void setMsoRequestId(CamundaInput msoRequestIdp) { + this.msoRequestId = msoRequestIdp; } @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) 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 index dd83d24..d893a12 100644 --- 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,7 +38,7 @@ public class CamundaClient extends RequestClient{ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); public CamundaClient() { - super(CommonConstants.CAMUNDA); + super(CommonConstants.CAMUNDA); } @@ -141,8 +141,8 @@ public class CamundaClient extends RequestClient{ if(schemaVersion == null){ schemaVersion = ""; } - - + + try{ CamundaRequest camundaRequest = new CamundaRequest(); CamundaInput camundaInput = new CamundaInput(); @@ -221,7 +221,6 @@ public class CamundaClient extends RequestClient{ try{ CamundaVIDRequest camundaRequest = new CamundaVIDRequest(); - BpmnRequest bpmnRequest = new BpmnRequest(); CamundaInput serviceInput = new CamundaInput(); CamundaInput host = new CamundaInput(); CamundaInput requestIdInput= new CamundaInput(); @@ -253,26 +252,11 @@ public class CamundaClient extends RequestClient{ vfModuleTypeInput.setValue(vfModuleType); networkTypeInput.setValue(networkType); - bpmnRequest.setRequestId(requestIdInput); - bpmnRequest.setIsBaseVfModule(isBaseVfModuleInput); - bpmnRequest.setRecipeTimeout(recipeTimeoutInput); - bpmnRequest.setRequestAction(requestActionInput); - bpmnRequest.setServiceInstanceId(serviceInstanceIdInput); - bpmnRequest.setVnfId(vnfIdInput); - bpmnRequest.setVfModuleId(vfModuleIdInput); - bpmnRequest.setVolumeGroupId(volumeGroupIdInput); - bpmnRequest.setNetworkId(networkIdInput); - bpmnRequest.setServiceType(serviceTypeInput); - bpmnRequest.setVnfType(vnfTypeInput); - bpmnRequest.setVfModuleType(vfModuleTypeInput); - bpmnRequest.setNetworkType(networkTypeInput); - //bpmnRequest.setRequestDetails(requestDetailsInput); - serviceInput.setValue(requestDetails); camundaRequest.setServiceInput(serviceInput); camundaRequest.setHost(host); camundaRequest.setRequestId(requestIdInput); - camundaRequest.setAttMsoRequestId(requestIdInput); + camundaRequest.setMsoRequestId(requestIdInput); camundaRequest.setIsBaseVfModule(isBaseVfModuleInput); camundaRequest.setRecipeTimeout(recipeTimeoutInput); camundaRequest.setRequestAction(requestActionInput); 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 index 3a9ad60..187e0ed 100644 --- 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 @@ -26,11 +26,11 @@ 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 = "att-mso-request-id"; - public static final String REQUEST_TIMEOUT_HEADER = "att-mso-service-request-timeout"; - public static final String SCHEMA_VERSION_HEADER = "att-mso-schema-version"; - public static final String SERVICE_INSTANCE_ID_HEADER = "att-mso-service-instance-id"; - public static final String ACTION_HEADER = "att-mso-action"; + 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"; @@ -45,7 +45,7 @@ public final class CommonConstants { public static final int BPEL = 0; public static final int CAMUNDA = 1; public static final String CAMUNDA_HOST = "host"; - public static final String SDNC_UUID_HEADER = "att-mso-sdnc-request-id"; + public static final String SDNC_UUID_HEADER = "mso-sdnc-request-id"; public static final String REQUEST_ID_VARIABLE = "requestId"; public static final String IS_BASE_VF_MODULE_VARIABLE = "isBaseVfModule"; 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 index 0136a2d..eb7a012 100644 --- 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,12 +26,13 @@ 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 validationFailMessage = "No valid $ELEMENT is specified"; + private static final String invalidElementMessage = "$ELEMENT is not valid in the $VERSION version"; public ValidationException (String msg) { super (validationFailMessage.replaceAll ("\\$ELEMENT", msg)); @@ -40,5 +41,7 @@ public class ValidationException extends Exception { public ValidationException (String msg, Exception cause) { super (validationFailMessage.replaceAll ("\\$ELEMENT", msg), cause); } - + public ValidationException(String msg, String version) { + super(invalidElementMessage.replaceAll("\\$ELEMENT", msg).replaceAll("\\$VERSION", version)); + } } 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 index 46e3a46..a0bed92 100644 --- 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 @@ -70,8 +70,8 @@ public class BPELRestClientTest { JsonMappingException, IOException { - String responseBody ="<layer3activate:service-response xmlns:layer3activate=\"http://ecomp.att.com/mso/request/layer3serviceactivate/schema/v1\"" - + "xmlns:reqtype=\"http://ecomp.att.com/mso/request/types/v1\"" + String responseBody ="<layer3activate:service-response xmlns:layer3activate=\"http://org.openecomp/mso/request/layer3serviceactivate/schema/v1\"" + + "xmlns:reqtype=\"http://org.openecomp/mso/request/types/v1\"" + "xmlns:aetgt=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\"" + "xmlns:types=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\">" + "<reqtype:request-id>req5</reqtype:request-id>" 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 index bd2fee6..a988111 100644 --- 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 @@ -54,7 +54,7 @@ public class CamundaRequestTest { CamundaInput svcid = new CamundaInput(); CamundaInput timeout = new CamundaInput(); camundaInput - .setValue("<aetgt:CreateTenantRequest xmlns:aetgt=\"http://ecomp.att.com/mso/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://ecomp.att.com/mso/workflow/schema/v1\" xmlns:ns5=\"http://ecomp.att.com/mso/request/types/v1\"> <msoservtypes:request-information xmlns:msoservtypes=\"http://ecomp.att.com/mso/request/types/v1\"><msoservtypes:request-id>155415ab-b4a7-4382-b4c6-d17d950604</msoservtypes:request-id><msoservtypes:request-action>Layer3ServiceActivateRequest</msoservtypes:request-action><msoservtypes:source>OMX</msoservtypes:source><msoservtypes:notification-url>https://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</msoservtypes:notification-url><msoservtypes:order-number>5051563</msoservtypes:order-number><msoservtypes:order-version>1</msoservtypes:order-version> </msoservtypes:request-information> <msoservtypes:service-information xmlns:msoservtypes=\"http://ecomp.att.com/mso/request/types/v1\"><msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type><msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id><msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> <sdncadapterworkflow:cloudId>MTSNJA4LCP1</sdncadapterworkflow:cloudId> </aetgt:CreateTenantRequest>"); + .setValue("<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns5=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:request-information xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"><msoservtypes:request-id>155415ab-b4a7-4382-b4c6-d17d950604</msoservtypes:request-id><msoservtypes:request-action>Layer3ServiceActivateRequest</msoservtypes:request-action><msoservtypes:source>OMX</msoservtypes:source><msoservtypes:notification-url>https://localhost:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</msoservtypes:notification-url><msoservtypes:order-number>5051563</msoservtypes:order-number><msoservtypes:order-version>1</msoservtypes:order-version> </msoservtypes:request-information> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"><msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type><msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id><msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> <sdncadapterworkflow:cloudId>MTSNJA4LCP1</sdncadapterworkflow:cloudId> </aetgt:CreateTenantRequest>"); camundaRequest.setServiceInput(camundaInput); host.setValue("localhost"); camundaRequest.setHost(host); @@ -72,8 +72,8 @@ public class CamundaRequestTest { String json = mapper.writeValueAsString(camundaRequest); System.out.println(json); assertEquals( - "{\"variables\":{\""+CommonConstants.CAMUNDA_SERVICE_INPUT+"\":{\"value\":\"<aetgt:CreateTenantRequest xmlns:aetgt=\\\"http://ecomp.att.com/mso/workflow/schema/v1\\\" xmlns:sdncadapterworkflow=\\\"http://ecomp.att.com/mso/workflow/schema/v1\\\" xmlns:ns5=\\\"http://ecomp.att.com/mso/request/types/v1\\\"> <msoservtypes:request-information xmlns:msoservtypes=\\\"http://ecomp.att.com/mso/request/types/v1\\\"><msoservtypes:request-id>155415ab-b4a7-4382-b4c6-d17d950604</msoservtypes:request-id><msoservtypes:request-action>Layer3ServiceActivateRequest</msoservtypes:request-action><msoservtypes:source>OMX</msoservtypes:source><msoservtypes:notification-url>https://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</msoservtypes:notification-url><msoservtypes:order-number>5051563</msoservtypes:order-number><msoservtypes:order-version>1</msoservtypes:order-version> </msoservtypes:request-information> <msoservtypes:service-information xmlns:msoservtypes=\\\"http://ecomp.att.com/mso/request/types/v1\\\"><msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type><msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id><msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> <sdncadapterworkflow:cloudId>MTSNJA4LCP1</sdncadapterworkflow:cloudId> </aetgt:CreateTenantRequest>\",\"type\":\"String\"}" + - ",\"host\":{\"value\":\"localhost\",\"type\":\"String\"},\"att-mso-schema-version\":{\"value\":\"v1\",\"type\":\"String\"},\"att-mso-request-id\":{\"value\":\"reqid123\",\"type\":\"String\"},\"att-mso-service-instance-id\":{\"value\":\"svcid123\",\"type\":\"String\"},\"att-mso-service-request-timeout\":{\"value\":\"\",\"type\":\"String\"}}}", + "{\"variables\":{\""+CommonConstants.CAMUNDA_SERVICE_INPUT+"\":{\"value\":\"<aetgt:CreateTenantRequest xmlns:aetgt=\\\"http://org.openecomp/mso/workflow/schema/v1\\\" xmlns:sdncadapterworkflow=\\\"http://org.openecomp/mso/workflow/schema/v1\\\" xmlns:ns5=\\\"http://org.openecomp/mso/request/types/v1\\\"> <msoservtypes:request-information xmlns:msoservtypes=\\\"http://org.openecomp/mso/request/types/v1\\\"><msoservtypes:request-id>155415ab-b4a7-4382-b4c6-d17d950604</msoservtypes:request-id><msoservtypes:request-action>Layer3ServiceActivateRequest</msoservtypes:request-action><msoservtypes:source>OMX</msoservtypes:source><msoservtypes:notification-url>https://localhost:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</msoservtypes:notification-url><msoservtypes:order-number>5051563</msoservtypes:order-number><msoservtypes:order-version>1</msoservtypes:order-version> </msoservtypes:request-information> <msoservtypes:service-information xmlns:msoservtypes=\\\"http://org.openecomp/mso/request/types/v1\\\"><msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type><msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id><msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> <sdncadapterworkflow:cloudId>MTSNJA4LCP1</sdncadapterworkflow:cloudId> </aetgt:CreateTenantRequest>\",\"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/ResponseHandlerTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/ResponseHandlerTest.java index ba2c552..6318d43 100644 --- 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 @@ -65,8 +65,8 @@ public class ResponseHandlerTest { @Test public void tesParseBpelResponse () throws JsonGenerationException, JsonMappingException, IOException { - String body = "<layer3activate:service-response xmlns:layer3activate=\"http://ecomp.att.com/mso/request/layer3serviceactivate/schema/v1\"" - + "xmlns:reqtype=\"http://ecomp.att.com/mso/request/types/v1\"" + String body = "<layer3activate:service-response xmlns:layer3activate=\"http://org.openecomp/mso/request/layer3serviceactivate/schema/v1\"" + + "xmlns:reqtype=\"http://org.openecomp/mso/request/types/v1\"" + "xmlns:aetgt=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\"" + "xmlns:types=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\">" + "<reqtype:request-id>req5</reqtype:request-id>" diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml index 0cce04a..71f8249 100644 --- a/mso-api-handlers/mso-api-handler-infra/pom.xml +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@ -95,7 +95,7 @@ <plugin> <artifactId>maven-war-plugin</artifactId> - <version>2.3</version> + <version>2.4</version> <configuration> <warSourceDirectory>WebContent</warSourceDirectory> <failOnMissingWebXml>false</failOnMissingWebXml> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java index 34d739b..12cfdb0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,23 +27,24 @@ public class Constants { public static final String NETWORK_TYPES_PATH = "/{version: v1|v2|v3}/network-types"; public static final String VF_MODULE_MODEL_NAMES_PATH = "/{version: v2|v3}/vf-module-model-names"; 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 String SCHEMA_VERSION_V1 = "v1"; public static final String SCHEMA_VERSION_V2 = "v2"; public static final String SCHEMA_VERSION_V3 = "v3"; - + 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 VALID_INSTANCE_NAME_FORMAT = "^[a-zA-Z][a-zA-Z0-9._-]*$"; + + public static final String A_LA_CARTE = "aLaCarte"; +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java index 64bdc3f..5b84a59 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,10 +22,9 @@ package org.openecomp.mso.apihandlerinfra; import java.io.StringReader; import java.io.StringWriter; +import java.io.IOException; import java.sql.Timestamp; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -35,29 +34,25 @@ import java.util.StringTokenizer; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig.Feature; import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; import org.hibernate.Session; -import org.jboss.resteasy.specimpl.MultivaluedMapImpl; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.openecomp.mso.apihandler.common.ErrorNumbers; import org.openecomp.mso.apihandler.common.ValidationException; import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.CloudConfiguration; import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ModelInfo; @@ -65,18 +60,17 @@ import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.PolicyException; import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RelatedInstance; import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RelatedInstanceList; import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestError; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestInfo; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestParameters; import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceException; import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest; -import org.openecomp.mso.apihandlerinfra.vnfbeans.ActionType; -import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestInfo; import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType; import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs; import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest; -import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.db.HibernateUtils; import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.requestsdb.HibernateUtil; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb; import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.RequestsDatabase; import org.openecomp.mso.utils.UUIDChecker; @@ -107,235 +101,292 @@ public class MsoRequest { private String vfModuleType; private String vfModuleModelName; private String networkType; - private String asdcServiceModelVersion; + private String asdcServiceModelVersion; private String requestScope; + private int reqVersion; + private boolean aLaCarteFlag = false; private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); private static final String NOT_PROVIDED = "not provided"; + protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb (); + MsoRequest (String requestId) { this.requestId = requestId; this.startTime = System.currentTimeMillis(); MsoLogger.setLogContext (requestId, null); - } - + } + MsoRequest () { this.startTime = System.currentTimeMillis(); MsoLogger.setLogContext (requestId, null); } - - + + public Response buildServiceErrorResponse (int httpResponseCode, MsoException exceptionType, String text, String messageId, List<String> variables) { - this.errorCode = messageId; - - if (text != null) { - this.errorMessage = text; - } - else { - this.errorMessage = ""; - } - this.httpResponse = Integer.toString(httpResponseCode); - if(errorMessage.length() > 1999){ - errorMessage = errorMessage.substring(0, 1999); - } - - RequestError re = new RequestError(); - - if(exceptionType.name().equals("PolicyException")){ - - PolicyException pe = new PolicyException(); - pe.setMessageId(messageId); - pe.setText(text); - if(variables != null){ - for(String variable: variables){ - pe.getVariables().add(variable); - } - } - re.setPolicyException(pe); - - } else { - - ServiceException se = new ServiceException(); - se.setMessageId(messageId); - se.setText(text); - if(variables != null){ - if(variables != null){ - for(String variable: variables){ - se.getVariables().add(variable); - } - } - } - re.setServiceException(se); - } + this.errorCode = messageId; + + if (text != null) { + this.errorMessage = text; + } + else { + this.errorMessage = ""; + } + this.httpResponse = Integer.toString(httpResponseCode); + if(errorMessage.length() > 1999){ + errorMessage = errorMessage.substring(0, 1999); + } + + RequestError re = new RequestError(); + + if(exceptionType.name().equals("PolicyException")){ + + PolicyException pe = new PolicyException(); + pe.setMessageId(messageId); + pe.setText(text); + if(variables != null){ + for(String variable: variables){ + pe.getVariables().add(variable); + } + } + re.setPolicyException(pe); + + } else { + + ServiceException se = new ServiceException(); + se.setMessageId(messageId); + se.setText(text); + if(variables != null){ + if(variables != null){ + for(String variable: variables){ + se.getVariables().add(variable); + } + } + } + re.setServiceException(se); + } String requestErrorStr = null; try{ - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_DEFAULT); - requestErrorStr = mapper.writeValueAsString(re); + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_DEFAULT); + requestErrorStr = mapper.writeValueAsString(re); }catch(Exception e){ - msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in buildServiceErrorResponse writing exceptionType to string ", e); + msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in buildServiceErrorResponse writing exceptionType to string ", e); } - + return Response.status (httpResponseCode).entity(requestErrorStr).build (); - + } + private int reqVersionToInt(String version){ + if(version!=null){ + return Integer.parseInt(version.substring(1)); + }else{ + return 0; + } + } // Parse request JSON - void parse (ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, Action action) throws ValidationException { + void parse (ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, Action action, String version) throws ValidationException { msoLogger.debug ("Validating the Service Instance request"); - + this.sir = sir; this.action = action; - + this.reqVersion = reqVersionToInt(version); + msoLogger.debug ("Incoming version is: " + version + " coverting to int: " + this.reqVersion); + + try{ - ObjectMapper mapper = new ObjectMapper(); - //mapper.configure(Feature.WRAP_ROOT_VALUE, true); - requestJSON = mapper.writeValueAsString(sir.getRequestDetails()); + ObjectMapper mapper = new ObjectMapper(); + //mapper.configure(Feature.WRAP_ROOT_VALUE, true); + requestJSON = mapper.writeValueAsString(sir.getRequestDetails()); } catch(Exception e){ - throw new ValidationException ("Parse ServiceInstanceRequest to JSON string"); - } - + throw new ValidationException ("Parse ServiceInstanceRequest to JSON string"); + } + if(instanceIdMap != null){ - if(instanceIdMap.get("serviceInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("serviceInstanceId"))) { - throw new ValidationException ("serviceInstanceId"); - } - this.sir.setServiceInstanceId(instanceIdMap.get("serviceInstanceId")); - } - - if(instanceIdMap.get("vnfInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vnfInstanceId"))) { - throw new ValidationException ("vnfInstanceId"); - } - this.sir.setVnfInstanceId(instanceIdMap.get("vnfInstanceId")); - } - - if(instanceIdMap.get("vfModuleInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vfModuleInstanceId"))) { - throw new ValidationException ("vfModuleInstanceId"); - } - this.sir.setVfModuleInstanceId(instanceIdMap.get("vfModuleInstanceId")); - } - - if(instanceIdMap.get("volumeGroupInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("volumeGroupInstanceId"))) { - throw new ValidationException ("volumeGroupInstanceId"); - } - this.sir.setVolumeGroupInstanceId(instanceIdMap.get("volumeGroupInstanceId")); - } - - if(instanceIdMap.get("networkInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("networkInstanceId"))) { - throw new ValidationException ("networkInstanceId"); - } - this.sir.setNetworkInstanceId(instanceIdMap.get("networkInstanceId")); - } + if(instanceIdMap.get("serviceInstanceId") != null){ + if (!UUIDChecker.isValidUUID (instanceIdMap.get ("serviceInstanceId"))) { + throw new ValidationException ("serviceInstanceId"); + } + this.sir.setServiceInstanceId(instanceIdMap.get("serviceInstanceId")); + } + + if(instanceIdMap.get("vnfInstanceId") != null){ + if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vnfInstanceId"))) { + throw new ValidationException ("vnfInstanceId"); + } + this.sir.setVnfInstanceId(instanceIdMap.get("vnfInstanceId")); + } + + if(instanceIdMap.get("vfModuleInstanceId") != null){ + if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vfModuleInstanceId"))) { + throw new ValidationException ("vfModuleInstanceId"); + } + this.sir.setVfModuleInstanceId(instanceIdMap.get("vfModuleInstanceId")); + } + + if(instanceIdMap.get("volumeGroupInstanceId") != null){ + if (!UUIDChecker.isValidUUID (instanceIdMap.get ("volumeGroupInstanceId"))) { + throw new ValidationException ("volumeGroupInstanceId"); + } + this.sir.setVolumeGroupInstanceId(instanceIdMap.get("volumeGroupInstanceId")); + } + + if(instanceIdMap.get("networkInstanceId") != null){ + if (!UUIDChecker.isValidUUID (instanceIdMap.get ("networkInstanceId"))) { + throw new ValidationException ("networkInstanceId"); + } + this.sir.setNetworkInstanceId(instanceIdMap.get("networkInstanceId")); + } } - + + RequestParameters requestParameters = sir.getRequestDetails().getRequestParameters(); + if(this.reqVersion >= 3){ + if(requestParameters!=null){ + this.aLaCarteFlag = sir.getRequestDetails().getRequestParameters().getALaCarte(); + }else{ + this.aLaCarteFlag = false; + } + }else{ + this.aLaCarteFlag = true; + } + + if(requestParameters != null && (reqVersion < 3) && requestParameters.getAutoBuildVfModules()){ + throw new ValidationException("AutoBuildVfModule", version); + } + this.modelInfo = sir.getRequestDetails().getModelInfo(); - + if (this.modelInfo == null) { throw new ValidationException ("model-info"); } - + this.requestInfo = sir.getRequestDetails().getRequestInfo(); - + if (this.requestInfo == null) { throw new ValidationException ("requestInfo"); } - + if (modelInfo.getModelType () == null) { - throw new ValidationException ("modelType"); - } - + throw new ValidationException ("modelType"); + } + this.requestScope = modelInfo.getModelType().name(); - - if (empty (modelInfo.getModelInvariantId ()) && !(requestScope.equalsIgnoreCase (ModelType.network.name ()) && - (action == Action.createInstance || action == Action.updateInstance))) { - throw new ValidationException ("modelInvariantId"); + + //is required for serviceInstance delete macro when aLaCarte=false (v3) + //create and updates except for network + if (empty (modelInfo.getModelInvariantId ()) && ((this.reqVersion >2 && !this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) || + !(requestScope.equalsIgnoreCase (ModelType.network.name ())) && (action == Action.createInstance || action == Action.updateInstance))) { + throw new ValidationException ("modelInvariantId"); } - + if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) { - throw new ValidationException ("modelInvariantId format"); - } - - if (empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance || (action == Action.deleteInstance && - (requestScope.equalsIgnoreCase (ModelType.network.name ()) || requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))) { - throw new ValidationException ("modelName"); - } - - if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase (ModelType.network.name ()) && - (action == Action.createInstance || action == Action.updateInstance))) { - throw new ValidationException ("modelVersion"); - } - + throw new ValidationException ("modelInvariantId format"); + } + + if (this.reqVersion <= 2 && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance || (action == Action.deleteInstance && + (requestScope.equalsIgnoreCase (ModelType.network.name ()) || requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))) { + throw new ValidationException ("modelName"); + } + if(this.reqVersion > 2 && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance || (action == Action.deleteInstance && + (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){ + throw new ValidationException ("modelName"); + } + + if (empty (modelInfo.getModelVersion ()) && ((this.reqVersion >2 && !this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) || + !(requestScope.equalsIgnoreCase (ModelType.network.name ())) && (action == Action.createInstance || action == Action.updateInstance))) { + throw new ValidationException ("modelVersion"); + } + if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) { - throw new ValidationException ("modelCustomizationName"); + if(this.reqVersion<=2){ + throw new ValidationException ("modelCustomizationName"); + } else if (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) { + throw new ValidationException ("modelCustomizationId or modelCustomizationName"); + } + } + + if(this.reqVersion > 2 && (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) && requestScope.equalsIgnoreCase (ModelType.network.name ()) + && (action == Action.updateInstance || action == Action.createInstance)){ + throw new ValidationException ("modelCustomizationId"); } - + + if(!empty(modelInfo.getModelNameVersionId())){ + modelInfo.setModelVersionId(modelInfo.getModelNameVersionId()); + } + if(!empty(modelInfo.getModelVersionId())){ + modelInfo.setModelNameVersionId(modelInfo.getModelVersionId()); + } + this.cloudConfiguration = sir.getRequestDetails ().getCloudConfiguration (); - if (!requestScope.equalsIgnoreCase (ModelType.service.name ()) && cloudConfiguration == null) { - throw new ValidationException ("cloudConfiguration"); + if ( (((!this.aLaCarteFlag && requestScope.equalsIgnoreCase (ModelType.service.name ())) || + (!requestScope.equalsIgnoreCase (ModelType.service.name ())) && action != Action.updateInstance)) + && cloudConfiguration == null) { + throw new ValidationException ("cloudConfiguration"); } - + if (cloudConfiguration != null) { - if (empty (cloudConfiguration.getLcpCloudRegionId ())) { - throw new ValidationException ("lcpCloudRegionId"); - } - if (empty (cloudConfiguration.getTenantId ())) { - throw new ValidationException ("tenantId"); - } + if (empty (cloudConfiguration.getLcpCloudRegionId ())) { + throw new ValidationException ("lcpCloudRegionId"); + } + if (empty (cloudConfiguration.getTenantId ())) { + throw new ValidationException ("tenantId"); + } } - + + + if (requestScope.equalsIgnoreCase (ModelType.service.name ()) && action == Action.createInstance) { - if (sir.getRequestDetails ().getRequestParameters () == null) { - throw new ValidationException ("requestParameters"); - } - if (empty (sir.getRequestDetails ().getRequestParameters ().getSubscriptionServiceType ())) { - throw new ValidationException ("subscriptionServiceType"); - } - } - + if (requestParameters == null) { + throw new ValidationException ("requestParameters"); + } + if (empty (requestParameters.getSubscriptionServiceType ())) { + throw new ValidationException ("subscriptionServiceType"); + } + } + if(requestScope.equalsIgnoreCase(ModelType.service.name())){ - this.serviceInstanceType = modelInfo.getModelName(); + this.serviceInstanceType = modelInfo.getModelName(); } - + if(requestScope.equalsIgnoreCase(ModelType.network.name())){ - this.networkType = modelInfo.getModelName(); - } - - // Verify instanceName existence and format - if (empty (requestInfo.getInstanceName ()) && action == Action.createInstance) { - throw new ValidationException ("instanceName"); - } - - if (!empty (requestInfo.getInstanceName ()) && !requestInfo.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) { - throw new ValidationException ("instanceName format"); - } - + this.networkType = modelInfo.getModelName(); + } + + // Verify instanceName existence and format except for macro serviceInstance + if (this.reqVersion < 3 && requestScope.equalsIgnoreCase (ModelType.service.name ()) && empty (requestInfo.getInstanceName ()) && action == Action.createInstance) { + throw new ValidationException ("instanceName"); + } + + if (!empty (requestInfo.getInstanceName ())) { + if (!requestInfo.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) { + throw new ValidationException ("instanceName format"); + } + } + if (empty (requestInfo.getProductFamilyId ()) && ((requestScope.equalsIgnoreCase (ModelType.vnf.name ()) && action == Action.createInstance) || - (requestScope.equalsIgnoreCase (ModelType.network.name ()) && (action == Action.createInstance || action == Action.updateInstance)))) { - throw new ValidationException ("productFamilyId"); - } - + (requestScope.equalsIgnoreCase (ModelType.network.name ()) && (action == Action.createInstance || action == Action.updateInstance)))) { + throw new ValidationException ("productFamilyId"); + } + if (empty (requestInfo.getSource ())) { - throw new ValidationException ("source"); + throw new ValidationException ("source"); } - + RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); @@ -344,169 +395,202 @@ public class MsoRequest { String asdcServiceModelVersion = null; String volumeGroupId = null; boolean isRelatedServiceInstancePresent = false; - boolean isRelatedVnfInstancePresent = false; + boolean isRelatedVnfInstancePresent = false; if (instanceList != null) { - for(RelatedInstanceList relatedInstanceList : instanceList){ - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + for(RelatedInstanceList relatedInstanceList : instanceList){ + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + + if (relatedInstance.getModelInfo () == null) { + throw new ValidationException ("modelInfo in relatedInstance"); + } + + if (relatedInstance.getModelInfo ().getModelType () == null) { + throw new ValidationException ("modelType in relatedInstance"); + } + + + if (!empty (relatedInstance.getInstanceName ())) { + if (!relatedInstance.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) { + throw new ValidationException ("instanceName format in relatedInstance"); + } + } + + if (empty (relatedInstance.getInstanceId ())) { + throw new ValidationException ("instanceId in relatedInstance"); + } + + if (!UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) { + throw new ValidationException ("instanceId format in relatedInstance"); + } + + + if (action != Action.deleteInstance) { + + // ModelInvariantId is not required in volumeGroup relatedInstance + if(!(relatedInstance.getModelInfo ().getModelType ().equals(ModelType.volumeGroup)) && + empty (relatedInstance.getModelInfo ().getModelInvariantId ())) { + throw new ValidationException ("modelInvariantId in relatedInstance"); + } + + if (!empty (relatedInstance.getModelInfo ().getModelInvariantId ()) && + !UUIDChecker.isValidUUID (relatedInstance.getModelInfo ().getModelInvariantId ())) { + throw new ValidationException ("modelInvariantId format in relatedInstance"); + } + + if (empty(relatedInstance.getModelInfo ().getModelName ()) && + !(relatedInstance.getModelInfo ().getModelType ().equals (ModelType.volumeGroup))) { + throw new ValidationException ("modelName in relatedInstance"); + } + + if (empty (relatedInstance.getModelInfo ().getModelVersion ()) && + !(relatedInstance.getModelInfo ().getModelType ().equals (ModelType.volumeGroup))) { + throw new ValidationException ("modelVersion in relatedInstance"); + } + } + + if (empty (relatedInstance.getModelInfo ().getModelCustomizationName ()) && + relatedInstance.getModelInfo ().getModelType ().equals (ModelType.vnf)) { + throw new ValidationException ("modelCustomizationName in relatedInstance"); + } + + if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) { + isRelatedServiceInstancePresent = true; + if (!relatedInstance.getInstanceId ().equals (this.sir.getServiceInstanceId ())) { + throw new ValidationException ("serviceInstanceId matching the serviceInstanceId in request URI"); + } + serviceModelName = relatedInstance.getModelInfo ().getModelName (); + asdcServiceModelVersion = relatedInstance.getModelInfo().getModelVersion (); + } + else if(relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { + isRelatedVnfInstancePresent = true; + if (!relatedInstance.getInstanceId ().equals (this.sir.getVnfInstanceId ())) { + throw new ValidationException ("vnfInstanceId matching the vnfInstanceId in request URI"); + } + vnfModelName = relatedInstance.getModelInfo().getModelCustomizationName(); + } + else if(relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) { + volumeGroupId = relatedInstance.getInstanceId (); + } + } + + + if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) { + if (!isRelatedServiceInstancePresent) { + throw new ValidationException ("related service instance for volumeGroup request"); + } + if (!isRelatedVnfInstancePresent) { + throw new ValidationException ("related vnf instance for volumeGroup request"); + } + this.serviceInstanceType = serviceModelName; + this.vnfType = serviceModelName + "/" + vnfModelName; + this.asdcServiceModelVersion = asdcServiceModelVersion; + } + else if(requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) { + if (!isRelatedServiceInstancePresent) { + throw new ValidationException ("related service instance for vfModule request"); + } + if (!isRelatedVnfInstancePresent) { + throw new ValidationException ("related vnf instance for vfModule request"); + } + String vfModuleModelName = modelInfo.getModelName (); + this.vfModuleModelName = vfModuleModelName; + this.serviceInstanceType = serviceModelName; + this.vnfType = serviceModelName + "/" + vnfModelName; + this.asdcServiceModelVersion = asdcServiceModelVersion; + this.vfModuleType = vnfType + "::" + vfModuleModelName; + this.sir.setVolumeGroupInstanceId (volumeGroupId); + } + else if (requestScope.equalsIgnoreCase (ModelType.vnf.name ())) { + if (!isRelatedServiceInstancePresent) { + throw new ValidationException ("related service instance for vnf request"); + } + this.vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName(); + } + } + else if ((( requestScope.equalsIgnoreCase(ModelType.vnf.name ()) || requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ()) ) && (action == Action.createInstance)) || + (this.reqVersion > 2 && (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) && action == Action.updateInstance)){ + msoLogger.debug ("related instance exception"); + throw new ValidationException ("related instances"); + } - if (!empty (relatedInstance.getInstanceName ()) && !relatedInstance.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) { - throw new ValidationException ("instanceName format in relatedInstance"); - } + } - if (empty (relatedInstance.getInstanceId ())) { - throw new ValidationException ("instanceId in relatedInstance"); - } + void parseOrchestration (ServiceInstancesRequest sir) throws ValidationException { - if (!UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) { - throw new ValidationException ("instanceId format in relatedInstance"); - } + msoLogger.debug ("Validating the Orchestration request"); - if (relatedInstance.getModelInfo () == null) { - throw new ValidationException ("modelInfo in relatedInstance"); - } + this.sir = sir; - if (relatedInstance.getModelInfo ().getModelType () == null) { - throw new ValidationException ("modelType in relatedInstance"); - } + try{ + ObjectMapper mapper = new ObjectMapper(); + //mapper.configure(Feature.WRAP_ROOT_VALUE, true); + requestJSON = mapper.writeValueAsString(sir.getRequestDetails()); - if (action != Action.deleteInstance) { - - if (empty (relatedInstance.getModelInfo ().getModelInvariantId ()) && - !(requestScope.equalsIgnoreCase (ModelType.vfModule.name ()) && action == Action.createInstance && - relatedInstance.getModelInfo ().getModelType ().equals(ModelType.volumeGroup))) { - throw new ValidationException ("modelInvariantId in relatedInstance"); - } - - if (!empty (relatedInstance.getModelInfo ().getModelInvariantId ()) && - !UUIDChecker.isValidUUID (relatedInstance.getModelInfo ().getModelInvariantId ())) { - throw new ValidationException ("modelInvariantId format in relatedInstance"); - } - - if (empty(relatedInstance.getModelInfo ().getModelName ()) && - !(requestScope.equalsIgnoreCase (ModelType.vfModule.name ()) && action == Action.createInstance && - relatedInstance.getModelInfo ().getModelType ().equals (ModelType.volumeGroup))) { - throw new ValidationException ("modelName in relatedInstance"); - } - - if (empty (relatedInstance.getModelInfo ().getModelVersion ()) && - !(requestScope.equalsIgnoreCase (ModelType.vfModule.name ()) && action == Action.createInstance && - relatedInstance.getModelInfo ().getModelType ().equals (ModelType.volumeGroup))) { - throw new ValidationException ("modelVersion in relatedInstance"); - } - } + } catch(Exception e){ + throw new ValidationException ("Parse ServiceInstanceRequest to JSON string", e); + } - if (empty (relatedInstance.getModelInfo ().getModelCustomizationName ()) && - relatedInstance.getModelInfo ().getModelType ().equals (ModelType.vnf)) { - throw new ValidationException ("modelCustomizationName in relatedInstance"); - } + this.requestInfo = sir.getRequestDetails().getRequestInfo(); - if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) { - isRelatedServiceInstancePresent = true; - if (!relatedInstance.getInstanceId ().equals (this.sir.getServiceInstanceId ())) { - throw new ValidationException ("serviceInstanceId matching the serviceInstanceId in request URI"); - } - serviceModelName = relatedInstance.getModelInfo ().getModelName (); - asdcServiceModelVersion = relatedInstance.getModelInfo().getModelVersion (); - } - else if(relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { - isRelatedVnfInstancePresent = true; - if (!relatedInstance.getInstanceId ().equals (this.sir.getVnfInstanceId ())) { - throw new ValidationException ("vnfInstanceId matching the vnfInstanceId in request URI"); - } - vnfModelName = relatedInstance.getModelInfo().getModelCustomizationName(); - } - else if(relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) { - volumeGroupId = relatedInstance.getInstanceId (); - } - } - - - if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) { - if (!isRelatedServiceInstancePresent) { - throw new ValidationException ("related service instance for volumeGroup request"); - } - if (!isRelatedVnfInstancePresent) { - throw new ValidationException ("related vnf instance for volumeGroup request"); - } - this.serviceInstanceType = serviceModelName; - this.vnfType = serviceModelName + "/" + vnfModelName; - this.asdcServiceModelVersion = asdcServiceModelVersion; - } - else if(requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) { - if (!isRelatedServiceInstancePresent) { - throw new ValidationException ("related service instance for vfModule request"); - } - if (!isRelatedVnfInstancePresent) { - throw new ValidationException ("related vnf instance for vfModule request"); - } - String vfModuleModelName = modelInfo.getModelName (); - this.vfModuleModelName = vfModuleModelName; - this.serviceInstanceType = serviceModelName; - this.vnfType = serviceModelName + "/" + vnfModelName; - this.asdcServiceModelVersion = asdcServiceModelVersion; - this.vfModuleType = vnfType + "::" + vfModuleModelName; - this.sir.setVolumeGroupInstanceId (volumeGroupId); - } - else if (requestScope.equalsIgnoreCase (ModelType.vnf.name ())) { - if (!isRelatedServiceInstancePresent) { - throw new ValidationException ("related service instance for vnf request"); - } - this.vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName(); - } + if (this.requestInfo == null) { + throw new ValidationException ("requestInfo"); } - else if (action != Action.deleteInstance && !requestScope.equalsIgnoreCase(ModelType.service.name ()) && - !requestScope.equalsIgnoreCase(ModelType.network.name ())) { - throw new ValidationException ("related instances"); + + if (empty (requestInfo.getSource ())) { + throw new ValidationException ("source"); + } + if (empty (requestInfo.getRequestorId ())) { + throw new ValidationException ("requestorId"); } - } - + public Map<String, List<String>> getOrchestrationFilters (MultivaluedMap<String, String> queryParams) throws ValidationException { - String queryParam = null; + String queryParam = null; Map<String, List<String>> orchestrationFilterParams = new HashMap<String, List<String>>(); - - + + for (Entry<String,List<String>> entry : queryParams.entrySet()) { queryParam = entry.getKey(); - + try{ - if(queryParam.equalsIgnoreCase("filter")){ - - StringTokenizer st = new StringTokenizer(entry.getValue().get(0), ":"); - - int counter=0; - String mapKey=null; - List<String> orchestrationList = new ArrayList<String>(); - while (st.hasMoreElements()) { - if(counter == 0){ - mapKey = st.nextElement() + ""; - } else{ - orchestrationList.add(st.nextElement() + ""); - } - counter++; - } - orchestrationFilterParams.put(mapKey, orchestrationList); - } + if(queryParam.equalsIgnoreCase("filter")){ + + StringTokenizer st = new StringTokenizer(entry.getValue().get(0), ":"); + + int counter=0; + String mapKey=null; + List<String> orchestrationList = new ArrayList<String>(); + while (st.hasMoreElements()) { + if(counter == 0){ + mapKey = st.nextElement() + ""; + } else{ + orchestrationList.add(st.nextElement() + ""); + } + counter++; + } + orchestrationFilterParams.put(mapKey, orchestrationList); + } }catch(Exception e){ //msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, e); throw new ValidationException ("QueryParam ServiceInfo", e); - } - + } + } + return orchestrationFilterParams; - } + } public void createRequestRecord (Status status, Action action) { Session session = null; try { - session = HibernateUtil.getSessionFactory ().openSession (); + session = hibernateUtils.getSessionFactory ().openSession (); session.beginTransaction (); if (null == sir) { @@ -515,108 +599,106 @@ public class MsoRequest { InfraActiveRequests aq = new InfraActiveRequests (); aq.setRequestId (requestId); - + aq.setRequestAction(action.name()); aq.setAction(action.name()); - + Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - + aq.setStartTime (startTimeStamp); - - if (requestInfo != null) { - if(requestInfo.getSource() != null){ - aq.setSource(requestInfo.getSource()); - } - if(requestInfo.getCallbackUrl() != null){ - aq.setCallBackUrl(requestInfo.getCallbackUrl()); - } - if(requestInfo.getCorrelator() != null){ - aq.setCorrelator(requestInfo.getCorrelator()); - } - + if (requestInfo != null) { + + if(requestInfo.getSource() != null){ + aq.setSource(requestInfo.getSource()); + } + if(requestInfo.getCallbackUrl() != null){ + aq.setCallBackUrl(requestInfo.getCallbackUrl()); + } + if(requestInfo.getCorrelator() != null){ + aq.setCorrelator(requestInfo.getCorrelator()); + } + + if(requestInfo.getRequestorId() != null) { + aq.setRequestorId(requestInfo.getRequestorId()); + } } - - if (modelInfo != null) { - aq.setRequestScope(requestScope); + + if (modelInfo != null) { + aq.setRequestScope(requestScope); } - + if (cloudConfiguration != null) { - if(cloudConfiguration.getLcpCloudRegionId() != null) { - aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId()); - } + if(cloudConfiguration.getLcpCloudRegionId() != null) { + aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId()); + } - if(cloudConfiguration.getTenantId() != null) { - aq.setTenantId(cloudConfiguration.getTenantId()); - } + if(cloudConfiguration.getTenantId() != null) { + aq.setTenantId(cloudConfiguration.getTenantId()); + } } - + if(sir.getServiceInstanceId() != null){ - aq.setServiceInstanceId(sir.getServiceInstanceId()); + aq.setServiceInstanceId(sir.getServiceInstanceId()); } - + if(sir.getVnfInstanceId() != null){ - aq.setVnfId(sir.getVnfInstanceId()); + aq.setVnfId(sir.getVnfInstanceId()); } - if (null != requestScope) { - if (requestScope.equalsIgnoreCase(ModelType.service.name())) { - if (requestInfo.getInstanceName() != null) { - aq.setServiceInstanceName(requestInfo.getInstanceName()); - } - } - - if (requestScope.equalsIgnoreCase(ModelType.network.name())) { - aq.setNetworkName(requestInfo.getInstanceName()); - aq.setNetworkType(networkType); - aq.setNetworkId(sir.getNetworkInstanceId()); - } + if(ModelType.service.name().equalsIgnoreCase(requestScope)){ + if(requestInfo.getInstanceName() != null){ + aq.setServiceInstanceName(requestInfo.getInstanceName()); + } + } - if (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name())) { - aq.setVolumeGroupId(sir.getVolumeGroupInstanceId()); - aq.setVolumeGroupName(requestInfo.getInstanceName()); - aq.setVnfType(vnfType); + if(ModelType.network.name().equalsIgnoreCase(requestScope)){ + aq.setNetworkName(requestInfo.getInstanceName()); + aq.setNetworkType(networkType); + aq.setNetworkId(sir.getNetworkInstanceId()); + } - } + if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)){ + aq.setVolumeGroupId(sir.getVolumeGroupInstanceId()); + aq.setVolumeGroupName(requestInfo.getInstanceName()); + aq.setVnfType(vnfType); - if (requestScope.equalsIgnoreCase(ModelType.vfModule.name())) { - aq.setVfModuleName(requestInfo.getInstanceName()); - aq.setVfModuleModelName(modelInfo.getModelName()); - aq.setVfModuleId(sir.getVfModuleInstanceId()); - aq.setVolumeGroupId(sir.getVolumeGroupInstanceId()); - aq.setVnfType(vnfType); + } - } + if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)){ + aq.setVfModuleName(requestInfo.getInstanceName()); + aq.setVfModuleModelName(modelInfo.getModelName()); + aq.setVfModuleId(sir.getVfModuleInstanceId()); + aq.setVolumeGroupId(sir.getVolumeGroupInstanceId()); + aq.setVnfType(vnfType); - if (requestScope.equalsIgnoreCase(ModelType.vnf.name())) { - aq.setVnfName(requestInfo.getInstanceName()); - if (null != sir.getRequestDetails()) { - RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); + } - if (instanceList != null) { + if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){ + aq.setVnfName(requestInfo.getInstanceName()); + if (null != sir.getRequestDetails()) { + RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); - for (RelatedInstanceList relatedInstanceList : instanceList) { + if (instanceList != null) { - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) { - aq.setVnfType(vnfType); - } - } - } - } - //aq.setVnfType(sir.getRequestDetails().getRelatedInstanceList()); + for(RelatedInstanceList relatedInstanceList : instanceList){ - } + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){ + aq.setVnfType(vnfType); + } + } + } + } } aq.setRequestBody (this.requestJSON); - - + aq.setRequestStatus (status.toString ()); aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); - + if ((status == Status.FAILED) || (status == Status.COMPLETE)) { aq.setStatusMessage (this.errorMessage); aq.setResponseBody (this.responseBody); @@ -625,14 +707,14 @@ public class MsoRequest { Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); aq.setEndTime (endTimeStamp); } - + msoLogger.debug ("About to insert a record"); session.save (aq); session.getTransaction ().commit (); session.close (); } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e); + msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e); if (session != null) { session.close (); } @@ -652,7 +734,7 @@ public class MsoRequest { this.responseBody, Constants.MODIFIED_BY_APIHANDLER); } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB"); + msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB"); msoLogger.debug ("Exception: ", e); } } @@ -666,8 +748,8 @@ public class MsoRequest { InfraActiveRequests inProgress, String errorString) { - - + + // Log the failed request into the MSO Requests database return Response.status (httpResponseCode).entity (null).build (); @@ -676,7 +758,7 @@ public class MsoRequest { public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) { - + return Response.status (httpResponseCode).entity (null).build (); } @@ -728,13 +810,13 @@ public class MsoRequest { public RequestStatusType getStatus () { return status; } - + public String getServiceType () { - if (this.vnfInputs.getServiceType () != null) - return this.vnfInputs.getServiceType (); - if (this.vnfInputs.getServiceId () != null) - return this.vnfInputs.getServiceId (); - return null; + if (this.vnfInputs.getServiceType () != null) + return this.vnfInputs.getServiceType (); + if (this.vnfInputs.getServiceId () != null) + return this.vnfInputs.getServiceId (); + return null; } public void setStatus (RequestStatusType status) { @@ -742,46 +824,46 @@ public class MsoRequest { switch (status) { case FAILED: case COMPLETE: - this.progress = Constants.PROGRESS_REQUEST_COMPLETED; - break; + this.progress = Constants.PROGRESS_REQUEST_COMPLETED; + break; case IN_PROGRESS: - this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; - break; + this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; + break; } } - + public ModelInfo getModelInfo() { - return modelInfo; + return modelInfo; } - + public ServiceInstancesRequest getServiceInstancesRequest() { - return sir; + return sir; } - + public String getServiceInstanceType () { - return serviceInstanceType; - } - + return serviceInstanceType; + } + public String getNetworkType () { - return networkType; + return networkType; } - + public String getVnfType () { - return vnfType; + return vnfType; } - + public String getVfModuleModelName () { - return vfModuleModelName; + return vfModuleModelName; } - + public String getVfModuleType () { - return vfModuleType; + return vfModuleType; } - + public String getAsdcServiceModelVersion () { - return asdcServiceModelVersion; + return asdcServiceModelVersion; } - + public static String domToStr (Document doc) { if (doc == null) { return null; @@ -816,16 +898,16 @@ public class MsoRequest { } return null; } - + public void addBPMNSpecificInputs(String personaModelId, String personaModelVersion, Boolean isBaseVfModule, - String vnfPersonaModelId, String vnfPersonaModelVersion) { - vnfInputs.setPersonaModelId(personaModelId); - vnfInputs.setPersonaModelVersion(personaModelVersion); - vnfInputs.setIsBaseVfModule(isBaseVfModule); - vnfInputs.setVnfPersonaModelId(vnfPersonaModelId); - vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion); + String vnfPersonaModelId, String vnfPersonaModelVersion) { + vnfInputs.setPersonaModelId(personaModelId); + vnfInputs.setPersonaModelVersion(personaModelVersion); + vnfInputs.setIsBaseVfModule(isBaseVfModule); + vnfInputs.setVnfPersonaModelId(vnfPersonaModelId); + vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion); - this.vnfReq.setVnfInputs(vnfInputs); + this.vnfReq.setVnfInputs(vnfInputs); StringWriter stringWriter = new StringWriter (); try { @@ -846,8 +928,33 @@ public class MsoRequest { } - + private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); + } + + public String getRequestJSON() throws JsonGenerationException, JsonMappingException, IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Inclusion.NON_NULL); + //mapper.configure(Feature.WRAP_ROOT_VALUE, true); + msoLogger.debug ("building sir from object " + sir); + requestJSON = mapper.writeValueAsString(sir); + return requestJSON; } -} + + public boolean getALaCarteFlag() { + return aLaCarteFlag; + } + + public void setaLaCarteFlag(boolean aLaCarteFlag) { + this.aLaCarteFlag = aLaCarteFlag; + } + + public int getReqVersion() { + return reqVersion; + } + + public void setReqVersion(int reqVersion) { + this.reqVersion = reqVersion; + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java index 61f4b9f..c25f5ce 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java @@ -56,9 +56,10 @@ import org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.requestsdb.HibernateUtil; +import org.openecomp.mso.db.HibernateUtils; import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb; public class NetworkMsoInfraRequest { @@ -79,6 +80,8 @@ public class NetworkMsoInfraRequest { private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); private static final String NOT_PROVIDED = "not provided"; + protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb (); + NetworkMsoInfraRequest (String requestId) { this.requestId = requestId; this.startTime = System.currentTimeMillis(); @@ -239,8 +242,8 @@ public class NetworkMsoInfraRequest { msoLogger.debug ("Exception: ", e); } - this.requestXML = stringWriter.toString ().replace ("http://ecomp.att.com/mso/infra/network-request", - "http://ecomp.att.com/mso/infra/vnf-request"); + this.requestXML = stringWriter.toString ().replace ("http://org.openecomp/mso/infra/network-request", + "http://org.openecomp/mso/infra/vnf-request"); msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); } @@ -252,7 +255,7 @@ public class NetworkMsoInfraRequest { Session session = null; try { - session = HibernateUtil.getSessionFactory ().openSession (); + session = hibernateUtils.getSessionFactory ().openSession (); session.beginTransaction (); InfraActiveRequests aq = new InfraActiveRequests (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java index f89cae9..3bdb745 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java index 00104da..f42ba97 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,10 +24,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; @@ -38,20 +35,14 @@ import org.apache.http.HttpStatus; import org.codehaus.jackson.map.ObjectMapper; import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationListResponse; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationResponse; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.InstanceReferences; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.Request; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestDetails; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestList; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestStatus; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.*; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoAlarmLogger; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.RequestsDatabase; -@Path("/orchestrationRequests/v2") +@Path("/") public class OrchestrationRequests { public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; @@ -61,28 +52,28 @@ public class OrchestrationRequests { private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); /** - * + * */ public OrchestrationRequests() { // TODO Auto-generated constructor stub } @GET - @Path("/{requestId}") + @Path("/orchestrationRequests/{version:[vV][2-3]}/{requestId}") @Produces(MediaType.APPLICATION_JSON) public Response getOrchestrationRequest(@PathParam("requestId") String requestId) { - + GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); - + MsoRequest msoRequest = new MsoRequest (requestId); - + long startTime = System.currentTimeMillis (); - + InfraActiveRequests requestDB = null; - + try { requestDB = RequestsDatabase.getRequestFromInfraActive(requestId); - + } catch (Exception e) { msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e); msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); @@ -97,57 +88,57 @@ public class OrchestrationRequests { msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB"); msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return response; - + } - + if(requestDB == null) { Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NO_CONTENT, MsoException.ServiceException, - "Orchestration RequestId " + requestId + " is not found in DB", + "Orchestration RequestId " + requestId + " is not found in DB", ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null); msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId"); msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId"); msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); return resp; - + } - + Request request = mapInfraActiveRequestToRequest(requestDB); - + orchestrationResponse.setRequest(request); - + return Response.status(200).entity(orchestrationResponse).build(); } - + @GET - @Path("/") + @Path("/orchestrationRequests/{version:[vV][2-3]}") @Produces(MediaType.APPLICATION_JSON) public Response getOrchestrationRequest(@Context UriInfo ui) { - + long startTime = System.currentTimeMillis (); - + MsoRequest msoRequest = new MsoRequest(); - + MultivaluedMap<String, String> queryParams = ui.getQueryParameters(); - + List<InfraActiveRequests> activeRequests = null; - + GetOrchestrationListResponse orchestrationList = null; - - + + try{ - + Map<String, List<String>> orchestrationMap = msoRequest.getOrchestrationFilters(queryParams); - + activeRequests = RequestsDatabase.getOrchestrationFiltersFromInfraActive(orchestrationMap); - + orchestrationList = new GetOrchestrationListResponse(); List<RequestList> requestLists = new ArrayList<RequestList>(); - + for(InfraActiveRequests infraActive : activeRequests){ - + Request request = mapInfraActiveRequestToRequest(infraActive); RequestList requestList = new RequestList(); requestList.setRequest(request); @@ -155,36 +146,148 @@ public class OrchestrationRequests { requestLists.add(requestList); } - + orchestrationList.setRequestList(requestLists); }catch(Exception e){ msoLogger.debug ("Get Orchestration Request with Filters Failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException, - "Get Orchestration Request with Filters Failed. " + e.getMessage(), + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException, + "Get Orchestration Request with Filters Failed. " + e.getMessage(), ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null); msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Get Orchestration Request with Filters Failed : " + e); msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Get Orchestration Request with Filters Failed"); msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return response; } - - + + return Response.status(200).entity(orchestrationList).build(); } + + @POST + @Path("/orchestrationRequests/v3/{requestId}/unlock") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId) { + + MsoRequest msoRequest = new MsoRequest (requestId); + + long startTime = System.currentTimeMillis (); + msoLogger.debug ("requestId is: " + requestId); + + InfraActiveRequests requestDB = null; + Request request = null; + + msoLogger.debug ("requestId is: " + requestId); + ServiceInstancesRequest sir = null; + + try{ + ObjectMapper mapper = new ObjectMapper(); + sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + + } catch(Exception e){ + msoLogger.debug ("Mapping of request to JSON object failed : ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, + "Mapping of request to JSON object failed. " + e.getMessage(), + ErrorNumbers.SVC_BAD_PARAMETER, null); + if (msoRequest.getRequestId () != null) { + msoLogger.debug ("Mapping of request to JSON object failed"); + } + msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + + try{ + msoRequest.parseOrchestration(sir); + } catch (Exception e) { + msoLogger.debug ("Validation failed: ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, + "Error parsing request. " + e.getMessage(), + ErrorNumbers.SVC_BAD_PARAMETER, null); + if (msoRequest.getRequestId () != null) { + msoLogger.debug ("Logging failed message to the database"); + } + msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + try { + requestDB = RequestsDatabase.getRequestFromInfraActive(requestId); + + if(requestDB == null) { + Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, + "Orchestration RequestId " + requestId + " is not found in DB", + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, + null); + msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); + return resp; + + }else{ + request = mapInfraActiveRequestToRequest(requestDB); + RequestStatus reqStatus = request.getRequestStatus(); + Status status = Status.valueOf(reqStatus.getRequestState()); + if(status == Status.IN_PROGRESS || status == Status.PENDING){ + msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.UNLOCKED); + reqStatus.setRequestState(Status.UNLOCKED.toString ()); + RequestsDatabase.updateInfraStatus (requestId, + Status.UNLOCKED.toString (), + Constants.MODIFIED_BY_APIHANDLER); + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "RequestId " + requestId + " has been unlocked"); + + }else{ + Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_REQUEST, + MsoException.ServiceException, + "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked", + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, + null); + msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); + return resp; + } + } + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e); + msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); + Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, + e.getMessage (), + ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, + null); + alarmLogger.sendAlarm ("MsoDatabaseAccessError", + MsoAlarmLogger.CRITICAL, + Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + + } + + return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); + } + private Request mapInfraActiveRequestToRequest(InfraActiveRequests requestDB) { - - + + Request request = new Request(); - + ObjectMapper mapper = new ObjectMapper(); // mapper.configure(Feature.WRAP_ROOT_VALUE, true); - + request.setRequestId(requestDB.getRequestId()); request.setRequestScope(requestDB.getRequestScope()); request.setRequestType(requestDB.getRequestAction()); - + InstanceReferences ir = new InstanceReferences(); if(requestDB.getNetworkId() != null) ir.setNetworkInstanceId(requestDB.getNetworkId()); @@ -206,46 +309,48 @@ public class OrchestrationRequests { ir.setVolumeGroupInstanceId(requestDB.getVolumeGroupId()); if(requestDB.getVolumeGroupName() != null) ir.setVolumeGroupInstanceName(requestDB.getVolumeGroupName()); + if(requestDB.getRequestorId() != null) + ir.setRequestorId(requestDB.getRequestorId()); + + + request.setInstanceReferences(ir); - - request.setInstanceReferences(ir); - String requestBody = requestDB.getRequestBody(); - + RequestDetails requestDetails = null; - + try{ requestDetails = mapper.readValue(requestBody, RequestDetails.class); - + }catch(Exception e){ msoLogger.debug("Exception caught mapping requestBody to RequestDetails"); } - + request.setRequestDetails(requestDetails); String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getStartTime()) + " GMT"; request.setStartTime(startTimeStamp); - + RequestStatus status = new RequestStatus(); if(requestDB.getStatusMessage() != null){ status.setStatusMessage(requestDB.getStatusMessage()); } - + if(requestDB.getEndTime() != null){ String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getEndTime()) + " GMT"; status.setFinishTime(endTimeStamp); } - + if(requestDB.getRequestStatus() != null){ status.setRequestState(requestDB.getRequestStatus()); } - + if(requestDB.getProgress() != null){ status.setPercentProgress(requestDB.getProgress().intValue()); } - + request.setRequestStatus(status); - + return request; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestHandler.java deleted file mode 100644 index bfea00f..0000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestHandler.java +++ /dev/null @@ -1,2102 +0,0 @@ -package org.openecomp.mso.apihandlerinfra; - -/*- - * #%L - * MSO - * %% - * Copyright (C) 2016 OPENECOMP - MSO - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - - -import java.text.SimpleDateFormat; -import java.util.*; - -import javax.servlet.ServletContext; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import org.openecomp.mso.HealthCheckUtils; - -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig.Feature; - -import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.apihandler.common.ResponseHandler; -import org.openecomp.mso.apihandler.common.ValidationException; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationListResponse; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationResponse; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.InstanceReferences; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RelatedInstance; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RelatedInstanceList; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.Request; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestDetails; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestError; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestList; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestStatus; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestReferences; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesResponse; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.Recipe; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceRecipe; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VnfComponentsRecipe; -import org.openecomp.mso.db.catalog.beans.VnfRecipe; -import org.openecomp.mso.db.catalog.beans.VnfResource; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoAlarmLogger; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesFactory; -import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.RequestsDatabase; -import org.openecomp.mso.utils.UUIDChecker; - -@Path("/") -public class RequestHandler { - - public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; - - private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory (); - - @Context - private UriInfo uriInfo; - - private static final String NOT_FOUND = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Application Not Started</title></head><body>Application not started, properties file missing or invalid or Database Connection failed</body></html>"; - - private static final Response NOT_STARTED_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE) - .entity (NOT_FOUND) - .build (); - - private static boolean noProperties = true; - - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); - - @Context - private ServletContext sc; - - private static MsoJavaProperties props = loadMsoProperties (); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); - - @HEAD - @GET - @Path("/healthcheck") - @Produces("text/html") - public Response healthcheck (@QueryParam("requestId") String requestId) { - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("Healthcheck"); - UUIDChecker.verifyOldUUID(requestId, msoLogger); - HealthCheckUtils healthCheck = new HealthCheckUtils (); - if (!healthCheck.siteStatusCheck(msoLogger, startTime)) { - return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; - } - - if (!healthCheck.configFileCheck(msoLogger, startTime, MSO_PROP_APIHANDLER_INFRA)) { - return HealthCheckUtils.NOT_STARTED_RESPONSE; - } - - if (!healthCheck.requestDBCheck (msoLogger, startTime)) { - return HealthCheckUtils.NOT_STARTED_RESPONSE; - } - msoLogger.debug("healthcheck - Successful"); - return HealthCheckUtils.HEALTH_CHECK_RESPONSE; - } - - @HEAD - @GET - @Path("/globalhealthcheck") - @Produces("text/html") - public Response globalHealthcheck (@DefaultValue("true") @QueryParam("enableBpmn") boolean enableBpmn) { - long startTime = System.currentTimeMillis (); - MsoLogger.setServiceName ("GlobalHealthcheck"); - // Generate a Request Id - String requestId = UUIDChecker.generateUUID(msoLogger); - HealthCheckUtils healthCheck = new HealthCheckUtils (); - if (!healthCheck.siteStatusCheck (msoLogger, startTime)) { - return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; - } - - if (healthCheck.verifyGlobalHealthCheck(enableBpmn, requestId)) { - msoLogger.debug("globalHealthcheck - Successful"); - return HealthCheckUtils.HEALTH_CHECK_RESPONSE; - } else { - msoLogger.debug("globalHealthcheck - At leaset one of the sub-modules is not available"); - return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; - } - } - - private static MsoJavaProperties loadMsoProperties () { - MsoJavaProperties msoProperties; - try { - msoProperties = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_APIHANDLER_INFRA); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_LOAD_PROPERTIES_FAIL, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Exception when loading MSO Properties", e); - return null; - } - - if (msoProperties != null && msoProperties.size () > 0) { - noProperties = false; - msoLogger.info (MessageEnum.APIH_PROPERTY_LOAD_SUC, "", ""); - return msoProperties; - } else { - msoLogger.error (MessageEnum.APIH_NO_PROPERTIES, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "No MSO APIH_INFRA Properties found"); - return null; - } - } - - @POST - @Path("/serviceInstances/v2") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response createServiceInstance(String request) { - - Response response = serviceInstances(request, Action.createInstance, null); - - return response; - } - - @DELETE - @Path("/serviceInstances/v2/{serviceInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response deleteServiceInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId) { - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); - return response; - } - - @POST - @Path("/serviceInstances/v2/{serviceInstanceId}/vnfs") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response createVnfInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId) { - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - Response response = serviceInstances(request, Action.createInstance, instanceIdMap); - - return response; - } - - @DELETE - @Path("/serviceInstances/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response deleteVnfInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId) { - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); - - return response; - } - - @POST - @Path("/serviceInstances/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response createVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId) { - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - Response response = serviceInstances(request, Action.createInstance, instanceIdMap); - - return response; - } - - @PUT - @Path("/serviceInstances/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response updateVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) { - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); - Response response = serviceInstances(request, Action.updateInstance, instanceIdMap); - - return response; - } - - @DELETE - @Path("/serviceInstances/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response deleteVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) { - - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); - - return response; - } - - - @POST - @Path("/serviceInstances/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response createVolumeGroupInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId) { - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - Response response = serviceInstances(request, Action.createInstance, instanceIdMap); - - return response; - } - - @PUT - @Path("/serviceInstances/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response updateVolumeGroupInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) { - - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId); - Response response = serviceInstances(request, Action.updateInstance, instanceIdMap); - - return response; - } - - @DELETE - @Path("/serviceInstances/v2/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response deleteVolumeGroupInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) { - - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); - - return response; - } - - @POST - @Path("/serviceInstances/v2/{serviceInstanceId}/networks") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response createNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId) { - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - Response response = serviceInstances(request, Action.createInstance, instanceIdMap); - - return response; - } - - @PUT - @Path("/serviceInstances/v2/{serviceInstanceId}/networks/{networkInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response updateNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("networkInstanceId") String networkInstanceId) { - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("networkInstanceId", networkInstanceId); - Response response = serviceInstances(request, Action.updateInstance, instanceIdMap); - - return response; - } - - @DELETE - @Path("/serviceInstances/v2/{serviceInstanceId}/networks/{networkInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response deleteNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("networkInstanceId") String networkInstanceId) { - - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("networkInstanceId", networkInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); - - return response; - } - - - - private Response serviceInstances(String requestJSON, Action action, HashMap<String,String> instanceIdMap) { - - String requestId = UUIDChecker.generateUUID(msoLogger); - long startTime = System.currentTimeMillis (); - msoLogger.debug ("requestId is: " + requestId); - ServiceInstancesRequest sir = null; - - MsoRequest msoRequest = new MsoRequest (requestId); - - - try{ - ObjectMapper mapper = new ObjectMapper(); - sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); - - } catch(Exception e){ - msoLogger.debug ("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, - "Mapping of request to JSON object failed. " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, null); - if (msoRequest.getRequestId () != null) { - msoLogger.debug ("Mapping of request to JSON object failed"); - msoRequest.createRequestRecord (Status.FAILED, action); - } - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - - try{ - msoRequest.parse(sir, instanceIdMap, action); - } catch (Exception e) { - msoLogger.debug ("Validation failed: ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, - "Error parsing request. " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, null); - if (msoRequest.getRequestId () != null) { - msoLogger.debug ("Logging failed message to the database"); - msoRequest.createRequestRecord (Status.FAILED, action); - } - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - InfraActiveRequests dup = null; - String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName(); - String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name(); - try { - dup = RequestsDatabase.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e); - - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException, - e.getMessage(), - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, - null) ; - - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Error during duplicate check"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - String instance = null; - if(instanceName != null){ - instance = instanceName; - }else{ - instance = instanceIdMap.get(requestScope + "InstanceId"); - } - String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") " + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - " + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding."; - //List<String> variables = new ArrayList<String>(); - //variables.add(dup.getRequestStatus()); - - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException, - dupMessage, - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, - null) ; - - - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError, "Duplicate request - Subscriber already has a request for this service"); - msoRequest.createRequestRecord (Status.FAILED, action); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - - ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); - - RequestReferences referencesResponse = new RequestReferences(); - - referencesResponse.setRequestId(requestId); - - serviceResponse.setRequestReferences(referencesResponse); - - try (CatalogDatabase db = new CatalogDatabase()) { - - RecipeLookupResult recipeLookupResult = null; - try { - recipeLookupResult = getServiceInstanceOrchestrationURI (db, msoRequest, action); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Exception while querying Catalog DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, - "Recipe could not be retrieved from catalog DB " + e.getMessage (), - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, - null); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.ERROR_FROM_CATALOG_DB)); - msoRequest.createRequestRecord (Status.FAILED,action); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while querying Catalog DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - db.close(); - return response; - } - - if (recipeLookupResult == null) { - msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "No recipe found in DB"); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, - "Recipe does not exist in catalog DB", - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, - null); - msoRequest.createRequestRecord (Status.FAILED, action); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No recipe found in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - db.close(); - return response; - } - - - Boolean isBaseVfModule = false; - - if (msoRequest.getModelInfo().getModelType().equals(ModelType.vfModule)) { - String asdcServiceModelVersion = msoRequest.getAsdcServiceModelVersion (); - - // Get VF Module-specific base module indicator - VfModule vfm = null; - - if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) { - vfm = db.getVfModuleType (msoRequest.getVfModuleType (), asdcServiceModelVersion); - } - else { - vfm = db.getVfModuleType (msoRequest.getVfModuleType ()); - } - - if (vfm != null) { - if (vfm.getIsBase() == 1) { - isBaseVfModule = true; - } - } - else if (action == Action.createInstance || action == Action.updateInstance){ - // There is no entry for this vfModuleType with this version, if specified, in VF_MODULE table in Catalog DB. - // This request cannot proceed - msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "VF Module Type", "", MsoLogger.ErrorCode.DataError, "No VfModuleType found in DB"); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - String serviceVersionText = ""; - if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) { - serviceVersionText = " with version " + asdcServiceModelVersion; - } - Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, - "VnfType " + msoRequest.getVnfType () + " and VF Module Model Name " + msoRequest.getVfModuleModelName() + serviceVersionText + " not found in MSO Catalog DB", - ErrorNumbers.SVC_BAD_PARAMETER, - null); - msoRequest.createRequestRecord (Status.FAILED, action); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No matching vfModuleType found in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - db.close(); - return response; - } - } - - db.close(); - - String serviceInstanceId = ""; - String vnfId = ""; - String vfModuleId = ""; - String volumeGroupId = ""; - String networkId = ""; - ServiceInstancesRequest siReq = msoRequest.getServiceInstancesRequest(); - - if(siReq.getServiceInstanceId () != null){ - serviceInstanceId = siReq.getServiceInstanceId (); - } - - if(siReq.getVnfInstanceId () != null){ - vnfId = siReq.getVnfInstanceId (); - } - - if(siReq.getVfModuleInstanceId () != null){ - vfModuleId = siReq.getVfModuleInstanceId (); - } - - if(siReq.getVolumeGroupInstanceId () != null){ - volumeGroupId = siReq.getVolumeGroupInstanceId (); - } - - if(siReq.getNetworkInstanceId () != null){ - networkId = siReq.getNetworkInstanceId (); - } - - - requestId = msoRequest.getRequestId (); - msoLogger.debug ("requestId is: " + requestId); - msoLogger.debug ("About to insert a record"); - - try { - msoRequest.createRequestRecord (Status.PENDING, action); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR, - MsoException.ServiceException, - "Exception while creating record in DB " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, - null); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - RequestClient requestClient = null; - HttpResponse response = null; - long subStartTime = System.currentTimeMillis(); - try { - requestClient = RequestClientFactory.getRequestClient (recipeLookupResult.getOrchestrationURI (), props); - // Capture audit event - msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - - System.out.println("URL : " + requestClient.getUrl ()); - - response = requestClient.post(requestId, isBaseVfModule, recipeLookupResult.getRecipeTimeout (), action.name (), - serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, - msoRequest.getServiceInstanceType (), - msoRequest.getVnfType (), msoRequest.getVfModuleType (), - msoRequest.getNetworkType (), requestJSON); - - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI (), null); - } catch (Exception e) { - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI (), null); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY, - MsoException.ServiceException, - "Failed calling bpmn " + e.getMessage (), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, - null); - alarmLogger.sendAlarm ("MsoConfigurationError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - if (response == null) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY, - MsoException.ServiceException, - "bpelResponse is null", - ErrorNumbers.SVC_NO_SERVER_RESOURCES, - null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - - // BPEL accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String camundaJSONResponseBody = respHandler.getResponseBody (); - msoLogger.debug ("Received from Camunda: " + camundaJSONResponseBody); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.IN_PROGRESS); - RequestsDatabase.updateInfraStatus (msoRequest.getRequestId (), - Status.IN_PROGRESS.toString (), - Constants.PROGRESS_REQUEST_IN_PROGRESS, - Constants.MODIFIED_BY_APIHANDLER); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) camundaJSONResponseBody); - return Response.status (HttpStatus.SC_ACCEPTED).entity (camundaJSONResponseBody).build (); - } else { - List<String> variables = new ArrayList<String>(); - variables.add(bpelStatus + ""); - String camundaJSONResponseBody = respHandler.getResponseBody (); - if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, - MsoException.ServiceException, - "Request Failed due to BPEL error with HTTP Status= %1 " + '\n' + camundaJSONResponseBody, - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, - variables); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, - MsoException.ServiceException, - "Request Failed due to BPEL error with HTTP Status= %1" , - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, - variables); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - } - - //return Response.status (HttpStatus.SC_ACCEPTED).entity (serviceResponse).build (); - // return serviceResponse; - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, - "No communication to catalog DB " + e.getMessage (), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, - null); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - msoRequest.createRequestRecord (Status.FAILED,action); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - @GET - @Path("/orchestrationRequests/v2/{requestId}") - @Produces(MediaType.APPLICATION_JSON) - public Response getOrchestrationRequest(@PathParam("requestId") String requestId) { - - GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); - - MsoRequest msoRequest = new MsoRequest (requestId); - - long startTime = System.currentTimeMillis (); - - InfraActiveRequests requestDB = null; - - try { - requestDB = RequestsDatabase.getRequestFromInfraActive(requestId); - - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, - e.getMessage (), - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - - } - - if(requestDB == null) { - Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NO_CONTENT, - MsoException.ServiceException, - "Orchestration RequestId " + requestId + " is not found in DB", - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, - null); - msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - - } - - Request request = mapInfraActiveRequestToRequest(requestDB); - - orchestrationResponse.setRequest(request); - - return Response.status(200).entity(orchestrationResponse).build(); - } - - @GET - @Path("/orchestrationRequests/v2") - @Produces(MediaType.APPLICATION_JSON) - public Response getOrchestrationRequest(@Context UriInfo ui) { - - long startTime = System.currentTimeMillis (); - - MsoRequest msoRequest = new MsoRequest(); - - MultivaluedMap<String, String> queryParams = ui.getQueryParameters(); - - List<InfraActiveRequests> activeRequests = null; - - GetOrchestrationListResponse orchestrationList = null; - - - try{ - - Map<String, List<String>> orchestrationMap = msoRequest.getOrchestrationFilters(queryParams); - - activeRequests = RequestsDatabase.getOrchestrationFiltersFromInfraActive(orchestrationMap); - - orchestrationList = new GetOrchestrationListResponse(); - - List<RequestList> requestLists = new ArrayList<RequestList>(); - - for(InfraActiveRequests infraActive : activeRequests){ - - Request request = mapInfraActiveRequestToRequest(infraActive); - RequestList requestList = new RequestList(); - requestList.setRequest(request); - - requestLists.add(requestList); - - } - - orchestrationList.setRequestList(requestLists); - - }catch(Exception e){ - msoLogger.debug ("Get Orchestration Request with Filters Failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException, - "Get Orchestration Request with Filters Failed. " + e.getMessage(), - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null); - msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Get Orchestration Request with Filters Failed : " + e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Get Orchestration Request with Filters Failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - - return Response.status(200).entity(orchestrationList).build(); - } - - @POST - @Path("/v3/vnf-request") - @Consumes("*/*") - @Produces("application/xml") - public Response manageVnfRequestV3 (String reqXML) { - // Set logger parameters - MsoLogger.setServiceName ("VnfRequest"); - return manageVnfRequestImpl (reqXML, Constants.SCHEMA_VERSION_V3); - } - - - @POST - @Path("/v2/vnf-request") - @Consumes("*/*") - @Produces("application/xml") - public Response manageVnfRequestV2 (String reqXML) { - // Set logger parameters - MsoLogger.setServiceName ("VnfRequest"); - return manageVnfRequestImpl (reqXML, Constants.SCHEMA_VERSION_V2); - } - - @POST - @Path("/v1/vnf-request") - @Consumes("*/*") - @Produces("application/xml") - public Response manageVnfRequestV1 (String reqXML) { - - // Set logger parameters - MsoLogger.setServiceName ("VnfRequest"); - - return manageVnfRequestImpl (reqXML, Constants.SCHEMA_VERSION_V1); - } - - @POST - @Path("/v3/network-request") - @Consumes("*/*") - @Produces("application/xml") - public Response manageNetworkRequestV3 (String reqXML) { - - // Set logger parameters - MsoLogger.setServiceName ("NetworkRequest"); - - return manageNetworkRequestImpl (reqXML, Constants.SCHEMA_VERSION_V3); - } - - @POST - @Path("/v2/network-request") - @Consumes("*/*") - @Produces("application/xml") - public Response manageNetworkRequestV2 (String reqXML) { - - // Set logger parameters - MsoLogger.setServiceName ("NetworkRequest"); - - return manageNetworkRequestImpl (reqXML, Constants.SCHEMA_VERSION_V2); - } - - @POST - @Path("/v1/network-request") - @Consumes("*/*") - @Produces("application/xml") - public Response manageNetworkRequestV1 (String reqXML) { - - // Set logger parameters - MsoLogger.setServiceName ("NetworkRequest"); - - return manageNetworkRequestImpl (reqXML, Constants.SCHEMA_VERSION_V1); - } - - @POST - @Path("/v3/volume-request") - @Consumes("*/*") - @Produces("application/xml") - public Response manageVolumeRequestV3 (String reqXML) { - // Set logger parameters - MsoLogger.setServiceName ("VolumeRequest"); - return manageVolumeRequestImpl (reqXML, Constants.SCHEMA_VERSION_V3); - } - - @POST - @Path("/v2/volume-request") - @Consumes("*/*") - @Produces("application/xml") - public Response manageVolumeRequestV2 (String reqXML) { - // Set logger parameters - MsoLogger.setServiceName ("VolumeRequest"); - return manageVolumeRequestImpl (reqXML, Constants.SCHEMA_VERSION_V2); - } - - @POST - @Path("/v1/volume-request") - @Consumes("*/*") - @Produces("application/xml") - public Response manageVolumeRequestV1 (String reqXML) { - - // Set logger parameters - MsoLogger.setServiceName ("VolumeRequest"); - - return manageVolumeRequestImpl (reqXML, Constants.SCHEMA_VERSION_V1); - } - - - private Response manageVnfRequestImpl (String reqXML, String version) { - String methodName = "VnfRequest"; - props = loadMsoProperties (); - long startTime = System.currentTimeMillis (); - - // Generate unique request id for the new request - UUID requestUUID = UUID.randomUUID (); - - VnfMsoInfraRequest msoRequest = new VnfMsoInfraRequest (requestUUID.toString ()); - MsoLogger.setLogContext (msoRequest.getRequestId (), null); - - if (noProperties) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, "Exiting the transaction: Infra API Handler not started, properties file missing or invalid"); - return NOT_STARTED_RESPONSE; - } - - uriInfo.getRequestUri (); - - if (reqXML == null) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "The content of the request is null"); - return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); - } - - String requestUri = uriInfo.getRequestUri ().toString (); - msoLogger.debug ("Incoming request received for pose VNFRequest:" + reqXML); - - msoRequest.setRequestUri (requestUri); - msoLogger.debug ("Schema version: " + version); - try { - msoRequest.parse (reqXML, version, props); - } catch (Exception e) { - msoLogger.debug ("Validation failed: ", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseFailedValidation (HttpStatus.SC_BAD_REQUEST, e.getMessage ()); - if (msoRequest.getRequestId () != null) { - msoLogger.debug ("Logging failed message to the database"); - msoRequest.createRequestRecord (Status.FAILED); - } - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, reqXML, "", "", MsoLogger.ErrorCode.SchemaError, "Exception when parsing reqXML", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - MsoLogger.setServiceName (MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo().getAction().name()); - msoLogger.debug ("Update serviceName with detailed action info to:" + MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo().getAction().name()); - if (msoRequest.getRequestInfo ().getAction () == org.openecomp.mso.apihandlerinfra.vnfbeans.ActionType.CREATE) { - // Check if this request is a duplicate of the one with the same vnfName - msoLogger.debug ("Checking for a duplicate with the same vnf-name"); - InfraActiveRequests dup = null; - try { - dup = RequestsDatabase.checkDuplicateByVnfName (msoRequest.getVnfInputs ().getVnfName (), - msoRequest.getRequestInfo ().getAction ().value (), - "VNF"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "vnf-name", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for duplicated request", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for duplicated request"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, "CREATE on the same VNF Name is already progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicates request - CREATE on the same VNF Name is already progress"); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicates request - CREATE on the same VNF Name is already progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } else { - // Check if this request is a duplicate of the one with the same vnfId - InfraActiveRequests dup = null; - msoLogger.debug ("Checking for a duplicate with the same vnf-id"); - try { - dup = RequestsDatabase.checkDuplicateByVnfId (msoRequest.getVnfInputs ().getVnfId (), - msoRequest.getRequestInfo ().getAction ().value (), - "VNF"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "vnf-id", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for a duplicate request with the same vnf-id", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for a duplicate request with the same vnf-id"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - msoRequest.getRequestInfo ().getAction ().value () - + " on the same VNF Id already in progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicated request on the same VNF Id already in progress"); - - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicated request on the same VNF Id already in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - String orchestrationURI = ""; - - try (CatalogDatabase db = new CatalogDatabase()) { - - Recipe recipe = null; - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - // First get recipe for the service type given - if (msoRequest.getServiceType () != null - && msoRequest.getServiceType ().length () > 0) { - recipe = db.getVnfRecipe (msoRequest.getVnfInputs ().getVnfType (), - msoRequest.getRequestInfo ().getAction ().value (), - msoRequest.getServiceType ()); - } - // If no recipe for the service type or no service type was given, look for recipe without service type - if (recipe == null) { - recipe = db.getVnfRecipe (msoRequest.getVnfInputs ().getVnfType (), - msoRequest.getRequestInfo ().getAction ().value (), - null); - } - } - if (version.equals (Constants.SCHEMA_VERSION_V2) || version.equals (Constants.SCHEMA_VERSION_V3)) { - switch (msoRequest.getRequestInfo ().getAction ()) { - case CREATE: - case UPDATE: - case DELETE: - // First get recipe for the vnf type given - recipe = db.getVnfRecipe (msoRequest.getVnfInputs ().getVnfType (), - msoRequest.getRequestInfo ().getAction ().value ()); - - // If no recipe for the vnf type is found, look for generic recipe with "*" vnf type - if (recipe == null) { - recipe = db.getVnfRecipe (Constants.VNF_TYPE_WILDCARD, - msoRequest.getRequestInfo ().getAction ().value ()); - } - break; - case CREATE_VF_MODULE: - case UPDATE_VF_MODULE: - case DELETE_VF_MODULE: - // First get recipe for the vnf type/vf module model name through vf module id query - recipe = db.getVfModuleRecipe (msoRequest.getVnfInputs ().getVnfType (), msoRequest.getVnfInputs ().getVfModuleModelName (), - msoRequest.getRequestInfo ().getAction ().value ()); - - // If no recipe is found, look for generic recipe with "*" vnf type - if (recipe == null) { - recipe = db.getVnfRecipeByVfModuleId (msoRequest.getVnfInputs ().getVfModuleId (), - Constants.VNF_TYPE_WILDCARD, msoRequest.getRequestInfo ().getAction ().value ()); - } - // First get recipe for the vnf type given - //recipe = db.getVnfRecipe (msoRequest.getVnfInputs ().getVnfType (), - // msoRequest.getRequestInfo ().getAction ().value ()); - - // If no recipe for the vnf type is found, look for generic recipe with "*" vnf type - //if (recipe == null) { - // recipe = db.getVnfRecipe (Constants.VNF_TYPE_WILDCARD, - // msoRequest.getRequestInfo ().getAction ().value ()); - // - //} - break; - default: - break; - } - - } - - if (recipe == null) { - msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, "VNF Recipe", "", "", MsoLogger.ErrorCode.DataError, "No recipe found in DB"); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.RECIPE_DOES_NOT_EXIST, - null, - ""); - msoRequest.createRequestRecord (Status.FAILED); - db.close (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No recipe found in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - orchestrationURI = recipe.getOrchestrationUri (); - msoLogger.debug ("Orchestration URI is: " + orchestrationURI); - - // Retrieve additional info for Vf Modules from Catalog DB to send it to BPMN - switch (msoRequest.getRequestInfo ().getAction ()) { - case CREATE_VF_MODULE: - case UPDATE_VF_MODULE: - String personaModelId = ""; - String personaModelVersion = ""; - String vnfPersonaModelId = ""; - String vnfPersonaModelVersion = ""; - Boolean isBase = false; - String asdcServiceModelVersion = msoRequest.getVnfInputs ().getAsdcServiceModelVersion (); - - // Get VF Module-specific persona info and base module indicator - VfModule vfm = null; - String vfModuleType = msoRequest.getVnfInputs ().getVnfType () + "::" + msoRequest.getVnfInputs ().getVfModuleModelName (); - if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) { - vfm = db.getVfModuleType (vfModuleType, asdcServiceModelVersion); - } - else { - vfm = db.getVfModuleType (vfModuleType); - } - if (vfm != null) { - if (vfm.getIsBase() == 1) { - isBase = true; - } - personaModelId = vfm.getModelInvariantUuid(); - personaModelVersion = vfm.getModelVersion(); - msoLogger.debug("Setting personaModelId to " + personaModelId + - ", personaModelVersion to " + personaModelVersion); - } - // Get VNF-specific persona info - VnfResource vnfr = null; - if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) { - vnfr = db.getVnfResource (msoRequest.getVnfInputs ().getVnfType (), asdcServiceModelVersion); - } - else { - vnfr = db.getVnfResource (msoRequest.getVnfInputs ().getVnfType ()); - } - if (vnfr != null) { - vnfPersonaModelId = vnfr.getModelInvariantUuid (); - vnfPersonaModelVersion = vnfr.getModelVersion(); - msoLogger.debug("Setting vnfPersonaModelId to " + vnfPersonaModelId + - ", vnfPersonaModelVersion to " + vnfPersonaModelVersion); - } - - msoRequest.addBPMNSpecificInputs(personaModelId, personaModelVersion, isBase, - vnfPersonaModelId, vnfPersonaModelVersion); - - break; - default: - break; - } - - db.close (); - - String requestId = msoRequest.getRequestId (); - msoLogger.debug ("requestId is: " + requestId); - msoLogger.debug ("About to insert a record"); - - try { - msoRequest.createRequestRecord (Status.PENDING); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, - null, - "non-unique request-id specified"); - // Cannot create a record of this request here, our communication with MSO DB just failed. Do not try - // to create a failed record - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - msoLogger.debug("Request going to BPEL: " + msoRequest.getRequestXML ()); - - RequestClient requestClient = null; - HttpResponse response = null; - long subStartTime = System.currentTimeMillis(); - try { - requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props); - // Capture audit event - msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - response = requestClient.post (msoRequest.getRequestXML (), - requestId, - Integer.toString (recipe.getRecipeTimeout ()).toString (), - version, - null, - null); - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null); - } catch (Exception e) { - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_COMMUNICATION_TO_BPEL, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoConfigurationError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - if (response == null) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_RESPONSE_FROM_BPEL, - null, - "bpelResponse is null"); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Null response from BPEL", "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Null response from BPEL"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - - // BPEL accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String bpelXMLResponseBody = respHandler.getResponseBody (); - msoLogger.debug ("Received from BPEL: " + bpelXMLResponseBody); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.IN_PROGRESS); - RequestsDatabase.updateInfraStatus (msoRequest.getRequestId (), - Status.IN_PROGRESS.toString (), - Constants.PROGRESS_REQUEST_IN_PROGRESS, - Constants.MODIFIED_BY_APIHANDLER); - Response resp = msoRequest.buildResponse (bpelStatus, null, null); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - - String bpelXMLResponseBody = respHandler.getResponseBody (); - if (bpelXMLResponseBody != null && !bpelXMLResponseBody.isEmpty ()) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, bpelXMLResponseBody, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, - "Response from BPEL engine is failed with HTTP Status=" + bpelStatus, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, ErrorNumbers.ERROR_FROM_BPEL, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Response from BPEL engine is empty", "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - } - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - private Response manageNetworkRequestImpl (String reqXML, String version) { - String methodName = "NetworkRequest"; - - props = loadMsoProperties (); - - long startTime = System.currentTimeMillis (); - if (noProperties) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, "Application not started, properties file missing or invalid"); - return NOT_STARTED_RESPONSE; - } - uriInfo.getRequestUri (); - - // Generate unique request id for the new request - UUID requestUUID = UUID.randomUUID (); - - NetworkMsoInfraRequest msoRequest = new NetworkMsoInfraRequest (requestUUID.toString ()); - MsoLogger.setLogContext (msoRequest.getRequestId (), null); - - if (reqXML == null) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "The input Request is null"); - return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); - } - - String requestUri = uriInfo.getRequestUri ().toString (); - - msoLogger.debug ("Incoming Request: " + reqXML); - - msoRequest.setRequestUri (requestUri); - msoLogger.debug ("Schema version: " + version); - try { - msoRequest.parse (reqXML, version, props); - } catch (Exception e) { - msoLogger.debug ("Validation failed: ", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseFailedValidation (HttpStatus.SC_BAD_REQUEST, e.getMessage ()); - if (msoRequest.getRequestId () != null) { - msoLogger.debug ("Logging failed message to the database"); - msoRequest.createRequestRecord (Status.FAILED); - } - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, reqXML, "", "", MsoLogger.ErrorCode.DataError, "Exception when parsing reqXML", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - MsoLogger.setServiceName (MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo().getAction().name()); - msoLogger.debug ("Update serviceName with detailed action info to:" + MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo().getAction().name()); - if (msoRequest.getRequestInfo () - .getAction () == org.openecomp.mso.apihandlerinfra.networkbeans.ActionType.CREATE) { - // Check if this request is a duplicate of the one with the same network Name - msoLogger.debug ("Checking for a duplicate with the same network-name"); - InfraActiveRequests dup = null; - try { - - dup = RequestsDatabase.checkDuplicateByVnfName (msoRequest.getNetworkInputs ().getNetworkName (), - msoRequest.getRequestInfo ().getAction ().value (), - "NETWORK"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "network-name", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for duplicated request", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for duplicated request"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - "CREATE on the same Network Name is already progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicates request - CREATE on the same Network Name is already progress"); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicates request - CREATE on the same Network Name is already progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } else { - // Check if this request is a duplicate of the one with the same networkId - InfraActiveRequests dup = null; - msoLogger.debug ("Checking for a duplicate with the same network-id"); - try { - dup = RequestsDatabase.checkDuplicateByVnfId (msoRequest.getNetworkInputs ().getNetworkId (), - msoRequest.getRequestInfo ().getAction ().value (), - "NETWORK"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "network-id", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for a duplicate request with the same network-id", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for a duplicate request with the same network-id"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - msoRequest.getRequestInfo ().getAction ().value () - + " on the same Network Id already in progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicated request on the same Network Id already in progress"); - - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicated request on the same Network Id already in progress."); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - String orchestrationURI = ""; - - // Query MSO Catalog DB - try (CatalogDatabase db = new CatalogDatabase()) { - Recipe recipe = null; - - if (msoRequest.getServiceType () != null - && msoRequest.getServiceType ().length () > 0) { - recipe = db.getNetworkRecipe (msoRequest.getNetworkInputs ().getNetworkType (), - msoRequest.getRequestInfo ().getAction ().value (), - msoRequest.getServiceType ()); - - } - if (recipe == null) { - recipe = db.getNetworkRecipe (msoRequest.getNetworkInputs ().getNetworkType (), - msoRequest.getRequestInfo ().getAction ().value (), - null); - } - - if (recipe == null) { - msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, "VNF Recipe", "", "", MsoLogger.ErrorCode.DataError, "VNF Recipe attribute not found"); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.RECIPE_DOES_NOT_EXIST, - null, - ""); - msoRequest.createRequestRecord (Status.FAILED); - db.close (); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No recipe found in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - orchestrationURI = recipe.getOrchestrationUri (); - msoLogger.debug ("Orchestration URI is: " + orchestrationURI); - - String requestId = msoRequest.getRequestId (); - msoLogger.debug ("requestId is: " + requestId); - msoLogger.debug ("About to insert a record"); - - try { - msoRequest.createRequestRecord (Status.PENDING); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.DataError, "Exception while creating record in DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, - null, - "non-unique request-id specified"); - // Cannot create a record of this request here, our communication with MSO DB just failed. Do not try - // to create a failed record - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - RequestClient requestClient = null; - HttpResponse response = null; - long subStartTime = System.currentTimeMillis(); - try { - requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props); - // Capture audit event - msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - response = requestClient.post (msoRequest.getRequestXML (), - requestId, - Integer.toString (recipe.getRecipeTimeout ()).toString (), - version, - null, - null); - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null); - } catch (Exception e) { - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_COMMUNICATION_TO_BPEL, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoConfigurationError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - if (response == null) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_RESPONSE_FROM_BPEL, - null, - "bpelResponse is null"); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Null response from BPEL", "Camunda", "", MsoLogger.ErrorCode.DataError, "bpelResponse is null"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is null"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - - // BPEL accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String bpelXMLResponseBody = respHandler.getResponseBody (); - msoLogger.debug ("Received from BPEL: " + bpelXMLResponseBody); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.IN_PROGRESS); - RequestsDatabase.updateInfraStatus (msoRequest.getRequestId (), - Status.IN_PROGRESS.toString (), - Constants.PROGRESS_REQUEST_IN_PROGRESS, - Constants.MODIFIED_BY_APIHANDLER); - Response resp = msoRequest.buildResponse (bpelStatus, null, null); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - - String bpelXMLResponseBody = respHandler.getResponseBody (); - if (bpelXMLResponseBody != null && !bpelXMLResponseBody.isEmpty ()) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, bpelXMLResponseBody, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, - "Response from BPEL engine is failed with HTTP Status=" + bpelStatus, "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is with status Failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, ErrorNumbers.ERROR_FROM_BPEL, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Response from BPEL engine is empty", "Camunda", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - } - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception while communciate with Catalog DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - private Response manageVolumeRequestImpl (String reqXML, String version) { - String methodName = "VolumeRequest"; - props = loadMsoProperties (); - - long startTime = System.currentTimeMillis (); - if (noProperties) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, "Application not started, properties file missing or invalid"); - return NOT_STARTED_RESPONSE; - } - - uriInfo.getRequestUri (); - - // Generate unique request id for the new request - UUID requestUUID = UUID.randomUUID (); - - VolumeMsoInfraRequest msoRequest = new VolumeMsoInfraRequest (requestUUID.toString ()); - - if (reqXML == null) { - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.BadRequest, "The input request is null"); - return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); - } - - String requestUri = uriInfo.getRequestUri ().toString (); - - msoLogger.debug ("Incoming Request: " + reqXML); - - msoRequest.setRequestUri (requestUri); - - msoLogger.debug ("Schema version: " + version); - try { - msoRequest.parse (reqXML, version, props); - } catch (Exception e) { - msoLogger.debug ("Validation failed: ", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseFailedValidation (HttpStatus.SC_BAD_REQUEST, e.getMessage ()); - if (msoRequest.getRequestId () != null) { - msoLogger.debug ("Logging failed message to the database"); - msoRequest.createRequestRecord (Status.FAILED); - } - msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, reqXML, "", "", MsoLogger.ErrorCode.DataError, "Exception when parsing reqXML", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - MsoLogger.setServiceName (MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo ().getAction ().name ()); - msoLogger.debug ("Update serviceName with detailed action info to:" + MsoLogger.getServiceName () + "_" + msoRequest.getRequestInfo ().getAction ().name ()); - if (msoRequest.getRequestInfo () - .getAction () == org.openecomp.mso.apihandlerinfra.volumebeans.ActionType.CREATE) { - // Check if this request is a duplicate of the one with the same network Name - msoLogger.debug ("Checking for a duplicate with the same volume-name"); - InfraActiveRequests dup = null; - try { - - dup = RequestsDatabase.checkDuplicateByVnfName (msoRequest.getVolumeInputs ().getVolumeGroupName (), - msoRequest.getRequestInfo ().getAction ().value (), - "VOLUME"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "volume-group-name", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for duplicated request", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for duplicated request"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - "CREATE on the same Volume Group Name is already progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicates request - CREATE on the same Volume Group Name is already progress"); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicates request - CREATE on the same Volume Group Name is already progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } else { - // Check if this request is a duplicate of the one with the same volumeGroupId - InfraActiveRequests dup = null; - msoLogger.debug ("Checking for a duplicate with the same volume-group-id"); - try { - dup = RequestsDatabase.checkDuplicateByVnfId (msoRequest.getVolumeInputs ().getVolumeGroupId (), - msoRequest.getRequestInfo ().getAction ().value (), - "VOLUME"); - - } catch (Exception e) { - msoLogger.debug ("Exception", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC_ATT, "volume-group-id", "", "", MsoLogger.ErrorCode.DataError, "Exception while checking for a duplicate request with the sam volume-group-id", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while checking for a duplicate request with the sam volume-group-id"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - if (dup != null) { - // Found the duplicate record. Return the appropriate error. - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponse (HttpStatus.SC_CONFLICT, - ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID, - dup); - msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, - msoRequest.getRequestInfo ().getAction ().value () - + " on the same Volume Group Id already in progress", "", "", MsoLogger.ErrorCode.DataError, "Duplicated request on the same Volume Group Id already in progress"); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, "Duplicated request on the same Volume Group Id already in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - String orchestrationURI = ""; - - // Query MSO Catalog DB - try (CatalogDatabase db = new CatalogDatabase()) { - - Recipe recipe = null; - - if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (msoRequest.getServiceType () != null - && msoRequest.getServiceType ().length () > 0) { - recipe = db.getVnfComponentsRecipe (msoRequest.getVolumeInputs ().getVnfType (), - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), - msoRequest.getServiceType ()); - } - if (recipe == null) { - recipe = db.getVnfComponentsRecipe (msoRequest.getVolumeInputs ().getVnfType (), - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), - null); - // If no recipe for the vnf type is found, look for generic recipe with "*" vnf type - if (recipe == null) { - recipe = db.getVnfComponentsRecipe (Constants.VNF_TYPE_WILDCARD, - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), - null); - } - } - } - else if (version.equals (Constants.SCHEMA_VERSION_V2) || version.equals (Constants.SCHEMA_VERSION_V3)) { - switch (msoRequest.getRequestInfo ().getAction ()) { - case CREATE: - case UPDATE: - case DELETE: - // First get recipe for the vnf type given - recipe = db.getVnfComponentsRecipe (msoRequest.getVolumeInputs ().getVnfType (), - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), null); - - // If no recipe for the vnf type is found, look for generic recipe with "*" vnf type - if (recipe == null) { - recipe = db.getVnfComponentsRecipe (Constants.VNF_TYPE_WILDCARD, - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), null); - } - break; - case CREATE_VF_MODULE_VOL: - case UPDATE_VF_MODULE_VOL: - case DELETE_VF_MODULE_VOL: - // First get recipe for the vnf type given - recipe = db.getVnfComponentsRecipe (msoRequest.getVolumeInputs ().getVnfType (), - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value (), null); - - // If no recipe for the vnf type is found, look for generic recipe with "*" in vf module id - if (recipe == null) { - recipe = db.getVnfComponentsRecipeByVfModuleId (Constants.VNF_TYPE_WILDCARD, - Constants.VOLUME_GROUP_COMPONENT_TYPE, - msoRequest.getRequestInfo ().getAction ().value ()); - } - break; - default: - break; - } - - } - - if (recipe == null) { - msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, "VNF Recipe", "", "", MsoLogger.ErrorCode.DataError, "VNF Recipe not found in DB"); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.RECIPE_DOES_NOT_EXIST, - null, - ""); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "VNF Recipe not found in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - orchestrationURI = recipe.getOrchestrationUri (); - msoLogger.debug ("Orchestration URI is: " + orchestrationURI); - - String requestId = msoRequest.getRequestId (); - msoLogger.debug ("requestId is: " + requestId); - msoLogger.debug ("About to insert a record"); - - try { - msoRequest.createRequestRecord (Status.PENDING); - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in createRequestRecord", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_INTERNAL_SERVER_ERROR, - ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, - null, - "non-unique request-id specified"); - // Cannot create a record of this request here, our communication with MSO DB just failed. Do not try - // to create a failed record - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - - RequestClient requestClient = null; - HttpResponse response = null; - long subStartTime = System.currentTimeMillis(); - try { - requestClient = RequestClientFactory.getRequestClient (orchestrationURI, props); - // Capture audit event - msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ()); - response = requestClient.post (msoRequest.getRequestXML (), - requestId, - Integer.toString (recipe.getRecipeTimeout ()).toString (), - version, - null, - null); - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationURI, null); - } catch (Exception e) { - msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationURI, null); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_COMMUNICATION_TO_BPEL, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoConfigurationError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL)); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, "Camunda", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine", e); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - if (response == null) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponseWithError (HttpStatus.SC_BAD_GATEWAY, - ErrorNumbers.NO_RESPONSE_FROM_BPEL, - null, - "bpelResponse is null"); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Null response from BPEL", "Camunda", "", MsoLogger.ErrorCode.DataError, "Null response from BPMN engine"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN engine"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - - // BPEL accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String bpelXMLResponseBody = respHandler.getResponseBody (); - msoLogger.debug ("Received from BPEL: " + bpelXMLResponseBody); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.IN_PROGRESS); - RequestsDatabase.updateInfraStatus (msoRequest.getRequestId (), - Status.IN_PROGRESS.toString (), - Constants.PROGRESS_REQUEST_IN_PROGRESS, - Constants.MODIFIED_BY_APIHANDLER); - Response resp = msoRequest.buildResponse (bpelStatus, null, null); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - - String bpelXMLResponseBody = respHandler.getResponseBody (); - if (bpelXMLResponseBody != null && !bpelXMLResponseBody.isEmpty ()) { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, bpelXMLResponseBody, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, - "Response from BPEL engine is failed with HTTP Status=" + bpelStatus, "Camunda", "", MsoLogger.ErrorCode.DataError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is with status Failed"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } else { - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response resp = msoRequest.buildResponse (bpelStatus, ErrorNumbers.ERROR_FROM_BPEL, null); - msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, "Response from BPEL engine is empty", "Camunda", "", MsoLogger.ErrorCode.DataError, "Response from BPEL engine is empty"); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is empty"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); - return resp; - } - } - } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception while communciate with Catalog DB", e); - msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.FAILED); - Response response = msoRequest.buildResponseWithError (HttpStatus.SC_NOT_FOUND, - ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB, - null, - e.getMessage ()); - alarmLogger.sendAlarm ("MsoDatabaseAccessError", - MsoAlarmLogger.CRITICAL, - Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB)); - msoRequest.createRequestRecord (Status.FAILED); - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB"); - msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); - return response; - } - } - - private Request mapInfraActiveRequestToRequest(InfraActiveRequests requestDB) { - - - Request request = new Request(); - - ObjectMapper mapper = new ObjectMapper(); - // mapper.configure(Feature.WRAP_ROOT_VALUE, true); - - request.setRequestId(requestDB.getRequestId()); - request.setRequestScope(requestDB.getRequestScope()); - request.setRequestType(requestDB.getRequestAction()); - - InstanceReferences ir = new InstanceReferences(); - if(requestDB.getNetworkId() != null) - ir.setNetworkInstanceId(requestDB.getNetworkId()); - if(requestDB.getNetworkName() != null) - ir.setNetworkInstanceName(requestDB.getNetworkName()); - if(requestDB.getServiceInstanceId() != null) - ir.setServiceInstanceId(requestDB.getServiceInstanceId()); - if(requestDB.getServiceInstanceName() != null) - ir.setServiceInstanceName(requestDB.getServiceInstanceName()); - if(requestDB.getVfModuleId() != null) - ir.setVfModuleInstanceId(requestDB.getVfModuleId()); - if(requestDB.getVfModuleName() != null) - ir.setVfModuleInstanceName(requestDB.getVfModuleName()); - if(requestDB.getVnfId() != null) - ir.setVnfInstanceId(requestDB.getVnfId()); - if(requestDB.getVnfName() != null) - ir.setVnfInstanceName(requestDB.getVnfName()); - if(requestDB.getVolumeGroupId() != null) - ir.setVolumeGroupInstanceId(requestDB.getVolumeGroupId()); - if(requestDB.getVolumeGroupName() != null) - ir.setVolumeGroupInstanceName(requestDB.getVolumeGroupName()); - - - request.setInstanceReferences(ir); - - String requestBody = requestDB.getRequestBody(); - - RequestDetails requestDetails = null; - - try{ - requestDetails = mapper.readValue(requestBody, RequestDetails.class); - - }catch(Exception e){ - msoLogger.debug("Exception caught mapping requestBody to RequestDetails"); - } - - request.setRequestDetails(requestDetails); - String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getStartTime()) + " GMT"; - request.setStartTime(startTimeStamp); - - RequestStatus status = new RequestStatus(); - if(requestDB.getStatusMessage() != null){ - status.setStatusMessage(requestDB.getStatusMessage()); - } - - if(requestDB.getEndTime() != null){ - String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getEndTime()) + " GMT"; - status.setFinishTime(endTimeStamp); - } - - - if(requestDB.getRequestStatus() != null){ - status.setRequestState(requestDB.getRequestStatus()); - } - - if(requestDB.getProgress() != null){ - status.setPercentProgress(requestDB.getProgress().intValue()); - } - - request.setRequestStatus(status); - - return request; - } - - private RecipeLookupResult getServiceInstanceOrchestrationURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception { - - RecipeLookupResult recipeLookupResult = null; - // Query MSO Catalog DB - - if (msoRequest.getModelInfo().getModelType().equals(ModelType.service)) { - - // SERVICE REQUEST - // Construct the default service name - // TODO need to make this a configurable property - - String defaultServiceName = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; - Service serviceRecord = db.getServiceByName(defaultServiceName); - int serviceId = serviceRecord.getId(); - ServiceRecipe recipe = db.getServiceRecipe(serviceId, action.name()); - - if (recipe == null) { - return null; - } - - recipeLookupResult = new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); - } - else if (msoRequest.getModelInfo().getModelType().equals(ModelType.vfModule) || - msoRequest.getModelInfo().getModelType().equals(ModelType.volumeGroup)) { - - String vnfComponentType = msoRequest.getModelInfo().getModelType().name(); - VnfComponentsRecipe recipe = null; - - if (action != Action.deleteInstance) { - RelatedInstanceList[] instanceList = null; - if (msoRequest.getServiceInstancesRequest().getRequestDetails() != null) { - instanceList = msoRequest.getServiceInstancesRequest().getRequestDetails().getRelatedInstanceList(); - } - - String serviceModelName = null; - String vnfModelName = null; - String vfModuleModelName = null; - String asdcServiceModelVersion = null; - String modelVersion = null; - - if (instanceList != null) { - - for(RelatedInstanceList relatedInstanceList : instanceList){ - - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){ - serviceModelName = relatedInstance.getModelInfo().getModelName(); - asdcServiceModelVersion = relatedInstance.getModelInfo().getModelVersion(); - } - - if(relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)){ - vnfModelName = relatedInstance.getModelInfo().getModelCustomizationName(); - } - - if(relatedInstance.getModelInfo().getModelType().equals(ModelType.vfModule) || - relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) { - vfModuleModelName = relatedInstance.getModelInfo().getModelName(); - modelVersion = relatedInstance.getModelInfo().getModelVersion(); - } - } - } - - String vnfType = serviceModelName + "/" + vnfModelName; - - // Try to find a recipe for a custom flow first - recipe = db.getVnfComponentsRecipe(vnfType, vfModuleModelName, asdcServiceModelVersion, modelVersion, action.name()); - } - - if (recipe == null) { - // Find the default recipe record - recipe = db.getVnfComponentsRecipeByVfModuleId("VID_DEFAULT", vnfComponentType, action.name()); - - if (recipe == null) { - return null; - } - } - recipeLookupResult = new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); - - } - else if (msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) { - // VNF REQUEST - // Construct the default vnf type - // TODO need to make this a configurable property - - String defaultVnfType = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; - - VnfRecipe recipe = db.getVnfRecipe(defaultVnfType, action.name()); - - if (recipe == null) { - return null; - } - recipeLookupResult = new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); - } - else if (msoRequest.getModelInfo().getModelType().equals(ModelType.network)) { - // NETWORK REQUEST - // Construct the default network type - // TODO need to make this a configurable property - - String defaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; - - Recipe recipe = db.getNetworkRecipe(defaultNetworkType, action.name()); - - if (recipe == null) { - return null; - } - recipeLookupResult = new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); - } - - if (recipeLookupResult != null) { - msoLogger.debug ("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout ())); - } - else { - msoLogger.debug("No matching recipe record found"); - } - return recipeLookupResult; - } -}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java index 774b9d6..3410cf4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,22 +37,10 @@ import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.codehaus.jackson.map.ObjectMapper; -import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.apihandler.common.ResponseHandler; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RelatedInstance; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RelatedInstanceList; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestReferences; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesResponse; +import org.openecomp.mso.apihandler.common.*; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.*; import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.Recipe; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceRecipe; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VnfComponentsRecipe; -import org.openecomp.mso.db.catalog.beans.VnfRecipe; +import org.openecomp.mso.db.catalog.beans.*; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoAlarmLogger; import org.openecomp.mso.logger.MsoLogger; @@ -62,7 +50,7 @@ import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.RequestsDatabase; import org.openecomp.mso.utils.UUIDChecker; -@Path("/serviceInstances/v2") +@Path("/serviceInstances/{version:[vV][2-3]}") public class ServiceInstances { private HashMap<String, String> instanceIdMap = new HashMap<String,String>(); @@ -76,7 +64,7 @@ public class ServiceInstances { private static MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties (); /** - * + * */ public ServiceInstances() { // TODO Auto-generated constructor stub @@ -86,206 +74,215 @@ public class ServiceInstances { @Path("/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response createServiceInstance(String request) { - - Response response = serviceInstances(request, Action.createInstance, null); - + public Response createServiceInstance(String request, @PathParam("version") String version) { + + Response response = serviceInstances(request, Action.createInstance, null, version); + return response; } - + @DELETE @Path("/{serviceInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response deleteServiceInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId) { - + public Response deleteServiceInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("version") String version) { + instanceIdMap.put("serviceInstanceId", serviceInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); + Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap, version); return response; } - + @POST @Path("/{serviceInstanceId}/vnfs") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response createVnfInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId) { - + public Response createVnfInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("version") String version) { + instanceIdMap.put("serviceInstanceId", serviceInstanceId); - Response response = serviceInstances(request, Action.createInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.createInstance, instanceIdMap, version); + return response; } - + @DELETE @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response deleteVnfInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId) { - + @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("version") String version) { + instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap, version); + return response; } - + @POST @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response createVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId) { - + public Response createVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("version") String version) { + instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); - Response response = serviceInstances(request, Action.createInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.createInstance, instanceIdMap, version); + return response; } - + @PUT @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response updateVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, + public Response updateVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) { - + @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, + @PathParam("version") String version) { + instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); - Response response = serviceInstances(request, Action.updateInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.updateInstance, instanceIdMap, version); + return response; } - + @DELETE @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response deleteVfModuleInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) { - - + @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, + @PathParam("version") String version) { + + instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap, version); + return response; } - - + + @POST @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response createVolumeGroupInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId) { - + @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("version") String version) { + instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); - Response response = serviceInstances(request, Action.createInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.createInstance, instanceIdMap, version); + return response; } - + @PUT @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateVolumeGroupInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) { - - + @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, + @PathParam("version") String version) { + + instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId); - Response response = serviceInstances(request, Action.updateInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.updateInstance, instanceIdMap, version); + return response; } - + @DELETE @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response deleteVolumeGroupInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) { - - + @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, + @PathParam("version") String version) { + + instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("vnfInstanceId", vnfInstanceId); instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap, version); + return response; } - + @POST @Path("/{serviceInstanceId}/networks") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response createNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId) { - + public Response createNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("version") String version) { + instanceIdMap.put("serviceInstanceId", serviceInstanceId); - Response response = serviceInstances(request, Action.createInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.createInstance, instanceIdMap, version); + return response; } - + @PUT @Path("/{serviceInstanceId}/networks/{networkInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("networkInstanceId") String networkInstanceId) { - + @PathParam("networkInstanceId") String networkInstanceId, + @PathParam("version") String version) { + instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("networkInstanceId", networkInstanceId); - Response response = serviceInstances(request, Action.updateInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.updateInstance, instanceIdMap, version); + return response; - } - + } + @DELETE @Path("/{serviceInstanceId}/networks/{networkInstanceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response deleteNetworkInstance(String request, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("networkInstanceId") String networkInstanceId) { - + @PathParam("networkInstanceId") String networkInstanceId, + @PathParam("version") String version) { + instanceIdMap.put("serviceInstanceId", serviceInstanceId); instanceIdMap.put("networkInstanceId", networkInstanceId); - Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap); - + Response response = serviceInstances(request, Action.deleteInstance, instanceIdMap, version); + return response; - } - - - - private Response serviceInstances(String requestJSON, Action action, HashMap<String,String> instanceIdMap) { - + } + + + + private Response serviceInstances(String requestJSON, Action action, HashMap<String,String> instanceIdMap, String version) { + String requestId = UUIDChecker.generateUUID(msoLogger); long startTime = System.currentTimeMillis (); msoLogger.debug ("requestId is: " + requestId); ServiceInstancesRequest sir = null; - + MsoRequest msoRequest = new MsoRequest (requestId); - - + + try{ ObjectMapper mapper = new ObjectMapper(); sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); - + } catch(Exception e){ msoLogger.debug ("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, - "Mapping of request to JSON object failed. " + e.getMessage(), + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, + "Mapping of request to JSON object failed. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null); if (msoRequest.getRequestId () != null) { msoLogger.debug ("Mapping of request to JSON object failed"); @@ -295,15 +292,15 @@ public class ServiceInstances { msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed"); msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return response; - } - - + } + + try{ - msoRequest.parse(sir, instanceIdMap, action); + msoRequest.parse(sir, instanceIdMap, action, version); } catch (Exception e) { msoLogger.debug ("Validation failed: ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, - "Error parsing request. " + e.getMessage(), + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, + "Error parsing request. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null); if (msoRequest.getRequestId () != null) { msoLogger.debug ("Logging failed message to the database"); @@ -314,27 +311,28 @@ public class ServiceInstances { msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return response; } - + InfraActiveRequests dup = null; String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName(); String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name(); try { - dup = RequestsDatabase.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); - + if(!(instanceName==null && requestScope.equals("service") && action == Action.createInstance)){ + dup = RequestsDatabase.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); + } } catch (Exception e) { msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e); - - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException, - e.getMessage(), + + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException, + e.getMessage(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null) ; - - + + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Error during duplicate check"); msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return response; } - + if (dup != null) { // Found the duplicate record. Return the appropriate error. String instance = null; @@ -346,29 +344,29 @@ public class ServiceInstances { String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") " + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - " + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding."; //List<String> variables = new ArrayList<String>(); //variables.add(dup.getRequestStatus()); - - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException, - dupMessage, + + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException, + dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null) ; - - + + msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError, "Duplicate request - Subscriber already has a request for this service"); msoRequest.createRequestRecord (Status.FAILED, action); msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage); msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return response; } - - + + ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); - + RequestReferences referencesResponse = new RequestReferences(); - + referencesResponse.setRequestId(requestId); - - serviceResponse.setRequestReferences(referencesResponse); - + + serviceResponse.setRequestReferences(referencesResponse); + try (CatalogDatabase db = new CatalogDatabase()){ RecipeLookupResult recipeLookupResult = null; @@ -513,7 +511,7 @@ public class ServiceInstances { serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, msoRequest.getServiceInstanceType (), msoRequest.getVnfType (), msoRequest.getVfModuleType (), - msoRequest.getNetworkType (), requestJSON); + msoRequest.getNetworkType (), msoRequest.getRequestJSON()); msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI (), null); } catch (Exception e) { @@ -575,7 +573,7 @@ public class ServiceInstances { ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables); msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); + msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is failed"); msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); return resp; @@ -587,7 +585,7 @@ public class ServiceInstances { ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables); msoRequest.updateFinalStatus (Status.FAILED); - msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty"); + msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty"); msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty"); msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); return resp; @@ -613,122 +611,199 @@ public class ServiceInstances { return response; } } - + private RecipeLookupResult getServiceInstanceOrchestrationURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception { + RecipeLookupResult recipeLookupResult = null; + //if the aLaCarte flag is set to TRUE, the API-H should choose the “VID_DEFAULT†recipe for the requested action - RecipeLookupResult recipeLookupResult = null; + msoLogger.debug("aLaCarteFlag is " + msoRequest.getALaCarteFlag()); // Query MSO Catalog DB - + if (msoRequest.getModelInfo().getModelType().equals(ModelType.service)) { - - // SERVICE REQUEST - // Construct the default service name - // TODO need to make this a configurable property - - String defaultServiceName = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; - Service serviceRecord = db.getServiceByName(defaultServiceName); - int serviceId = serviceRecord.getId(); - ServiceRecipe recipe = db.getServiceRecipe(serviceId, action.name()); - - if (recipe == null) { - return null; - } - - recipeLookupResult = new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); + recipeLookupResult = getServiceURI(db, msoRequest, action); } else if (msoRequest.getModelInfo().getModelType().equals(ModelType.vfModule) || - msoRequest.getModelInfo().getModelType().equals(ModelType.volumeGroup)) { - - String vnfComponentType = msoRequest.getModelInfo().getModelType().name(); - VnfComponentsRecipe recipe = null; - - if (action != Action.deleteInstance) { - RelatedInstanceList[] instanceList = null; - if (msoRequest.getServiceInstancesRequest().getRequestDetails() != null) { - instanceList = msoRequest.getServiceInstancesRequest().getRequestDetails().getRelatedInstanceList(); - } - - String serviceModelName = null; - String vnfModelName = null; - String vfModuleModelName = null; - String asdcServiceModelVersion = null; - String modelVersion = null; - - if (instanceList != null) { - - for(RelatedInstanceList relatedInstanceList : instanceList){ - - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){ - serviceModelName = relatedInstance.getModelInfo().getModelName(); - asdcServiceModelVersion = relatedInstance.getModelInfo().getModelVersion(); - } - - if(relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)){ - vnfModelName = relatedInstance.getModelInfo().getModelCustomizationName(); - } - - if(relatedInstance.getModelInfo().getModelType().equals(ModelType.vfModule) || - relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) { - vfModuleModelName = relatedInstance.getModelInfo().getModelName(); - modelVersion = relatedInstance.getModelInfo().getModelVersion(); - } - } - } - - String vnfType = serviceModelName + "/" + vnfModelName; - - // Try to find a recipe for a custom flow first - recipe = db.getVnfComponentsRecipe(vnfType, vfModuleModelName, asdcServiceModelVersion, modelVersion, action.name()); - } - - if (recipe == null) { - // Find the default recipe record - recipe = db.getVnfComponentsRecipeByVfModuleId("VID_DEFAULT", vnfComponentType, action.name()); - - if (recipe == null) { - return null; - } - } - recipeLookupResult = new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); - - } - else if (msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) { - // VNF REQUEST - // Construct the default vnf type - // TODO need to make this a configurable property - - String defaultVnfType = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; - - VnfRecipe recipe = db.getVnfRecipe(defaultVnfType, action.name()); - - if (recipe == null) { - return null; - } - recipeLookupResult = new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); + msoRequest.getModelInfo().getModelType().equals(ModelType.volumeGroup) || msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) { + + recipeLookupResult = getVnfOrVfModuleUri(db, msoRequest, action); + + }else if (msoRequest.getModelInfo().getModelType().equals(ModelType.network)) { + + recipeLookupResult = getNetworkUri(db, msoRequest, action); } - else if (msoRequest.getModelInfo().getModelType().equals(ModelType.network)) { - // NETWORK REQUEST - // Construct the default network type - // TODO need to make this a configurable property - - String defaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; - - Recipe recipe = db.getNetworkRecipe(defaultNetworkType, action.name()); - - if (recipe == null) { - return null; - } - recipeLookupResult = new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); - } - + if (recipeLookupResult != null) { - msoLogger.debug ("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout ())); + msoLogger.debug ("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout ())); } else { - msoLogger.debug("No matching recipe record found"); + msoLogger.debug("No matching recipe record found"); } return recipeLookupResult; } + + private RecipeLookupResult getServiceURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception { + // SERVICE REQUEST + // Construct the default service name + // TODO need to make this a configurable property + String defaultServiceName = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; + + Service serviceRecord = null; + if(msoRequest.getALaCarteFlag()){ + serviceRecord = db.getServiceByName(defaultServiceName); + }else{ + serviceRecord = db.getServiceByVersionAndInvariantId(msoRequest.getModelInfo().getModelInvariantId(), msoRequest.getModelInfo().getModelVersion()); + } + int serviceId; + ServiceRecipe recipe = null; + if(serviceRecord !=null){ + serviceId = serviceRecord.getId(); + recipe = db.getServiceRecipe(serviceId, action.name()); + } + //if an aLaCarte flag was sent in the request, throw an error if the recipe was not found + RequestParameters reqParam = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters(); + if(reqParam!=null && reqParam.isALaCarteSet() && recipe==null){ + return null; + }else if (recipe == null) { //aLaCarte wasn't sent, so we'll try the default + serviceRecord = db.getServiceByName(defaultServiceName); + serviceId = serviceRecord.getId(); + recipe = db.getServiceRecipe(serviceId, action.name()); + } + if(recipe==null){ + return null; + } + return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); + } + + + private RecipeLookupResult getVnfOrVfModuleUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception { + + String vnfComponentType = msoRequest.getModelInfo().getModelType().name(); + + RelatedInstanceList[] instanceList = null; + if (msoRequest.getServiceInstancesRequest().getRequestDetails() != null) { + instanceList = msoRequest.getServiceInstancesRequest().getRequestDetails().getRelatedInstanceList(); + } + + String serviceModelName = null; + String vnfModelName = null; + String asdcServiceModelVersion = null; + String modelVersion = msoRequest.getModelInfo().getModelVersion(); + Recipe recipe = null; + String defaultVnfType = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; + String modelCustomizationId = msoRequest.getModelInfo().getModelCustomizationId(); + String vfModuleModelName = msoRequest.getModelInfo().getModelName(); + if (instanceList != null) { + + for(RelatedInstanceList relatedInstanceList : instanceList){ + + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + ModelInfo modelInfo = relatedInstance.getModelInfo(); + if(modelInfo.getModelType().equals(ModelType.service)){ + serviceModelName = modelInfo.getModelName(); + asdcServiceModelVersion = modelInfo.getModelVersion(); + } + + if(modelInfo.getModelType().equals(ModelType.vnf)){ + vnfModelName = modelInfo.getModelCustomizationName(); + if (null == vnfModelName || vnfModelName.trim().isEmpty()) { + VnfResource vnfResource = db.getVnfResourceByModelCustomizationId(modelInfo.getModelCustomizationUuid(), modelInfo.getModelVersion()); + vnfModelName = vnfResource.getModelName(); + } + } + } + + if(msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) { + String modelCustomizationName = msoRequest.getModelInfo().getModelCustomizationName(); + + VnfResource vnfResource = null; + + // Validation for vnfResource + if(modelCustomizationName!=null) { + vnfResource = db.getVnfResource(serviceModelName + "/" + modelCustomizationName, asdcServiceModelVersion); + }else{ + vnfResource = db.getVnfResourceByModelCustomizationId(modelCustomizationId, asdcServiceModelVersion); + } + + if(vnfResource==null){ + throw new ValidationException("catalog entry"); + } + + VnfRecipe vnfRecipe = db.getVnfRecipe(defaultVnfType, action.name()); + + if (vnfRecipe == null) { + return null; + } + + return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout()); + }else{ + String vnfType = serviceModelName + "/" + vnfModelName; + String vfModuleType = vnfType + "::" + vfModuleModelName; + List<VfModule> vfModule = db.getVfModule(vfModuleType, modelCustomizationId, asdcServiceModelVersion, modelVersion, action.name()); + if(vfModule==null || vfModule.isEmpty()){ + throw new ValidationException("catalog entry"); + }else{ + if(!msoRequest.getALaCarteFlag() && action != Action.deleteInstance){ + recipe = db.getVnfComponentsRecipeByVfModule(vfModule, action.name()); + } + } + if (recipe == null) { + msoLogger.debug("recipe is null, getting default"); + recipe = db.getVnfComponentsRecipeByVfModuleId("VID_DEFAULT", vnfComponentType, action.name()); + + if (recipe == null) { + return null; + } + } + + } + } else { + msoLogger.debug("recipe is null, getting default"); + + if(msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) { + recipe = db.getVnfRecipe(defaultVnfType, action.name()); + if (recipe == null) { + return null; + } + } else { + recipe = db.getVnfComponentsRecipeByVfModuleId("VID_DEFAULT", vnfComponentType, action.name()); + + if (recipe == null) { + return null; + } + } + } + + return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); + } + + private RecipeLookupResult getNetworkUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception { + + String defaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; + + String modelName = msoRequest.getModelInfo().getModelName(); + Recipe recipe = null; + if(msoRequest.getALaCarteFlag()){ + recipe = db.getNetworkRecipe(defaultNetworkType, action.name()); + }else{ + if(msoRequest.getModelInfo().getModelCustomizationId()!=null){ + NetworkResource networkResource = db.getNetworkResourceByModelCustUuid(msoRequest.getModelInfo().getModelCustomizationId()); + if(networkResource!=null){ + recipe = db.getNetworkRecipe(networkResource.getNetworkType(), action.name()); + }else{ + throw new ValidationException("no catalog entry found"); + } + }else{ + //ok for version < 3 + recipe = db.getNetworkRecipe(modelName, action.name()); + } + if(recipe == null){ + recipe = db.getNetworkRecipe(defaultNetworkType, action.name()); + } + } + if (recipe == null) { + return null; + } + return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Status.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Status.java index c98f90d..fdd19bd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Status.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Status.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,5 +29,6 @@ public enum Status { IN_PROGRESS, COMPLETE, FAILED, - TIMEOUT + TIMEOUT, + UNLOCKED } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java index 8a0a1f3..07d70e9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -52,18 +52,18 @@ public class VfModuleModelNamesHandler { long startTime = System.currentTimeMillis (); String methodName = "getVfModuleModelNames"; MsoLogger.setServiceName (LOG_SERVICE_NAME + methodName); - msoLogger.debug ("Incoming request received for vfModuleModelNames"); + msoLogger.debug ("Incoming request received for vfModuleModelNames"); List <VfModule> vfModules = null; try (CatalogDatabase db = new CatalogDatabase()){ vfModules = db.getAllVfModules (); } catch (Exception e) { - msoLogger.debug ("No connection to catalog DB", e); + msoLogger.debug ("No connection to catalog DB", e); msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "no connection to catalog DB"); msoLogger.debug ("End of the transaction, the final response is: " + e.toString ()); return Response.status (HttpStatus.SC_NOT_FOUND).entity (e.toString ()).build (); } - if (vfModules == null) { + if (vfModules == null) { msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "VfModule not found"); msoLogger.debug ("End of the transaction. VfModuleModelName not found the final response status: " + HttpStatus.SC_NOT_FOUND); return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); @@ -74,10 +74,10 @@ public class VfModuleModelNamesHandler { for (int i = 0; i < vfModules.size (); i++) { VfModuleModelName vfModuleModelName = beansObjectFactory.createVfModuleModelName (); VfModule vm = vfModules.get (i); - vfModuleModelName.setModelName (vm.getType ()); + vfModuleModelName.setModelName (vm.getModelName ()); vfModuleModelName.setModelVersion (vm.getVersion ()); vfModuleModelName.setModelInvariantUuid (vm.getModelInvariantUuid ()); - vfModuleModelName.setIsBase(vm.isBase()); + vfModuleModelName.setIsBase(vm.isBase()); vfModuleModelName.setDescription (vm.getDescription ()); vfModuleModelName.setId (String.valueOf (vm.getId ())); vfModuleModelName.setAsdcServiceModelVersion(vm.getVersion ()); @@ -93,10 +93,10 @@ public class VfModuleModelNamesHandler { jaxbMarshaller.marshal (vfModuleModelNames, stringWriter); } catch (JAXBException e) { - msoLogger.debug ("Error marshalling", e); + msoLogger.debug ("Error marshalling", e); } - String response = stringWriter.toString (); + String response = stringWriter.toString (); msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); msoLogger.debug ("End of the transaction, the final response is: " + response); return Response.status (HttpStatus.SC_OK).entity (response).build (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java index 162e4f7..bfcbe0d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java @@ -59,9 +59,10 @@ import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.requestsdb.HibernateUtil; +import org.openecomp.mso.db.HibernateUtils; import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb; public class VnfMsoInfraRequest { @@ -83,6 +84,8 @@ public class VnfMsoInfraRequest { private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); private static final String NOT_PROVIDED = "not provided"; + protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb (); + VnfMsoInfraRequest (String requestId) { this.requestId = requestId; this.startTime = System.currentTimeMillis(); @@ -276,7 +279,7 @@ public class VnfMsoInfraRequest { Session session = null; try { - session = HibernateUtil.getSessionFactory ().openSession (); + session = hibernateUtils.getSessionFactory ().openSession (); session.beginTransaction (); InfraActiveRequests aq = new InfraActiveRequests (); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java index 32fd80d..0b59585 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -57,7 +57,6 @@ public class VnfTypesHandler { List <VnfResource> vnfResources = null; try(CatalogDatabase db = new CatalogDatabase ()) { - ; if (vnfRole != null) { vnfResources = db.getVnfResourcesByRole (vnfRole); } else { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java index eb7d187..911ac48 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -54,10 +54,11 @@ import org.openecomp.mso.apihandlerinfra.volumebeans.ObjectFactory; import org.openecomp.mso.apihandlerinfra.volumebeans.RequestInfo; import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType; import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest; +import org.openecomp.mso.db.HibernateUtils; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.requestsdb.HibernateUtil; +import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb; import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.RequestsDatabase; @@ -77,6 +78,8 @@ public class VolumeMsoInfraRequest { private long startTime; private long progress = Constants.PROGRESS_REQUEST_RECEIVED; + protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb (); + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); private static final String NOT_PROVIDED = "not provided"; @@ -133,37 +136,37 @@ public class VolumeMsoInfraRequest { action = this.rinfo.getAction (); if (action == null) { throw new ValidationException ("action"); - } + } this.volumeInputs = volumeReq.getVolumeInputs (); if (this.volumeInputs == null) { throw new ValidationException ("volume-inputs"); } - + // Verify that the elements correspond to the version - + if (version.equals(Constants.SCHEMA_VERSION_V1)) { - if (this.volumeInputs.getBackoutOnFailure() != null || this.volumeInputs.getAicCloudRegion() != null || - this.volumeInputs.getVfModuleModelName () != null || this.volumeInputs.getAsdcServiceModelVersion () != null || - this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) { - throw new ValidationException ("format for v1 version of volume request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V2)) { - if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null || - this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) { - throw new ValidationException ("format for v2 version of volume request"); - } - } - else if (version.equals(Constants.SCHEMA_VERSION_V3)) { - if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null) { - throw new ValidationException ("format for v3 version of volume request"); + if (this.volumeInputs.getBackoutOnFailure() != null || this.volumeInputs.getAicCloudRegion() != null || + this.volumeInputs.getVfModuleModelName () != null || this.volumeInputs.getAsdcServiceModelVersion () != null || + this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) { + throw new ValidationException ("format for v1 version of volume request"); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V2)) { + if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null || + this.volumeInputs.getServiceInstanceId () != null || this.volumeInputs.getVnfId () != null) { + throw new ValidationException ("format for v2 version of volume request"); } } - - + else if (version.equals(Constants.SCHEMA_VERSION_V3)) { + if (this.volumeInputs.getServiceType() != null || this.volumeInputs.getAicNodeClli() != null) { + throw new ValidationException ("format for v3 version of volume request"); + } + } + + if (!InfraUtils.isActionAllowed (props, "volume", version, action.value ())) { - throw new ValidationException ("action allowable for version " + version + " of volume request"); - } + throw new ValidationException ("action allowable for version " + version + " of volume request"); + } switch (action) { case UPDATE: @@ -177,7 +180,7 @@ public class VolumeMsoInfraRequest { default: break; } - + if (ActionType.CREATE.equals (action) || ActionType.CREATE_VF_MODULE_VOL.equals(action)) { if (this.volumeInputs.getVolumeGroupName () == null) { throw new ValidationException ("volume-group-name"); @@ -185,18 +188,18 @@ public class VolumeMsoInfraRequest { if (!InfraUtils.isValidHeatName(this.volumeInputs.getVolumeGroupName ())) { throw new ValidationException ("volume-group-name: no value meeting heat stack name syntax requirements"); } - } - - + } + + if (this.volumeInputs.getVnfType () == null) { throw new ValidationException ("vnf-type"); - } - - + } + + switch (action) { case CREATE_VF_MODULE_VOL: case UPDATE_VF_MODULE_VOL: - case DELETE_VF_MODULE_VOL: + case DELETE_VF_MODULE_VOL: if (this.volumeInputs.getVfModuleModelName () == null) { throw new ValidationException ("vf-module-model-name"); } @@ -204,38 +207,38 @@ public class VolumeMsoInfraRequest { default: break; } - + if (!version.equals(Constants.SCHEMA_VERSION_V1) && this.volumeInputs.getServiceId () == null) { throw new ValidationException ("service-id "); - } - + } + if (version.equals(Constants.SCHEMA_VERSION_V1) && this.volumeInputs.getServiceType () != null && this.volumeInputs.getServiceId () != null) { throw new ValidationException ("service-type or service-id "); } - + if (version.equals(Constants.SCHEMA_VERSION_V1) && this.volumeInputs.getAicNodeClli () == null) { throw new ValidationException ("aic-node-clli"); } - + if ((version.equals(Constants.SCHEMA_VERSION_V2) || version.equals(Constants.SCHEMA_VERSION_V3)) && (this.volumeInputs.getAicCloudRegion () == null || this.volumeInputs.getAicCloudRegion ().isEmpty())) { throw new ValidationException ("aic-cloud-region"); } - + if (version.equals(Constants.SCHEMA_VERSION_V3) && this.volumeInputs.getServiceInstanceId () == null) { throw new ValidationException ("service-instance-id"); } - + if (version.equals(Constants.SCHEMA_VERSION_V3) && this.volumeInputs.getVnfId () == null && ActionType.CREATE_VF_MODULE_VOL.equals(action)) { throw new ValidationException ("vnf-id"); } - if (ActionType.CREATE.equals (action) || ActionType.CREATE_VF_MODULE_VOL.equals(action)) { + if (ActionType.CREATE.equals (action) || ActionType.CREATE_VF_MODULE_VOL.equals(action)) { if (this.volumeInputs.getTenantId () == null) { throw new ValidationException ("tenant-id"); } } - + Object vpN = volumeReq.getVolumeParams (); if (vpN != null) { @@ -245,7 +248,7 @@ public class VolumeMsoInfraRequest { } msoLogger.debug ("VolumeParams: " + this.volumeParams); - + msoLogger.debug ("Request valid"); @@ -267,9 +270,9 @@ public class VolumeMsoInfraRequest { msoLogger.debug ("Exception: ", e); } - this.requestXML = stringWriter.toString ().replace("http://ecomp.att.com/mso/infra/volume-request", - "http://ecomp.att.com/mso/infra/vnf-request"); - + this.requestXML = stringWriter.toString ().replace("http://org.openecomp/mso/infra/volume-request", + "http://org.openecomp/mso/infra/vnf-request"); + msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); } @@ -279,7 +282,7 @@ public class VolumeMsoInfraRequest { Session session = null; try { - session = HibernateUtil.getSessionFactory ().openSession (); + session = hibernateUtils.getSessionFactory ().openSession (); session.beginTransaction (); InfraActiveRequests aq = new InfraActiveRequests (); @@ -295,7 +298,7 @@ public class VolumeMsoInfraRequest { } else { // Set up mandatory parameters aq.setAction (NOT_PROVIDED); - aq.setAction (NOT_PROVIDED); + aq.setRequestAction (NOT_PROVIDED); } aq.setRequestBody (this.requestXML); @@ -332,7 +335,7 @@ public class VolumeMsoInfraRequest { if (volumeInputs.getTenantId () != null) { aq.setTenantId (volumeInputs.getTenantId ()); } - + } aq.setStartTime (startTimeStamp); aq.setRequestStatus (status.toString ()); @@ -349,10 +352,10 @@ public class VolumeMsoInfraRequest { aq.setResponseBody (this.responseBody); Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); - aq.setEndTime (endTimeStamp); - } + aq.setEndTime (endTimeStamp); + } aq.setProgress (this.progress); - + msoLogger.debug ("About to insert a record"); @@ -373,7 +376,7 @@ public class VolumeMsoInfraRequest { public void updateFinalStatus (Status status) { int result = 0; try { - result = RequestsDatabase.updateInfraFinalStatus(requestId, status.toString (), + result = RequestsDatabase.updateInfraFinalStatus(requestId, status.toString (), this.errorMessage, this.progress, this.responseBody, Constants.MODIFIED_BY_APIHANDLER); } catch (Exception e) { msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception in updateFinalStatus"); @@ -449,7 +452,7 @@ public class VolumeMsoInfraRequest { vr.setRequestInfo (ri); vr.setVolumeInputs (this.volumeInputs); - + StringWriter stringWriter = new StringWriter (); try { JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); @@ -512,7 +515,7 @@ public class VolumeMsoInfraRequest { vr.setRequestInfo (ri); vr.setVolumeInputs (this.volumeInputs); - + StringWriter stringWriter = new StringWriter (); try { JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); @@ -595,11 +598,11 @@ public class VolumeMsoInfraRequest { break; } } - + public String getServiceType () { - if (this.volumeInputs.getServiceType () != null) + if (this.volumeInputs.getServiceType () != null) return this.volumeInputs.getServiceType (); - if (this.volumeInputs.getServiceId () != null) + if (this.volumeInputs.getServiceId () != null) return this.volumeInputs.getServiceId (); return null; } @@ -630,9 +633,9 @@ public class VolumeMsoInfraRequest { String s = sw.toString (); return s; } - + return null; - + } catch (Exception e) { msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in domToStr", e); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequest.java index 41e1236..b843784 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequest.java @@ -46,11 +46,11 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}request-info"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}request-info"/> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}network-inputs"/> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}network-params" minOccurs="0"/> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}network-outputs" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}network-inputs"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}network-params" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}network-outputs" minOccurs="0"/> * </sequence> * </sequence> * </restriction> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java index 1c0cd94..f77d5e3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java @@ -48,7 +48,7 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/network-request/v1}network-request" maxOccurs="unbounded" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/network-request/v1}network-request" maxOccurs="unbounded" minOccurs="0"/> * </sequence> * </restriction> * </complexContent> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java index e7ddc92..a7e3ae0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java @@ -48,7 +48,7 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vnf-type" maxOccurs="unbounded" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-type" maxOccurs="unbounded" minOccurs="0"/> * </sequence> * </restriction> * </complexContent> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java index df553da..6099d37 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java @@ -52,7 +52,7 @@ import javax.xml.namespace.QName; @XmlRegistry public class ObjectFactory { - private final static QName _NetworkParams_QNAME = new QName("http://ecomp.att.com/mso/infra/network-request/v1", "network-params"); + private final static QName _NetworkParams_QNAME = new QName("http://org.openecomp/mso/infra/network-request/v1", "network-params"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.apihandlerinfra.vnfbeans1 @@ -121,7 +121,7 @@ public class ObjectFactory { * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} * */ - @XmlElementDecl(namespace = "http://ecomp.att.com/mso/infra/network-request/v1", name = "network-params") + @XmlElementDecl(namespace = "http://org.openecomp/mso/infra/network-request/v1", name = "network-params") public JAXBElement<Object> createNetworkParams(Object value) { return new JAXBElement<Object>(_NetworkParams_QNAME, Object.class, null, value); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestInfo.java index c7e20aa..35c8d30 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestInfo.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,16 +19,15 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // package org.openecomp.mso.apihandlerinfra.networkbeans; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -38,17 +37,17 @@ import javax.xml.bind.annotation.XmlType; /** * <p>Java class for anonymous complex type. - * + * * <p>The following schema fragment specifies the expected content contained within this class. - * + * * <pre> * <complexType> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="request-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="action" type="{http://ecomp.att.com/mso/infra/vnf-request/v1}action-type"/> - * <element name="request-status" type="{http://ecomp.att.com/mso/infra/vnf-request/v1}request-status-type" minOccurs="0"/> + * <element name="action" type="{http://org.openecomp/mso/infra/vnf-request/v1}action-type"/> + * <element name="request-status" type="{http://org.openecomp/mso/infra/vnf-request/v1}request-status-type" minOccurs="0"/> * <element name="status-message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * <element name="progress" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/> * <element name="start-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> @@ -59,8 +58,8 @@ import javax.xml.bind.annotation.XmlType; * </complexContent> * </complexType> * </pre> - * - * + * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -93,11 +92,11 @@ public class RequestInfo { /** * Gets the value of the requestId property. - * + * * @return * possible object is * {@link String } - * + * */ public String getRequestId() { return requestId; @@ -105,11 +104,11 @@ public class RequestInfo { /** * Sets the value of the requestId property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setRequestId(String value) { this.requestId = value; @@ -117,11 +116,11 @@ public class RequestInfo { /** * Gets the value of the action property. - * + * * @return * possible object is * {@link ActionType } - * + * */ public ActionType getAction() { return action; @@ -129,11 +128,11 @@ public class RequestInfo { /** * Sets the value of the action property. - * + * * @param value * allowed object is * {@link ActionType } - * + * */ public void setAction(ActionType value) { this.action = value; @@ -141,11 +140,11 @@ public class RequestInfo { /** * Gets the value of the requestStatus property. - * + * * @return * possible object is * {@link RequestStatusType } - * + * */ public RequestStatusType getRequestStatus() { return requestStatus; @@ -153,11 +152,11 @@ public class RequestInfo { /** * Sets the value of the requestStatus property. - * + * * @param value * allowed object is * {@link RequestStatusType } - * + * */ public void setRequestStatus(RequestStatusType value) { this.requestStatus = value; @@ -165,11 +164,11 @@ public class RequestInfo { /** * Gets the value of the statusMessage property. - * + * * @return * possible object is * {@link String } - * + * */ public String getStatusMessage() { return statusMessage; @@ -177,11 +176,11 @@ public class RequestInfo { /** * Sets the value of the statusMessage property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setStatusMessage(String value) { this.statusMessage = value; @@ -189,11 +188,11 @@ public class RequestInfo { /** * Gets the value of the progress property. - * + * * @return * possible object is * {@link Integer } - * + * */ public Integer getProgress() { return progress; @@ -201,11 +200,11 @@ public class RequestInfo { /** * Sets the value of the progress property. - * + * * @param value * allowed object is * {@link Integer } - * + * */ public void setProgress(Integer value) { this.progress = value; @@ -213,11 +212,11 @@ public class RequestInfo { /** * Gets the value of the startTime property. - * + * * @return * possible object is * {@link String } - * + * */ public String getStartTime() { return startTime; @@ -225,11 +224,11 @@ public class RequestInfo { /** * Sets the value of the startTime property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setStartTime(String value) { this.startTime = value; @@ -237,11 +236,11 @@ public class RequestInfo { /** * Gets the value of the endTime property. - * + * * @return * possible object is * {@link String } - * + * */ public String getEndTime() { return endTime; @@ -249,11 +248,11 @@ public class RequestInfo { /** * Sets the value of the endTime property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setEndTime(String value) { this.endTime = value; @@ -261,11 +260,11 @@ public class RequestInfo { /** * Gets the value of the source property. - * + * * @return * possible object is * {@link String } - * + * */ public String getSource() { return source; @@ -273,11 +272,11 @@ public class RequestInfo { /** * Sets the value of the source property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSource(String value) { this.source = value; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/package-info.java index 54fb497..b112191 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/package-info.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/package-info.java @@ -25,6 +25,6 @@ // Generated on: 2015.09.03 at 02:02:13 PM EDT // -@javax.xml.bind.annotation.XmlSchema(namespace = "http://ecomp.att.com/mso/infra/network-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/mso/infra/network-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.openecomp.mso.apihandlerinfra.networkbeans; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/package-info.java index 9225523..1d58fb8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/package-info.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/package-info.java @@ -25,6 +25,6 @@ // Generated on: 2015.01.08 at 03:50:12 PM EST // -@javax.xml.bind.annotation.XmlSchema(namespace = "http://ecomp.att.com/mso/request/types/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/mso/request/types/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.openecomp.mso.apihandlerinfra; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/CloudConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/CloudConfiguration.java index a9f7f7a..777c945 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/CloudConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/CloudConfiguration.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,11 +31,11 @@ public class CloudConfiguration { /** * Gets the value of the aicNodeClli property. - * + * * @return * possible object is * {@link String } - * + * */ public String getAicNodeClli() { return aicNodeClli; @@ -43,11 +43,11 @@ public class CloudConfiguration { /** * Sets the value of the aicNodeClli property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setAicNodeClli(String value) { this.aicNodeClli = value; @@ -55,11 +55,11 @@ public class CloudConfiguration { /** * Gets the value of the tenantId property. - * + * * @return * possible object is * {@link String } - * + * */ public String getTenantId() { return tenantId; @@ -67,16 +67,16 @@ public class CloudConfiguration { /** * Sets the value of the tenantId property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setTenantId(String value) { this.tenantId = value; } - + public String getLcpCloudRegionId() { return lcpCloudRegionId; @@ -85,6 +85,12 @@ public class CloudConfiguration { public void setLcpCloudRegionId(String lcpCloudRegionId) { this.lcpCloudRegionId = lcpCloudRegionId; } - + + @Override + public String toString() { + return "CloudConfiguration [aicNodeClli=" + aicNodeClli + ", tenantId=" + + tenantId + ", lcpCloudRegionId=" + lcpCloudRegionId + "]"; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/InstanceReferences.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/InstanceReferences.java index fd5c73f..8f453c8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/InstanceReferences.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/InstanceReferences.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import org.codehaus.jackson.map.annotate.JsonSerialize; @JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) public class InstanceReferences { - + protected String serviceInstanceId; protected String serviceInstanceName; protected String vnfInstanceId; @@ -35,8 +35,9 @@ public class InstanceReferences { protected String volumeGroupInstanceName; protected String networkInstanceId; protected String networkInstanceName; - - + protected String requestorId; + + public String getServiceInstanceId() { return serviceInstanceId; } @@ -97,7 +98,12 @@ public class InstanceReferences { public void setNetworkInstanceName(String networkInstanceName) { this.networkInstanceName = networkInstanceName; } - + public String getRequestorId() { + return requestorId; + } + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ModelInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ModelInfo.java index e361b1d..f542d63 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ModelInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ModelInfo.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2016.03.30 at 02:48:23 PM CDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.7 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2016.03.30 at 02:48:23 PM CDT // @@ -38,11 +38,16 @@ public class ModelInfo { protected String modelCustomizationName; protected String modelInvariantId; protected ModelType modelType; + //v2 protected String modelNameVersionId; protected String modelName; protected String modelVersion; - - + protected String modelCustomizationUuid; + //v3 + protected String modelVersionId; + protected String modelCustomizationId; + + public String getModelCustomizationName() { return modelCustomizationName; } @@ -79,6 +84,34 @@ public class ModelInfo { public void setModelInvariantId(String modelInvariantId) { this.modelInvariantId = modelInvariantId; } - + public String getModelCustomizationUuid() { + return modelCustomizationUuid; + } + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getModelVersionId() { + return modelVersionId; + } + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + public String getModelCustomizationId() { + return modelCustomizationId; + } + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } + @Override + public String toString() { + return "ModelInfo [modelCustomizationName=" + modelCustomizationName + + ", modelInvariantId=" + modelInvariantId + ", modelType=" + + modelType + ", modelNameVersionId=" + modelNameVersionId + + ", modelName=" + modelName + ", modelVersion=" + modelVersion + + ", modelCustomizationUuid=" + modelCustomizationUuid + + ", modelVersionId=" + modelVersionId + + ", modelCustomizationId=" + modelCustomizationId + "]"; + } + -} +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/PolicyException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/PolicyException.java index 4d336c4..5aed50e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/PolicyException.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/PolicyException.java @@ -41,7 +41,7 @@ import javax.xml.bind.annotation.XmlType; * <pre> * <complexType name="policyException"> * <complexContent> - * <extension base="{http://ecomp.att.com/mso/request/types/v1}exceptionType"> + * <extension base="{http://org.openecomp/mso/request/types/v1}exceptionType"> * </extension> * </complexContent> * </complexType> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstanceList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstanceList.java index 1244d3b..b60d4b6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstanceList.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstanceList.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,7 @@ package org.openecomp.mso.apihandlerinfra.serviceinstancebeans; public class RelatedInstanceList { - + protected RelatedInstance relatedInstance; public RelatedInstance getRelatedInstance() { @@ -32,6 +32,11 @@ public class RelatedInstanceList { this.relatedInstance = relatedInstance; } + @Override + public String toString() { + return "RelatedInstanceList [relatedInstance=" + relatedInstance + "]"; + } + + - } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestDetails.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestDetails.java index de6cbb7..bb1fa3b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestDetails.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestDetails.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,8 @@ package org.openecomp.mso.apihandlerinfra.serviceinstancebeans; +import java.util.Arrays; + import org.codehaus.jackson.map.annotate.JsonRootName; import org.codehaus.jackson.map.annotate.JsonSerialize; @@ -36,11 +38,11 @@ public class RequestDetails { /** * Gets the value of the serviceInfo property. - * + * * @return * possible object is * {@link ModelInfo } - * + * */ public ModelInfo getModelInfo() { return modelInfo; @@ -48,11 +50,11 @@ public class RequestDetails { /** * Sets the value of the serviceInfo property. - * + * * @param value * allowed object is * {@link ModelInfo } - * + * */ public void setModelInfo(ModelInfo value) { this.modelInfo = value; @@ -60,11 +62,11 @@ public class RequestDetails { /** * Gets the value of the requestInfo property. - * + * * @return * possible object is * {@link RequestInfo } - * + * */ public RequestInfo getRequestInfo() { return requestInfo; @@ -72,11 +74,11 @@ public class RequestDetails { /** * Sets the value of the requestInfo property. - * + * * @param value * allowed object is * {@link RequestInfo } - * + * */ public void setRequestInfo(RequestInfo value) { this.requestInfo = value; @@ -84,11 +86,11 @@ public class RequestDetails { /** * Gets the value of the subscriberInfo property. - * + * * @return * possible object is * {@link SubscriberInfo } - * + * */ public SubscriberInfo getSubscriberInfo() { return subscriberInfo; @@ -96,11 +98,11 @@ public class RequestDetails { /** * Sets the value of the subscriberInfo property. - * + * * @param value * allowed object is * {@link SubscriberInfo } - * + * */ public void setSubscriberInfo(SubscriberInfo value) { this.subscriberInfo = value; @@ -108,11 +110,11 @@ public class RequestDetails { /** * Gets the value of the cloudConfiguration property. - * + * * @return * possible object is * {@link CloudConfiguration } - * + * */ public CloudConfiguration getCloudConfiguration() { return cloudConfiguration; @@ -120,11 +122,11 @@ public class RequestDetails { /** * Sets the value of the cloudConfiguration property. - * + * * @param value * allowed object is * {@link CloudConfiguration } - * + * */ public void setCloudConfiguration(CloudConfiguration value) { this.cloudConfiguration = value; @@ -132,11 +134,11 @@ public class RequestDetails { /** * Gets the value of the requestParameters property. - * + * * @return * possible object is * {@link RequestParameters } - * + * */ public RequestParameters getRequestParameters() { return requestParameters; @@ -144,11 +146,11 @@ public class RequestDetails { /** * Sets the value of the requestParameters property. - * + * * @param value * allowed object is * {@link RequestParameters } - * + * */ public void setRequestParameters(RequestParameters value) { this.requestParameters = value; @@ -162,4 +164,13 @@ public class RequestDetails { this.relatedInstanceList = relatedInstanceList; } + @Override + public String toString() { + return "RequestDetails [modelInfo=" + modelInfo + ", requestInfo=" + + requestInfo + ", relatedInstanceList=" + + Arrays.toString(relatedInstanceList) + ", subscriberInfo=" + + subscriberInfo + ", cloudConfiguration=" + cloudConfiguration + + ", requestParameters=" + requestParameters + "]"; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestError.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestError.java index 3a27238..db2f165 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestError.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestError.java @@ -45,8 +45,8 @@ import javax.xml.bind.annotation.XmlType; * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <choice> - * <element name="policyException" type="{http://ecomp.att.com/mso/request/types/v1}policyException"/> - * <element name="serviceException" type="{http://ecomp.att.com/mso/request/types/v1}serviceException"/> + * <element name="policyException" type="{http://org.openecomp/mso/request/types/v1}policyException"/> + * <element name="serviceException" type="{http://org.openecomp/mso/request/types/v1}serviceException"/> * </choice> * </sequence> * </restriction> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestInfo.java index e5f3167..69c0dfc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestInfo.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,6 +21,7 @@ package org.openecomp.mso.apihandlerinfra.serviceinstancebeans; import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; @JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) public class RequestInfo { @@ -33,15 +34,17 @@ public class RequestInfo { protected Integer orderVersion; protected String source; protected String instanceName; + @JsonSerialize(include=Inclusion.ALWAYS) protected boolean suppressRollback; + protected String requestorId; /** * Gets the value of the callbackUrl property. - * + * * @return * possible object is * {@link String } - * + * */ public String getCallbackUrl() { return callbackUrl; @@ -49,11 +52,11 @@ public class RequestInfo { /** * Sets the value of the callbackUrl property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setCallbackUrl(String value) { this.callbackUrl = value; @@ -61,11 +64,11 @@ public class RequestInfo { /** * Gets the value of the correlator property. - * + * * @return * possible object is * {@link String } - * + * */ public String getCorrelator() { return correlator; @@ -73,11 +76,11 @@ public class RequestInfo { /** * Sets the value of the correlator property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setCorrelator(String value) { this.correlator = value; @@ -85,11 +88,11 @@ public class RequestInfo { /** * Gets the value of the orderNumber property. - * + * * @return * possible object is * {@link String } - * + * */ public String getOrderNumber() { return orderNumber; @@ -97,11 +100,11 @@ public class RequestInfo { /** * Sets the value of the orderNumber property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setOrderNumber(String value) { this.orderNumber = value; @@ -109,11 +112,11 @@ public class RequestInfo { /** * Gets the value of the orderVersion property. - * + * * @return * possible object is * {@link Integer } - * + * */ public Integer getOrderVersion() { return orderVersion; @@ -121,11 +124,11 @@ public class RequestInfo { /** * Sets the value of the orderVersion property. - * + * * @param value * allowed object is * {@link Integer } - * + * */ public void setOrderVersion(Integer value) { this.orderVersion = value; @@ -133,11 +136,11 @@ public class RequestInfo { /** * Gets the value of the source property. - * + * * @return * possible object is * {@link String } - * + * */ public String getSource() { return source; @@ -145,11 +148,11 @@ public class RequestInfo { /** * Sets the value of the source property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSource(String value) { this.source = value; @@ -179,13 +182,36 @@ public class RequestInfo { this.productFamilyId = productFamilyId; } - public boolean isSuppressRollback() { + /** + * Required for Marshalers to send the fields. + * @return + */ + public boolean getSuppressRollback() { return suppressRollback; } public void setSuppressRollback(boolean suppressRollback) { this.suppressRollback = suppressRollback; } - + + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + + @Override + public String toString() { + return "RequestInfo [billingAccountNumber=" + billingAccountNumber + + ", callbackUrl=" + callbackUrl + ", correlator=" + correlator + + ", orderNumber=" + orderNumber + ", productFamilyId=" + + productFamilyId + ", orderVersion=" + orderVersion + + ", source=" + source + ", instanceName=" + instanceName + + ", suppressRollback=" + suppressRollback + ", requestorId=" + + requestorId + "]"; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java index 1a82040..dee0649 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,13 +25,25 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; + +import org.openecomp.mso.apihandlerinfra.MsoRequest; @JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) public class RequestParameters { private String subscriptionServiceType; private List<Map<String, String>> userParams = new ArrayList<>(); + @JsonSerialize(include=Inclusion.ALWAYS) + private boolean aLaCarte = false; + @JsonIgnore + private boolean isALaCarteSet = false; + @JsonSerialize(include=Inclusion.ALWAYS) + private boolean autoBuildVfModules = false; + @JsonSerialize(include=Inclusion.ALWAYS) + private boolean cascadeDelete = false; public String getSubscriptionServiceType() { @@ -42,6 +54,24 @@ public class RequestParameters { this.subscriptionServiceType = subscriptionServiceType; } + public boolean getALaCarte() { + return aLaCarte; + } + + public void setaLaCarte(boolean aLaCarte) { + this.aLaCarte = aLaCarte; + this.isALaCarteSet = true; + } + + //returns true if aLaCarte param came in on request + public boolean isALaCarteSet() { + return isALaCarteSet; + } + + public boolean isaLaCarte() { + return aLaCarte; + } + public List<Map<String, String>> getUserParams() { return userParams; } @@ -50,5 +80,40 @@ public class RequestParameters { this.userParams = userParams; } + public String getUserParamValue(String name){ + if(userParams!=null){ + for(Map<String, String> param:userParams){ + if(param.get("name").equals(name)){ + return param.get("value"); + } + } + } + return null; + } + + public boolean getAutoBuildVfModules() { + return autoBuildVfModules; + } + + public void setAutoBuildVfModules(boolean autoBuildVfModules) { + this.autoBuildVfModules = autoBuildVfModules; + } + + public boolean getCascadeDelete() { + return cascadeDelete; + } + + public void setCascadeDelete(boolean cascadeDelete) { + this.cascadeDelete = cascadeDelete; + } + + @Override + public String toString() { + return "RequestParameters [subscriptionServiceType=" + + subscriptionServiceType + ", userParams=" + userParams + + ", aLaCarte=" + aLaCarte + ", autoBuildVfModules=" + + autoBuildVfModules + "]"; + } + -} +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestStatus.java index a9bf5e8..89e8075 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestStatus.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestStatus.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,8 +31,8 @@ public class RequestStatus { protected String statusMessage; protected Integer percentProgress; protected String finishTime; - - + + public String getRequestState() { return requestState; } @@ -57,5 +57,4 @@ public class RequestStatus { public void setFinishTime(String finishTime) { this.finishTime = finishTime; } - -} +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceException.java index f207e96..b3c01d0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceException.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceException.java @@ -41,7 +41,7 @@ import javax.xml.bind.annotation.XmlType; * <pre> * <complexType name="serviceException"> * <complexContent> - * <extension base="{http://ecomp.att.com/mso/request/types/v1}exceptionType"> + * <extension base="{http://org.openecomp/mso/request/types/v1}exceptionType"> * </extension> * </complexContent> * </complexType> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceInstancesRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceInstancesRequest.java index 30903b9..2281f2e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceInstancesRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceInstancesRequest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -78,6 +78,15 @@ public class ServiceInstancesRequest { public void setVfModuleInstanceId(String vfModuleInstanceId) { this.vfModuleInstanceId = vfModuleInstanceId; } - -} + @Override + public String toString() { + return "ServiceInstancesRequest [requestDetails=" + requestDetails + + ", serviceInstanceId=" + serviceInstanceId + + ", vnfInstanceId=" + vnfInstanceId + ", networkInstanceId=" + + networkInstanceId + ", volumeGroupInstanceId=" + + volumeGroupInstanceId + ", vfModuleInstanceId=" + + vfModuleInstanceId + "]"; + } + +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java index bf7a044..97fc496 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,11 +30,11 @@ public class SubscriberInfo { /** * Gets the value of the globalSubscriberId property. - * + * * @return * possible object is * {@link String } - * + * */ public String getGlobalSubscriberId() { return globalSubscriberId; @@ -42,11 +42,11 @@ public class SubscriberInfo { /** * Sets the value of the globalSubscriberId property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setGlobalSubscriberId(String value) { this.globalSubscriberId = value; @@ -54,11 +54,11 @@ public class SubscriberInfo { /** * Gets the value of the subscriberName property. - * + * * @return * possible object is * {@link String } - * + * */ public String getSubscriberName() { return subscriberName; @@ -66,14 +66,20 @@ public class SubscriberInfo { /** * Sets the value of the subscriberName property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSubscriberName(String value) { this.subscriberName = value; } + @Override + public String toString() { + return "SubscriberInfo [globalSubscriberId=" + globalSubscriberId + + ", subscriberName=" + subscriberName + "]"; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java index b1c000f..e86d2bb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java @@ -52,8 +52,8 @@ import javax.xml.namespace.QName; @XmlRegistry public class ObjectFactory { - private final static QName _VnfParams_QNAME = new QName("http://ecomp.att.com/mso/infra/vnf-request/v1", "vnf-params"); - private final static QName _NetworkParams_QNAME = new QName("http://ecomp.att.com/mso/infra/vnf-request/v1", "network-params"); + private final static QName _VnfParams_QNAME = new QName("http://org.openecomp/mso/infra/vnf-request/v1", "vnf-params"); + private final static QName _NetworkParams_QNAME = new QName("http://org.openecomp/mso/infra/vnf-request/v1", "network-params"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.apihandlerinfra.vnfbeans1 @@ -142,7 +142,7 @@ public class ObjectFactory { * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} * */ - @XmlElementDecl(namespace = "http://ecomp.att.com/mso/infra/vnf-request/v1", name = "vnf-params") + @XmlElementDecl(namespace = "http://org.openecomp/mso/infra/vnf-request/v1", name = "vnf-params") public JAXBElement<Object> createVnfParams(Object value) { return new JAXBElement<Object>(_VnfParams_QNAME, Object.class, null, value); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestInfo.java index cb8973b..e9f88ab 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestInfo.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -38,17 +38,17 @@ import javax.xml.bind.annotation.XmlType; /** * <p>Java class for anonymous complex type. - * + * * <p>The following schema fragment specifies the expected content contained within this class. - * + * * <pre> * <complexType> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="request-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="action" type="{http://ecomp.att.com/mso/infra/vnf-request/v1}action-type"/> - * <element name="request-status" type="{http://ecomp.att.com/mso/infra/vnf-request/v1}request-status-type" minOccurs="0"/> + * <element name="action" type="{http://org.openecomp/mso/infra/vnf-request/v1}action-type"/> + * <element name="request-status" type="{http://org.openecomp/mso/infra/vnf-request/v1}request-status-type" minOccurs="0"/> * <element name="status-message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * <element name="progress" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/> * <element name="start-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> @@ -59,8 +59,8 @@ import javax.xml.bind.annotation.XmlType; * </complexContent> * </complexType> * </pre> - * - * + * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -93,11 +93,11 @@ public class RequestInfo { /** * Gets the value of the requestId property. - * + * * @return * possible object is * {@link String } - * + * */ public String getRequestId() { return requestId; @@ -105,11 +105,11 @@ public class RequestInfo { /** * Sets the value of the requestId property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setRequestId(String value) { this.requestId = value; @@ -117,11 +117,11 @@ public class RequestInfo { /** * Gets the value of the action property. - * + * * @return * possible object is * {@link ActionType } - * + * */ public ActionType getAction() { return action; @@ -129,11 +129,11 @@ public class RequestInfo { /** * Sets the value of the action property. - * + * * @param value * allowed object is * {@link ActionType } - * + * */ public void setAction(ActionType value) { this.action = value; @@ -141,11 +141,11 @@ public class RequestInfo { /** * Gets the value of the requestStatus property. - * + * * @return * possible object is * {@link RequestStatusType } - * + * */ public RequestStatusType getRequestStatus() { return requestStatus; @@ -153,11 +153,11 @@ public class RequestInfo { /** * Sets the value of the requestStatus property. - * + * * @param value * allowed object is * {@link RequestStatusType } - * + * */ public void setRequestStatus(RequestStatusType value) { this.requestStatus = value; @@ -165,11 +165,11 @@ public class RequestInfo { /** * Gets the value of the statusMessage property. - * + * * @return * possible object is * {@link String } - * + * */ public String getStatusMessage() { return statusMessage; @@ -177,11 +177,11 @@ public class RequestInfo { /** * Sets the value of the statusMessage property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setStatusMessage(String value) { this.statusMessage = value; @@ -189,11 +189,11 @@ public class RequestInfo { /** * Gets the value of the progress property. - * + * * @return * possible object is * {@link Integer } - * + * */ public Integer getProgress() { return progress; @@ -201,11 +201,11 @@ public class RequestInfo { /** * Sets the value of the progress property. - * + * * @param value * allowed object is * {@link Integer } - * + * */ public void setProgress(Integer value) { this.progress = value; @@ -213,11 +213,11 @@ public class RequestInfo { /** * Gets the value of the startTime property. - * + * * @return * possible object is * {@link String } - * + * */ public String getStartTime() { return startTime; @@ -225,11 +225,11 @@ public class RequestInfo { /** * Sets the value of the startTime property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setStartTime(String value) { this.startTime = value; @@ -237,11 +237,11 @@ public class RequestInfo { /** * Gets the value of the endTime property. - * + * * @return * possible object is * {@link String } - * + * */ public String getEndTime() { return endTime; @@ -249,11 +249,11 @@ public class RequestInfo { /** * Sets the value of the endTime property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setEndTime(String value) { this.endTime = value; @@ -261,11 +261,11 @@ public class RequestInfo { /** * Gets the value of the source property. - * + * * @return * possible object is * {@link String } - * + * */ public String getSource() { return source; @@ -273,11 +273,11 @@ public class RequestInfo { /** * Sets the value of the source property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSource(String value) { this.source = value; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestStatusType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestStatusType.java index 4698c78..a8fa78b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestStatusType.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestStatusType.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -35,7 +35,7 @@ import javax.xml.bind.annotation.XmlType; /** * <p>Java class for request-status-type. - * + * * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> @@ -47,7 +47,7 @@ import javax.xml.bind.annotation.XmlType; * </restriction> * </simpleType> * </pre> - * + * */ @XmlType(name = "request-status-type") @XmlEnum @@ -57,7 +57,8 @@ public enum RequestStatusType { FAILED, IN_PROGRESS, PENDING, - TIMEOUT; + TIMEOUT, + UNLOCKED; public String value() { return name(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java index 790a5e8..099a33d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java @@ -48,7 +48,7 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vf-module-model-name" maxOccurs="unbounded" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vf-module-model-name" maxOccurs="unbounded" minOccurs="0"/> * </sequence> * </restriction> * </complexContent> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequest.java index bd210a5..8d0fdcc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequest.java @@ -46,11 +46,11 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}request-info"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}request-info"/> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vnf-inputs"/> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vnf-params" minOccurs="0"/> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vnf-outputs" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-inputs"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-params" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-outputs" minOccurs="0"/> * </sequence> * </sequence> * </restriction> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java index 65aa9c1..1ae2297 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java @@ -48,7 +48,7 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vnf-request" maxOccurs="unbounded" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-request" maxOccurs="unbounded" minOccurs="0"/> * </sequence> * </restriction> * </complexContent> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java index 473695c..9b966cd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java @@ -48,7 +48,7 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vnf-type" maxOccurs="unbounded" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/vnf-request/v1}vnf-type" maxOccurs="unbounded" minOccurs="0"/> * </sequence> * </restriction> * </complexContent> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java index 700d7a9..aa60961 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java @@ -25,6 +25,6 @@ // Generated on: 2015.09.03 at 02:02:13 PM EDT // -@javax.xml.bind.annotation.XmlSchema(namespace = "http://ecomp.att.com/mso/infra/vnf-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/mso/infra/vnf-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.openecomp.mso.apihandlerinfra.vnfbeans; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java index 24b620e..3344d8d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java @@ -52,7 +52,7 @@ import javax.xml.namespace.QName; @XmlRegistry public class ObjectFactory { - private final static QName _VolumeParams_QNAME = new QName("http://ecomp.att.com/mso/infra/volume-request/v1", "volume-params"); + private final static QName _VolumeParams_QNAME = new QName("http://org.openecomp/mso/infra/volume-request/v1", "volume-params"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.apihandlerinfra.vnfbeans1 @@ -107,7 +107,7 @@ public class ObjectFactory { * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} * */ - @XmlElementDecl(namespace = "http://ecomp.att.com/mso/infra/volume-request/v1", name = "volume-params") + @XmlElementDecl(namespace = "http://org.openecomp/mso/infra/volume-request/v1", name = "volume-params") public JAXBElement<Object> createVolumeParams(Object value) { return new JAXBElement<Object>(_VolumeParams_QNAME, Object.class, null, value); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfo.java index 40e809c..4dfa4a6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfo.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -38,17 +38,17 @@ import javax.xml.bind.annotation.XmlType; /** * <p>Java class for anonymous complex type. - * + * * <p>The following schema fragment specifies the expected content contained within this class. - * + * * <pre> * <complexType> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="request-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> - * <element name="action" type="{http://ecomp.att.com/mso/infra/vnf-request/v1}action-type"/> - * <element name="request-status" type="{http://ecomp.att.com/mso/infra/vnf-request/v1}request-status-type" minOccurs="0"/> + * <element name="action" type="{http://org.openecomp/mso/infra/vnf-request/v1}action-type"/> + * <element name="request-status" type="{http://org.openecomp/mso/infra/vnf-request/v1}request-status-type" minOccurs="0"/> * <element name="status-message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * <element name="progress" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/> * <element name="start-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> @@ -59,8 +59,8 @@ import javax.xml.bind.annotation.XmlType; * </complexContent> * </complexType> * </pre> - * - * + * + * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { @@ -93,11 +93,11 @@ public class RequestInfo { /** * Gets the value of the requestId property. - * + * * @return * possible object is * {@link String } - * + * */ public String getRequestId() { return requestId; @@ -105,11 +105,11 @@ public class RequestInfo { /** * Sets the value of the requestId property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setRequestId(String value) { this.requestId = value; @@ -117,11 +117,11 @@ public class RequestInfo { /** * Gets the value of the action property. - * + * * @return * possible object is * {@link ActionType } - * + * */ public ActionType getAction() { return action; @@ -129,11 +129,11 @@ public class RequestInfo { /** * Sets the value of the action property. - * + * * @param value * allowed object is * {@link ActionType } - * + * */ public void setAction(ActionType value) { this.action = value; @@ -141,11 +141,11 @@ public class RequestInfo { /** * Gets the value of the requestStatus property. - * + * * @return * possible object is * {@link RequestStatusType } - * + * */ public RequestStatusType getRequestStatus() { return requestStatus; @@ -153,11 +153,11 @@ public class RequestInfo { /** * Sets the value of the requestStatus property. - * + * * @param value * allowed object is * {@link RequestStatusType } - * + * */ public void setRequestStatus(RequestStatusType value) { this.requestStatus = value; @@ -165,11 +165,11 @@ public class RequestInfo { /** * Gets the value of the statusMessage property. - * + * * @return * possible object is * {@link String } - * + * */ public String getStatusMessage() { return statusMessage; @@ -177,11 +177,11 @@ public class RequestInfo { /** * Sets the value of the statusMessage property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setStatusMessage(String value) { this.statusMessage = value; @@ -189,11 +189,11 @@ public class RequestInfo { /** * Gets the value of the progress property. - * + * * @return * possible object is * {@link Integer } - * + * */ public Integer getProgress() { return progress; @@ -201,11 +201,11 @@ public class RequestInfo { /** * Sets the value of the progress property. - * + * * @param value * allowed object is * {@link Integer } - * + * */ public void setProgress(Integer value) { this.progress = value; @@ -213,11 +213,11 @@ public class RequestInfo { /** * Gets the value of the startTime property. - * + * * @return * possible object is * {@link String } - * + * */ public String getStartTime() { return startTime; @@ -225,11 +225,11 @@ public class RequestInfo { /** * Sets the value of the startTime property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setStartTime(String value) { this.startTime = value; @@ -237,11 +237,11 @@ public class RequestInfo { /** * Gets the value of the endTime property. - * + * * @return * possible object is * {@link String } - * + * */ public String getEndTime() { return endTime; @@ -249,11 +249,11 @@ public class RequestInfo { /** * Sets the value of the endTime property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setEndTime(String value) { this.endTime = value; @@ -261,11 +261,11 @@ public class RequestInfo { /** * Gets the value of the source property. - * + * * @return * possible object is * {@link String } - * + * */ public String getSource() { return source; @@ -273,11 +273,11 @@ public class RequestInfo { /** * Sets the value of the source property. - * + * * @param value * allowed object is * {@link String } - * + * */ public void setSource(String value) { this.source = value; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequest.java index 9ec3d7e..d67d8c9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequest.java @@ -46,11 +46,11 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/volume-request/v1}request-info"/> + * <element ref="{http://org.openecomp/mso/infra/volume-request/v1}request-info"/> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/volume-request/v1}volume-inputs"/> - * <element ref="{http://ecomp.att.com/mso/infra/volume-request/v1}volume-params" minOccurs="0"/> - * <element ref="{http://ecomp.att.com/mso/infra/volume-request/v1}volume-outputs" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/volume-request/v1}volume-inputs"/> + * <element ref="{http://org.openecomp/mso/infra/volume-request/v1}volume-params" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/volume-request/v1}volume-outputs" minOccurs="0"/> * </sequence> * </sequence> * </restriction> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java index 04fc16e..432df99 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java @@ -48,7 +48,7 @@ import javax.xml.bind.annotation.XmlType; * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> - * <element ref="{http://ecomp.att.com/mso/infra/volume-request/v1}volume-request" maxOccurs="unbounded" minOccurs="0"/> + * <element ref="{http://org.openecomp/mso/infra/volume-request/v1}volume-request" maxOccurs="unbounded" minOccurs="0"/> * </sequence> * </restriction> * </complexContent> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/package-info.java index 3678024..da9b178 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/package-info.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/package-info.java @@ -25,6 +25,6 @@ // Generated on: 2015.09.03 at 02:02:13 PM EDT // -@javax.xml.bind.annotation.XmlSchema(namespace = "http://ecomp.att.com/mso/infra/volume-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.openecomp/mso/infra/volume-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.openecomp.mso.apihandlerinfra.volumebeans; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-feature-request.xml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-feature-request.xml index aacab0b..00ea3fe 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-feature-request.xml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-feature-request.xml @@ -19,14 +19,14 @@ --> <feature-request - xmlns="http://ecomp.att.com/mso/request/layer3serviceactivate/schema/v1" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:msolayer3="http://ecomp.att.com/mso/request/layer3/schema/v1" - xmlns:msoservtypes="http://ecomp.att.com/mso/request/types/v1"> + xmlns="http://org.openecomp/mso/request/layer3serviceactivate/schema/v1" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:msolayer3="http://org.openecomp/mso/request/layer3/schema/v1" + xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"> <msoservtypes:request-information> <msoservtypes:request-id>155415ab-b4a7-4382-b4c6-d17d950565</msoservtypes:request-id> <msoservtypes:request-action>ChangeFeatureActivateRequest</msoservtypes:request-action> <msoservtypes:source>OMX</msoservtypes:source> - <msoservtypes:notification-url>https://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</msoservtypes:notification-url> + <msoservtypes:notification-url>https://localhost:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</msoservtypes:notification-url> <msoservtypes:order-number>5051560</msoservtypes:order-number> <msoservtypes:order-version>1</msoservtypes:order-version> </msoservtypes:request-information> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-service-request.xml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-service-request.xml index 1e49583..3186ae4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-service-request.xml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-service-request.xml @@ -22,17 +22,17 @@ --> <tns:service-request xmlns:p="urn:ietf:params:xml:ns:yang:ietf-inet-types" -xmlns:tns="http://ecomp.att.com/mso/request/changelayer3activate/schema/v1" -xmlns:tns1="http://ecomp.att.com/mso/request/types/v1" -xmlns:msolayer3="http://ecomp.att.com/mso/request/layer3/schema/v1" -xmlns:tns3="http://ecomp.att.com/mso/layer3/simple/types/v1" +xmlns:tns="http://org.openecomp/mso/request/changelayer3activate/schema/v1" +xmlns:tns1="http://org.openecomp/mso/request/types/v1" +xmlns:msolayer3="http://org.openecomp/mso/request/layer3/schema/v1" +xmlns:tns3="http://org.openecomp/mso/layer3/simple/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <tns1:request-information> <tns1:request-id>ChgActsm519-500</tns1:request-id> <tns1:request-action>ChangeLayer3ServiceActivateRequest</tns1:request-action> <tns1:source>OMX</tns1:source> - <tns1:notification-url>https://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNot + <tns1:notification-url>https://localhost:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNot ification.jws</tns1:notification-url> <tns1:order-number>051815-1005</tns1:order-number> <tns1:order-version>2</tns1:order-version> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/feature-request.xml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/feature-request.xml index b652a62..edcfc04 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/feature-request.xml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/feature-request.xml @@ -19,7 +19,7 @@ ============LICENSE_END========================================================= --> -<tns:feature-request xmlns:tns="http://ecomp.att.com/mso/request/schema/v1" xmlns:tns1="http://ecomp.att.com/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ecomp.att.com/mso/request/schema/v1 MsoRequestV1.xsd"> +<tns:feature-request xmlns:tns="http://org.openecomp/mso/request/schema/v1" xmlns:tns1="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/schema/v1 MsoRequestV1.xsd"> <tns1:request-information> <tns1:request-id>tns1:request-id</tns1:request-id> <tns1:request-action>Layer3ServiceActivateRequest</tns1:request-action> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/service-request.xml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/service-request.xml index b9f70a0..c905eeb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/service-request.xml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/service-request.xml @@ -19,7 +19,7 @@ ============LICENSE_END========================================================= --> -<tns:service-request xmlns:tns="http://ecomp.att.com/mso/request/schema/v1" xmlns:tns1="http://ecomp.att.com/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ecomp.att.com/mso/request/schema/v1 MsoRequestV1.xsd "> +<tns:service-request xmlns:tns="http://org.openecomp/mso/request/schema/v1" xmlns:tns1="http://org.openecomp/mso/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.openecomp/mso/request/schema/v1 MsoRequestV1.xsd "> <tns1:request-information> <tns1:request-id>tns1:request-id</tns1:request-id> <tns1:request-action>Layer3ServiceActivateRequest</tns1:request-action> diff --git a/mso-api-handlers/mso-requests-db/pom.xml b/mso-api-handlers/mso-requests-db/pom.xml index 2d9cc89..63520f0 100644 --- a/mso-api-handlers/mso-requests-db/pom.xml +++ b/mso-api-handlers/mso-requests-db/pom.xml @@ -96,7 +96,6 @@ <artifactId>hibernate-jpa-2.1-api</artifactId> <version>1.0.0.Final</version> </dependency> - <dependency> <groupId>org.openecomp.mso</groupId> <artifactId>common</artifactId> @@ -107,17 +106,7 @@ <build> <finalName>${project.artifactId}</finalName> <plugins> - - <plugin> - <artifactId>maven-war-plugin</artifactId> - <version>2.3</version> - <configuration> - <warSourceDirectory>WebContent</warSourceDirectory> - <failOnMissingWebXml>false</failOnMissingWebXml> - </configuration> - </plugin> - - <plugin> + <plugin> <groupId>de.juplo</groupId> <artifactId>hibernate4-maven-plugin</artifactId> <version>1.1.0</version> diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/HibernateUtil.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/HibernateUtil.java deleted file mode 100644 index 21bece9..0000000 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/HibernateUtil.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.requestsdb; - - -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -@SuppressWarnings("deprecation") -public class HibernateUtil { - - //private static SessionFactory SESSION_FACTORY; - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - - private static SessionFactory SESSION_FACTORY; - - - static { - try { - - if ("MYSQL".equals (System.getProperty ("mso.db")) || "MARIADB".equals(System.getProperty("mso.db"))) { - SESSION_FACTORY = new Configuration ().configure ("hibernate-mysql.cfg.xml").buildSessionFactory (); - } else { - LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC", "", "", MsoLogger.ErrorCode.DataError , "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC"); - } - } catch (Exception ex) { - LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, ex.getMessage (), "", "", MsoLogger.ErrorCode.DataError , "Problem in getting DB connection type", ex); - throw ex; - } - } - - public static SessionFactory getSessionFactory () { - return SESSION_FACTORY; - } - - private HibernateUtil () { - // Avoid creation of an instance - } -} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/HibernateUtilsRequestsDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/HibernateUtilsRequestsDb.java new file mode 100644 index 0000000..0954811 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/HibernateUtilsRequestsDb.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.requestsdb; + +import org.openecomp.mso.db.HibernateUtils; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import java.net.URL; + +public class HibernateUtilsRequestsDb extends HibernateUtils { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); + + @Override + protected URL getHibernateConfigFile() { + try { + + if ("MYSQL".equals (System.getProperty ("mso.db")) || "MARIADB".equals(System.getProperty("mso.db"))) { + return this.getClass().getClassLoader().getResource("hibernate-requests-core-mysql.cfg.xml"); + } else { + LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC", "", "", MsoLogger.ErrorCode.DataError , "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC"); + return null; + } + } catch (Exception ex) { + LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, ex.getMessage (), "", "", MsoLogger.ErrorCode.DataError , "Problem in getting DB connection type", ex); + return null; + } + + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java index 4312819..54574c8 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -77,7 +77,7 @@ public class InfraRequests implements java.io.Serializable { private String networkId; private String networkName; private String networkType; - + private String requestorId; public InfraRequests() { } @@ -273,7 +273,7 @@ public class InfraRequests implements java.io.Serializable { public void setRequestType(String requestType) { this.requestType = requestType; } - + public String getVolumeGroupId() { return this.volumeGroupId; } @@ -281,7 +281,7 @@ public class InfraRequests implements java.io.Serializable { public void setVolumeGroupId(String volumeGroupId) { this.volumeGroupId = volumeGroupId; } - + public String getVolumeGroupName() { return this.volumeGroupName; } @@ -289,7 +289,7 @@ public class InfraRequests implements java.io.Serializable { public void setVolumeGroupName(String volumeGroupName) { this.volumeGroupName = volumeGroupName; } - + public String getVfModuleId() { return this.vfModuleId; } @@ -297,7 +297,7 @@ public class InfraRequests implements java.io.Serializable { public void setVfModuleId(String vfModuleId) { this.vfModuleId = vfModuleId; } - + public String getVfModuleName() { return this.vfModuleName; } @@ -305,7 +305,7 @@ public class InfraRequests implements java.io.Serializable { public void setVfModuleName(String vfModuleName) { this.vfModuleName = vfModuleName; } - + public String getVfModuleModelName() { return this.vfModuleModelName; } @@ -313,7 +313,7 @@ public class InfraRequests implements java.io.Serializable { public void setVfModuleModelName(String vfModuleModelName) { this.vfModuleModelName = vfModuleModelName; } - + public String getAaiServiceId() { return this.aaiServiceId; } @@ -369,7 +369,7 @@ public class InfraRequests implements java.io.Serializable { public void setRequestScope(String requestScope) { this.requestScope = requestScope; } - + public String getRequestAction() { return requestAction; } @@ -401,5 +401,13 @@ public class InfraRequests implements java.io.Serializable { public void setNetworkType(String networkType) { this.networkType = networkType; } - + + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + } diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java index fda4461..e32c456 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java @@ -35,13 +35,17 @@ import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.hibernate.persister.entity.AbstractEntityPersister; - +import org.openecomp.mso.db.HibernateUtils; +import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb; import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; public class RequestsDatabase { + protected static HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb (); + protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); - + protected static final String SOURCE = "source"; protected static final String START_TIME = "startTime"; protected static final String REQUEST_TYPE = "requestType"; @@ -70,7 +74,7 @@ public class RequestsDatabase { } public static boolean healthCheck () { - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); try { Query query = session.createSQLQuery (" show tables "); @@ -88,7 +92,7 @@ public class RequestsDatabase { public static int updateInfraStatus (String requestId, String requestStatus, String lastModifiedBy) { long startTime = System.currentTimeMillis (); msoLogger.debug ("Update infra request record " + requestId + " with status " + requestStatus); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); int result = 0; try { @@ -113,7 +117,7 @@ public class RequestsDatabase { public static int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) { long startTime = System.currentTimeMillis (); msoLogger.debug ("Update infra request record " + requestId + " with status " + requestStatus); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); int result = 0; try { @@ -139,7 +143,7 @@ public class RequestsDatabase { public static int updateInfraFinalStatus (String requestId, String requestStatus, String statusMessage, long progress, String responseBody, String lastModifiedBy) { long startTime = System.currentTimeMillis (); msoLogger.debug ("Update infra request record " + requestId + " with status " + requestStatus); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); int result = 0; try { @@ -172,7 +176,7 @@ public class RequestsDatabase { List <InfraActiveRequests> results = new ArrayList<InfraActiveRequests>(); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); try { session.beginTransaction (); Criteria crit = session.createCriteria (InfraActiveRequests.class); @@ -197,7 +201,7 @@ public class RequestsDatabase { long startTime = System.currentTimeMillis (); msoLogger.debug ("Get request " + requestId + " from InfraActiveRequests DB"); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); InfraActiveRequests ar = null; try { session.beginTransaction (); @@ -314,7 +318,7 @@ public class RequestsDatabase { long startTime = System.currentTimeMillis (); msoLogger.debug ("Get list of infra requests from DB with " + queryAttributeName + " = " + queryValue); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); try { session.beginTransaction (); Criteria crit = session.createCriteria (InfraActiveRequests.class) @@ -342,7 +346,7 @@ public class RequestsDatabase { long startTime = System.currentTimeMillis (); msoLogger.debug ("Get infra request from DB with id " + requestId); - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); InfraActiveRequests ar = null; try { session.beginTransaction (); @@ -366,7 +370,7 @@ public class RequestsDatabase { msoLogger.debug ("Get infra request from DB for VNF " + vnfName + " and action " + action + " and requestType " + requestType); InfraActiveRequests ar = null; - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); try { session.beginTransaction (); @@ -395,7 +399,7 @@ public class RequestsDatabase { msoLogger.debug ("Get list of infra requests from DB for VNF " + vnfId + " and action " + action); InfraActiveRequests ar = null; - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); try { session.beginTransaction (); @@ -429,7 +433,7 @@ public class RequestsDatabase { * @return SiteStatus object or null if none found */ public static SiteStatus getSiteStatus (String siteName) { - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); long startTime = System.currentTimeMillis (); SiteStatus siteStatus = null; @@ -456,7 +460,7 @@ public class RequestsDatabase { * @param status The updated status of the Site */ public static void updateSiteStatus (String siteName, boolean status) { - Session session = HibernateUtil.getSessionFactory ().openSession (); + Session session = hibernateUtils.getSessionFactory ().openSession (); session.beginTransaction (); long startTime = System.currentTimeMillis (); diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/InfraActiveRequests.hbm.xml b/mso-api-handlers/mso-requests-db/src/main/resources/InfraActiveRequests.hbm.xml index b98177a..ee12b45 100644 --- a/mso-api-handlers/mso-requests-db/src/main/resources/InfraActiveRequests.hbm.xml +++ b/mso-api-handlers/mso-requests-db/src/main/resources/InfraActiveRequests.hbm.xml @@ -8,9 +8,9 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -142,5 +142,8 @@ <property name="networkType" type="string"> <column name="NETWORK_TYPE" length="80"/> </property> + <property name="requestorId" type="string"> + <column name="REQUESTOR_ID" length="80"/> + </property> </class> </hibernate-mapping> diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-mysql.cfg.xml b/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-requests-core-mysql.cfg.xml index 531b771..531b771 100644 --- a/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-mysql.cfg.xml +++ b/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-requests-core-mysql.cfg.xml diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/HibernateUtilESTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/HibernateUtilESTest.java deleted file mode 100644 index 6ae0a64..0000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/HibernateUtilESTest.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file was automatically generated by EvoSuite - * Wed Dec 14 15:15:07 GMT 2016 - */ - -package org.openecomp.mso.requestsdb; - -import org.junit.Test; -import static org.junit.Assert.*; -import org.evosuite.runtime.EvoRunner; -import org.evosuite.runtime.EvoRunnerParameters; -import org.evosuite.runtime.PrivateAccess; -import org.junit.runner.RunWith; -import org.openecomp.mso.requestsdb.HibernateUtil; - -@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) -public class HibernateUtilESTest extends HibernateUtilESTestscaffolding { - - @Test(timeout = 4000) - public void test0() throws Throwable { - HibernateUtil hibernateUtil0 = (HibernateUtil)PrivateAccess.callDefaultConstructorOfTheClassUnderTest(); - assertNotNull(hibernateUtil0); - } -} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/HibernateUtilESTestscaffolding.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/HibernateUtilESTestscaffolding.java deleted file mode 100644 index e2e9b60..0000000 --- a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/HibernateUtilESTestscaffolding.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Scaffolding file used to store all the setups needed to run - * tests automatically generated by EvoSuite - * Wed Dec 14 15:15:07 GMT 2016 - */ - -package org.openecomp.mso.requestsdb; - -import org.evosuite.runtime.annotation.EvoSuiteClassExclude; -import org.junit.BeforeClass; -import org.junit.Before; -import org.junit.After; -import org.junit.AfterClass; -import org.evosuite.runtime.sandbox.Sandbox; -import org.evosuite.runtime.sandbox.Sandbox.SandboxMode; - -@EvoSuiteClassExclude -public class HibernateUtilESTestscaffolding { - - @org.junit.Rule - public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); - - private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); - - private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); - - @BeforeClass - public static void initEvoSuiteFramework() { - org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.requestsdb.HibernateUtil"; - org.evosuite.runtime.GuiSupport.initialize(); - org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; - org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; - org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; - org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; - org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); - org.evosuite.runtime.classhandling.JDKClassResetter.init(); - initializeClasses(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - } - - @AfterClass - public static void clearEvoSuiteFramework(){ - Sandbox.resetDefaultSecurityManager(); - java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); - } - - @Before - public void initTestCase(){ - threadStopper.storeCurrentThreads(); - threadStopper.startRecordingTime(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); - org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); - org.evosuite.runtime.GuiSupport.setHeadless(); - org.evosuite.runtime.Runtime.getInstance().resetRuntime(); - org.evosuite.runtime.agent.InstrumentingAgent.activate(); - } - - @After - public void doneWithTestCase(){ - threadStopper.killAndJoinClientThreads(); - org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); - org.evosuite.runtime.classhandling.JDKClassResetter.reset(); - resetClasses(); - org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); - org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); - org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); - } - - private static void initializeClasses() { - org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(HibernateUtilESTestscaffolding.class.getClassLoader() , - "org.openecomp.mso.logger.MessageEnum", - "com.att.eelf.i18n.EELFResolvableErrorEnum", - "org.openecomp.mso.logger.MsoLogger$Catalog", - "org.openecomp.mso.logger.MsoLogger$StatusCode", - "org.hibernate.SessionFactory", - "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", - "com.att.eelf.configuration.EELFManager", - "com.att.eelf.configuration.EELFLogger", - "com.att.eelf.i18n.EELFMsgs", - "org.openecomp.mso.entity.MsoRequest", - "com.att.eelf.configuration.EELFLogger$Level", - "org.openecomp.mso.requestsdb.HibernateUtil", - "org.openecomp.mso.logger.MsoLogger$ResponseCode", - "com.att.eelf.configuration.SLF4jWrapper", - "com.att.eelf.i18n.EELFResourceManager", - "org.openecomp.mso.logger.MsoLogger", - "org.openecomp.mso.logger.MsoLogger$ErrorCode" - ); - } - - private static void resetClasses() { - org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(HibernateUtilESTestscaffolding.class.getClassLoader()); - - org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( - "com.att.eelf.i18n.EELFResourceManager", - "org.openecomp.mso.logger.MessageEnum", - "org.openecomp.mso.logger.MsoLogger$Catalog", - "org.openecomp.mso.logger.MsoLogger", - "com.att.eelf.i18n.EELFMsgs", - "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", - "com.att.eelf.configuration.EELFLogger$Level", - "com.att.eelf.configuration.EELFManager", - "org.openecomp.mso.logger.MsoLogger$ErrorCode", - "org.openecomp.mso.requestsdb.HibernateUtil" - ); - } -} diff --git a/mso-api-handlers/pom.xml b/mso-api-handlers/pom.xml index 6b9448e..23f7be3 100644 --- a/mso-api-handlers/pom.xml +++ b/mso-api-handlers/pom.xml @@ -20,6 +20,12 @@ </modules> <dependencies> + <dependency> + <groupId>org.evosuite</groupId> + <artifactId>evosuite-standalone-runtime</artifactId> + <version>${evosuiteVersion}</version> + <scope>test</scope> + </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> |