diff options
Diffstat (limited to 'mso-api-handlers')
154 files changed, 25564 insertions, 0 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/pom.xml b/mso-api-handlers/mso-api-handler-common/pom.xml new file mode 100644 index 0000000000..b9d622d08c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/pom.xml @@ -0,0 +1,109 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-api-handlers</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + + + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-api-handler-common</artifactId> + + <name>ECOMP MSO API Handler common</name> + <description>ECOMP MSO API Handler common classes</description> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-jaxrs</artifactId> + <version>3.0.19.Final</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </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> + <scope>provided</scope> + </dependency> + + + <dependency> + <groupId>javax.activation</groupId> + <artifactId>activation</artifactId> + <version>1.1.1</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + <version>1.9.13</version> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + <version>1.9.13</version> + </dependency> + + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-catalog-db</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-requests-db</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>1.10.19</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + + </build> + <packaging>jar</packaging> +</project>
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequest.java new file mode 100644 index 0000000000..4de534b600 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/BpmnRequest.java @@ -0,0 +1,255 @@ +/*- + * ============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.apihandler.camundabeans; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.codehaus.jackson.annotate.JsonPropertyOrder; + +import org.openecomp.mso.apihandler.common.CommonConstants; + +/** + * JavaBean JSON class for a "bpmnRequest" which contains the JSON payload that + * will be passed to the Camunda process + */ +@JsonPropertyOrder({CommonConstants.REQUEST_ID_VARIABLE, + CommonConstants.IS_BASE_VF_MODULE_VARIABLE, CommonConstants.RECIPE_TIMEOUT_VARIABLE, + CommonConstants.REQUEST_ACTION_VARIABLE, CommonConstants.SERVICE_INSTANCE_ID_VARIABLE, + CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, + CommonConstants.VOLUME_GROUP_ID_VARIABLE, CommonConstants.NETWORK_ID_VARIABLE, + CommonConstants.SERVICE_TYPE_VARIABLE, CommonConstants.VNF_TYPE_VARIABLE, + CommonConstants.VF_MODULE_TYPE_VARIABLE, CommonConstants.NETWORK_TYPE_VARIABLE, + CommonConstants.REQUEST_DETAILS_VARIABLE}) +@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) +public class BpmnRequest { + + public BpmnRequest() { + + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + private CamundaInput host; + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + private CamundaInput requestId; + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + private CamundaBooleanInput isBaseVfModule; + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + private CamundaIntegerInput recipeTimeout; + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + private CamundaInput requestAction; + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + private CamundaInput serviceInstanceId; + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + private CamundaInput vnfId; + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + private CamundaInput vfModuleId; + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + private CamundaInput volumeGroupId; + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + private CamundaInput networkId; + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + private CamundaInput serviceType; + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + private CamundaInput vnfType; + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + private CamundaInput vfModuleType; + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + private CamundaInput networkType; + + @JsonProperty(CommonConstants.REQUEST_DETAILS_VARIABLE) + private CamundaInput requestDetails; + + + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public CamundaInput getHost() { + return host; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public void setHost(CamundaInput host) { + this.host = host; + } + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + public CamundaInput getRequestId() { + return requestId; + } + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + public void setRequestId(CamundaInput requestId) { + this.requestId = requestId; + } + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + public CamundaBooleanInput getIsBaseVfModule() { + return isBaseVfModule; + } + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + public void setIsBaseVfModule(CamundaBooleanInput isBaseVfModule) { + this.isBaseVfModule = isBaseVfModule; + } + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + public CamundaIntegerInput getRecipeTimeout() { + return recipeTimeout; + } + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + public void setRecipeTimeout(CamundaIntegerInput recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + public CamundaInput getRequestAction() { + return requestAction; + } + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + public void setRequestAction(CamundaInput requestAction) { + this.requestAction = requestAction; + } + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + public CamundaInput getServiceInstanceId() { + return serviceInstanceId; + } + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + public void setServiceInstanceId(CamundaInput serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + public CamundaInput getVnfId() { + return vnfId; + } + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + public void setVnfId(CamundaInput vnfId) { + this.vnfId = vnfId; + } + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + public CamundaInput getVfModuleId() { + return vfModuleId; + } + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + public void setVfModuleId(CamundaInput vfModuleId) { + this.vfModuleId = vfModuleId; + } + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + public CamundaInput getVolumeGroupId() { + return volumeGroupId; + } + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + public void setVolumeGroupId(CamundaInput volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + public CamundaInput getNetworkId() { + return networkId; + } + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + public void setNetworkId(CamundaInput networkId) { + this.networkId = networkId; + } + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + public CamundaInput getServiceType() { + return serviceType; + } + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + public void setServiceType(CamundaInput serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + public CamundaInput getVnfType() { + return vnfType; + } + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + public void setVnfType(CamundaInput vnfType) { + this.vnfType = vnfType; + } + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + public CamundaInput getVfModuleType() { + return vfModuleType; + } + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + public void setVfModuleType(CamundaInput vfModuleType) { + this.vfModuleType = vfModuleType; + } + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + public CamundaInput getNetworkType() { + return networkType; + } + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + public void setNetworkType(CamundaInput networkType) { + this.networkType = networkType; + } + + @JsonProperty(CommonConstants.REQUEST_DETAILS_VARIABLE) + public CamundaInput getRequestDetails() { + return requestDetails; + } + + @JsonProperty(CommonConstants.REQUEST_DETAILS_VARIABLE) + public void setRequestDetails(CamundaInput requestDetails) { + this.requestDetails = requestDetails; + } + + + + + @Override + public String toString() { + //return "CamundaRequest [requestId=" + + ", host=" + // + host + ", schema=" + schema + ", reqid=" + reqid + ", svcid=" + // + svcid + ", timeout=" + timeout + "]"; + return "BpmnRequest"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBooleanInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBooleanInput.java new file mode 100644 index 0000000000..c6ef7e59ca --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBooleanInput.java @@ -0,0 +1,61 @@ +/*- + * ============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.apihandler.camundabeans; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +import org.openecomp.mso.apihandler.common.CommonConstants; + +/** + * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that + * will be passed to the Camunda process + */ + + +public class CamundaBooleanInput { + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + private boolean value; + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + private String type = "Boolean"; + + + public CamundaBooleanInput() { + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public boolean getValue() { + return value; + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public void setValue(boolean value) { + this.value = value; + } + + @Override + public String toString() { + return "CamundaInput [value=" + value + ", type=" + type + "]"; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBpmnRequestInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBpmnRequestInput.java new file mode 100644 index 0000000000..e7e9b31edc --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaBpmnRequestInput.java @@ -0,0 +1,59 @@ +/*- + * ============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.apihandler.camundabeans; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +import org.openecomp.mso.apihandler.common.CommonConstants; + +/** + * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that + * will be passed to the Camunda process + */ +public class CamundaBpmnRequestInput { + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + private BpmnRequest value; + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + private String type = "String"; + + + public CamundaBpmnRequestInput() { + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public BpmnRequest getValue() { + return value; + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public void setValue(BpmnRequest value) { + this.value = value; + } + + @Override + public String toString() { + return "CamundaInput [value=" + value + ", type=" + type + "]"; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaInput.java new file mode 100644 index 0000000000..16c71658a5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaInput.java @@ -0,0 +1,66 @@ +/*- + * ============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.apihandler.camundabeans; + + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +import org.openecomp.mso.apihandler.common.CommonConstants; + +/** + * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that + * will be passed to the Camunda process + * + */ + + +public class CamundaInput { + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + private String value; + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + private String type = "String"; + + + public CamundaInput() { + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public String getValue() { + return value; + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return "CamundaInput [value=" + value + ", type=" + type + "]"; + } + + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaIntegerInput.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaIntegerInput.java new file mode 100644 index 0000000000..ac77fb75bd --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaIntegerInput.java @@ -0,0 +1,59 @@ +/*- + * ============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.apihandler.camundabeans; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +import org.openecomp.mso.apihandler.common.CommonConstants; + +/** + * JavaBean JSON class for a "gMyServiceInput" which contains the xml payload that + * will be passed to the Camunda process + */ +public class CamundaIntegerInput { + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + private int value; + @JsonProperty(CommonConstants.CAMUNDA_TYPE) + private String type = "Integer"; + + + public CamundaIntegerInput() { + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public int getValue() { + return value; + } + + @JsonProperty(CommonConstants.CAMUNDA_VALUE) + public void setValue(int value) { + this.value = value; + } + + @Override + public String toString() { + return "CamundaInput [value=" + Integer.toString(value) + ", type=" + type + "]"; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaRequest.java new file mode 100644 index 0000000000..4eacff6623 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaRequest.java @@ -0,0 +1,133 @@ +/*- + * ============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.apihandler.camundabeans; + + + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.codehaus.jackson.annotate.JsonPropertyOrder; + +import org.openecomp.mso.apihandler.common.CommonConstants; + +/** + * JavaBean JSON class for a "variables" which contains the xml payload that + * will be passed to the Camunda process + * + */ +@JsonPropertyOrder({ CommonConstants.CAMUNDA_SERVICE_INPUT, CommonConstants.CAMUNDA_HOST, + CommonConstants.SCHEMA_VERSION_HEADER, CommonConstants.REQUEST_ID_HEADER, CommonConstants.SERVICE_INSTANCE_ID_HEADER, + CommonConstants. REQUEST_TIMEOUT_HEADER, CommonConstants.CAMUNDA_SERVICE_INPUT}) +@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) +public class CamundaRequest { + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + private CamundaInput serviceInput; + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + private CamundaInput host; + + @JsonProperty(CommonConstants.SCHEMA_VERSION_HEADER) + private CamundaInput schema; + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + private CamundaInput reqid; + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_HEADER) + private CamundaInput svcid; + + @JsonProperty(CommonConstants.REQUEST_TIMEOUT_HEADER) + private CamundaInput timeout; + + public CamundaRequest() { + } + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + public CamundaInput getServiceInput() { + return serviceInput; + } + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + public void setServiceInput(CamundaInput serviceInput) { + this.serviceInput = serviceInput; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public CamundaInput getHost() { + return host; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public void setHost(CamundaInput host) { + this.host = host; + } + + @JsonProperty(CommonConstants.SCHEMA_VERSION_HEADER) + public CamundaInput getSchema() { + return schema; + } + + @JsonProperty(CommonConstants.SCHEMA_VERSION_HEADER) + public void setSchema(CamundaInput schema) { + this.schema = schema; + } + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + public CamundaInput getReqid() { + return reqid; + } + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + public void setReqid(CamundaInput reqid) { + this.reqid = reqid; + } + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_HEADER) + public CamundaInput getSvcid() { + return svcid; + } + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_HEADER) + public void setSvcid(CamundaInput svcid) { + this.svcid = svcid; + } + + + @JsonProperty(CommonConstants.REQUEST_TIMEOUT_HEADER) + public CamundaInput getTimeout() { + return timeout; + } + + @JsonProperty(CommonConstants.REQUEST_TIMEOUT_HEADER) + public void setTimeout(CamundaInput timeout) { + this.timeout = timeout; + } + + + + @Override + public String toString() { + return "CamundaRequest [serviceInput=" + serviceInput + ", host=" + + host + ", schema=" + schema + ", reqid=" + reqid + ", svcid=" + + svcid + ", timeout=" + timeout + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaResponse.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaResponse.java new file mode 100644 index 0000000000..3eeb0c0f76 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaResponse.java @@ -0,0 +1,97 @@ +/*- + * ============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.apihandler.camundabeans; + + +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * JavaBean JSON class for a "variables" which contains the xml payload that + * will be passed to the Camunda process + * + */ + +public class CamundaResponse { + + @JsonProperty("response") + private String response; + @JsonProperty("messageCode") + private int messageCode; + @JsonProperty("message") + private String message; + @JsonProperty("processInstanceID") + private String processInstanceID; + @JsonProperty("variables") + private String variables; + + public String getProcessInstanceID() { + return processInstanceID; + } + + public void setProcessInstanceID(String processInstanceID) { + this.processInstanceID = processInstanceID; + } + + public String getVariables() { + return variables; + } + + public void setVariables(String variables) { + this.variables = variables; + } + + public CamundaResponse() { + } + + public String getResponse() { + return response; + } + + public void setResponse(String response) { + this.response = response; + } + + public int getMessageCode() { + return messageCode; + } + + public void setMessageCode(int messageCode) { + this.messageCode = messageCode; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return "CamundaResponse [response=" + response + ", messageCode=" + + messageCode + ", message=" + message + "]"; + } + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java new file mode 100644 index 0000000000..5cf859d537 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java @@ -0,0 +1,262 @@ +/*- + * ============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.apihandler.camundabeans; + +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.codehaus.jackson.annotate.JsonPropertyOrder; + +import org.openecomp.mso.apihandler.common.CommonConstants; + +/** + * JavaBean JSON class for a "variables" which contains the JSON payload that + * will be passed to the Camunda process + */ +@JsonPropertyOrder({CommonConstants.CAMUNDA_SERVICE_INPUT, CommonConstants.REQUEST_ID_VARIABLE, + CommonConstants.REQUEST_ID_HEADER, + CommonConstants.IS_BASE_VF_MODULE_VARIABLE, CommonConstants.RECIPE_TIMEOUT_VARIABLE, + CommonConstants.REQUEST_ACTION_VARIABLE, CommonConstants.SERVICE_INSTANCE_ID_VARIABLE, + CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, + CommonConstants.VOLUME_GROUP_ID_VARIABLE, CommonConstants.NETWORK_ID_VARIABLE, + CommonConstants.SERVICE_TYPE_VARIABLE, CommonConstants.VNF_TYPE_VARIABLE, + CommonConstants.VF_MODULE_TYPE_VARIABLE, CommonConstants.NETWORK_TYPE_VARIABLE, + CommonConstants.CAMUNDA_SERVICE_INPUT}) +@JsonRootName(CommonConstants.CAMUNDA_ROOT_INPUT) +public class CamundaVIDRequest { + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + private CamundaInput serviceInput; + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + private CamundaInput host; + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + private CamundaInput requestId; + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + private CamundaInput attMsoRequestId; + + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + private CamundaBooleanInput isBaseVfModule; + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + private CamundaIntegerInput recipeTimeout; + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + private CamundaInput requestAction; + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + private CamundaInput serviceInstanceId; + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + private CamundaInput vnfId; + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + private CamundaInput vfModuleId; + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + private CamundaInput volumeGroupId; + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + private CamundaInput networkId; + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + private CamundaInput serviceType; + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + private CamundaInput vnfType; + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + private CamundaInput vfModuleType; + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + private CamundaInput networkType; + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + public CamundaInput getServiceInput() { + return serviceInput; + } + + @JsonProperty(CommonConstants.CAMUNDA_SERVICE_INPUT) + public void setServiceInput(CamundaInput serviceInput) { + this.serviceInput = serviceInput; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public CamundaInput getHost() { + return host; + } + + @JsonProperty(CommonConstants.CAMUNDA_HOST) + public void setHost(CamundaInput host) { + this.host = host; + } + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + public CamundaInput getRequestId() { + return requestId; + } + + @JsonProperty(CommonConstants.REQUEST_ID_VARIABLE) + public void setRequestId(CamundaInput requestId) { + this.requestId = requestId; + } + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + public CamundaInput getAttMsoRequestId() { + return attMsoRequestId; + } + + @JsonProperty(CommonConstants.REQUEST_ID_HEADER) + public void setAttMsoRequestId(CamundaInput attMsoRequestId) { + this.attMsoRequestId = attMsoRequestId; + } + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + public CamundaBooleanInput getIsBaseVfModule() { + return isBaseVfModule; + } + + @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) + public void setIsBaseVfModule(CamundaBooleanInput isBaseVfModule) { + this.isBaseVfModule = isBaseVfModule; + } + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + public CamundaIntegerInput getRecipeTimeout() { + return recipeTimeout; + } + + @JsonProperty(CommonConstants.RECIPE_TIMEOUT_VARIABLE) + public void setRecipeTimeout(CamundaIntegerInput recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + public CamundaInput getRequestAction() { + return requestAction; + } + + @JsonProperty(CommonConstants.REQUEST_ACTION_VARIABLE) + public void setRequestAction(CamundaInput requestAction) { + this.requestAction = requestAction; + } + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + public CamundaInput getServiceInstanceId() { + return serviceInstanceId; + } + + @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) + public void setServiceInstanceId(CamundaInput serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + public CamundaInput getVnfId() { + return vnfId; + } + + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) + public void setVnfId(CamundaInput vnfId) { + this.vnfId = vnfId; + } + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + public CamundaInput getVfModuleId() { + return vfModuleId; + } + + @JsonProperty(CommonConstants.VF_MODULE_ID_VARIABLE) + public void setVfModuleId(CamundaInput vfModuleId) { + this.vfModuleId = vfModuleId; + } + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + public CamundaInput getVolumeGroupId() { + return volumeGroupId; + } + + @JsonProperty(CommonConstants.VOLUME_GROUP_ID_VARIABLE) + public void setVolumeGroupId(CamundaInput volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + public CamundaInput getNetworkId() { + return networkId; + } + + @JsonProperty(CommonConstants.NETWORK_ID_VARIABLE) + public void setNetworkId(CamundaInput networkId) { + this.networkId = networkId; + } + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + public CamundaInput getServiceType() { + return serviceType; + } + + @JsonProperty(CommonConstants.SERVICE_TYPE_VARIABLE) + public void setServiceType(CamundaInput serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + public CamundaInput getVnfType() { + return vnfType; + } + + @JsonProperty(CommonConstants.VNF_TYPE_VARIABLE) + public void setVnfType(CamundaInput vnfType) { + this.vnfType = vnfType; + } + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + public CamundaInput getVfModuleType() { + return vfModuleType; + } + + @JsonProperty(CommonConstants.VF_MODULE_TYPE_VARIABLE) + public void setVfModuleType(CamundaInput vfModuleType) { + this.vfModuleType = vfModuleType; + } + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + public CamundaInput getNetworkType() { + return networkType; + } + + @JsonProperty(CommonConstants.NETWORK_TYPE_VARIABLE) + public void setNetworkType(CamundaInput networkType) { + this.networkType = networkType; + } + + + @Override + public String toString() { + //return "CamundaRequest [requestId=" + + ", host=" + // + host + ", schema=" + schema + ", reqid=" + reqid + ", svcid=" + // + svcid + ", timeout=" + timeout + "]"; + return "CamundaRequest"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/Track.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/Track.java new file mode 100644 index 0000000000..a625298881 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/Track.java @@ -0,0 +1,49 @@ +/*- + * ============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.apihandler.camundabeans; + +public class Track { + + String title; + String singer; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSinger() { + return singer; + } + + public void setSinger(String singer) { + this.singer = singer; + } + + @Override + public String toString() { + return "Track [title=" + title + ", singer=" + singer + "]"; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java new file mode 100644 index 0000000000..511b874e15 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java @@ -0,0 +1,95 @@ +/*- + * ============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.apihandler.common; + +import java.io.IOException; + +import javax.ws.rs.core.MediaType; +import javax.xml.bind.DatatypeConverter; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; + +import org.openecomp.mso.logger.MsoLogger; + +public class BPELRestClient extends RequestClient { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + public BPELRestClient () { + super (CommonConstants.BPEL); + } + + @Override + public HttpResponse post (String bpelReqXML, + String requestId, + String requestTimeout, + String schemaVersion, + String serviceInstanceId, + String action) throws ClientProtocolException, IOException { + String encryptedCredentials = null; + HttpPost post = new HttpPost (url); + msoLogger.debug ("BPEL url is: " + url); + StringEntity input = new StringEntity (bpelReqXML); + input.setContentType (MediaType.TEXT_XML); + if (props != null) { + encryptedCredentials = props.getProperty (CommonConstants.BPEL_AUTH,null); + if (encryptedCredentials != null) { + String userCredentials = getEncryptedPropValue (encryptedCredentials, + CommonConstants.DEFAULT_BPEL_AUTH, + CommonConstants.ENCRYPTION_KEY); + if (userCredentials != null) { + post.addHeader ("Authorization", + "Basic " + new String (DatatypeConverter.printBase64Binary (userCredentials.getBytes ()))); + } + } + } + post.addHeader (CommonConstants.REQUEST_ID_HEADER, requestId); + post.addHeader (CommonConstants.REQUEST_TIMEOUT_HEADER, requestTimeout); + post.addHeader (CommonConstants.SCHEMA_VERSION_HEADER, schemaVersion); + if (serviceInstanceId != null) { + post.addHeader (CommonConstants.SERVICE_INSTANCE_ID_HEADER, serviceInstanceId); + } + if (action != null) { + post.addHeader (CommonConstants.ACTION_HEADER, action); + } + post.setEntity (input); + HttpResponse response = client.execute (post); + msoLogger.debug ("bpel response " + response); + return response; + } + + @Override + public HttpResponse post (String bpelReqXML) { + return null; + } + + @Override + public HttpResponse post(String requestId, boolean isBaseVfModule, + int recipeTimeout, String requestAction, String serviceInstanceId, + String vnfId, String vfModuleId, String volumeGroupId, String networkId, + String serviceType, String vnfType, String vfModuleType, String networkType, + String requestDetails) { + return null; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java new file mode 100644 index 0000000000..dd83d24c9e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java @@ -0,0 +1,313 @@ +/*- + * ============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.apihandler.common; + + +import org.openecomp.mso.apihandler.camundabeans.*; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; + +import javax.xml.bind.DatatypeConverter; +import java.io.IOException; + +public class CamundaClient extends RequestClient{ + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); + + public CamundaClient() { + super(CommonConstants.CAMUNDA); + } + + + @Override + public HttpResponse post(String camundaReqXML, String requestId, + String requestTimeout, String schemaVersion, String serviceInstanceId, String action) + throws ClientProtocolException, IOException{ + HttpPost post = new HttpPost(url); + msoLogger.debug("Camunda url is: "+ url); + String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion); + + StringEntity input = new StringEntity(jsonReq); + input.setContentType(CommonConstants.CONTENT_TYPE_JSON); + + String encryptedCredentials = null; + if(props!=null){ + encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); + if(encryptedCredentials != null){ + String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); + if(userCredentials != null){ + post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes()))); + } + } + } + + post.setEntity(input); + HttpResponse response = client.execute(post); + + return response; + } + + @Override + public HttpResponse post(String jsonReq) + throws ClientProtocolException, IOException{ + HttpPost post = new HttpPost(url); + msoLogger.debug("Camunda url is: "+ url); + //String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion); + + StringEntity input = new StringEntity(jsonReq); + input.setContentType(CommonConstants.CONTENT_TYPE_JSON); + + String encryptedCredentials = null; + if(props!=null){ + encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); + if(encryptedCredentials != null){ + String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); + if(userCredentials != null){ + post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes()))); + } + } + } + + post.setEntity(input); + HttpResponse response = client.execute(post); + + return response; + } + + @Override + public HttpResponse post(String requestId, boolean isBaseVfModule, + int recipeTimeout, String requestAction, String serviceInstanceId, + String vnfId, String vfModuleId, String volumeGroupId, String networkId, + String serviceType, String vnfType, String vfModuleType, String networkType, + String requestDetails) + throws ClientProtocolException, IOException{ + HttpPost post = new HttpPost(url); + msoLogger.debug("Camunda url is: "+ url); + String jsonReq = wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction, + serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, + serviceType, vnfType, vfModuleType, networkType, requestDetails); + + StringEntity input = new StringEntity(jsonReq); + input.setContentType(CommonConstants.CONTENT_TYPE_JSON); + + String encryptedCredentials = null; + if(props!=null){ + encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); + if(encryptedCredentials != null){ + String userCredentials = getEncryptedPropValue(encryptedCredentials, CommonConstants.DEFAULT_BPEL_AUTH, CommonConstants.ENCRYPTION_KEY); + if(userCredentials != null){ + post.addHeader("Authorization", "Basic " + new String(DatatypeConverter.printBase64Binary(userCredentials.getBytes()))); + } + } + } + + post.setEntity(input); + HttpResponse response = client.execute(post); + + return response; + } + + private String wrapRequest(String reqXML, String requestId, String serviceInstanceId, String requestTimeout, String schemaVersion){ + String jsonReq = null; + if(reqXML == null){ + reqXML =""; + } + if(requestTimeout == null){ + requestTimeout =""; + } + if(schemaVersion == null){ + schemaVersion = ""; + } + + + try{ + CamundaRequest camundaRequest = new CamundaRequest(); + CamundaInput camundaInput = new CamundaInput(); + CamundaInput host = new CamundaInput(); + CamundaInput schema = new CamundaInput(); + CamundaInput reqid = new CamundaInput(); + CamundaInput svcid = new CamundaInput(); + CamundaInput timeout = new CamundaInput(); + camundaInput.setValue(reqXML); + host.setValue(parseURL()); + schema.setValue(schemaVersion); + reqid.setValue(requestId); + svcid.setValue(serviceInstanceId); + timeout.setValue(requestTimeout); + camundaRequest.setServiceInput(camundaInput); + camundaRequest.setHost(host); + camundaRequest.setReqid(reqid); + camundaRequest.setSvcid(svcid); + camundaRequest.setSchema(schema); + camundaRequest.setTimeout(timeout); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true); + + jsonReq = mapper.writeValueAsString(camundaRequest); + msoLogger.debug("request body is " + jsonReq); + }catch(Exception e){ + msoLogger.error(MessageEnum.APIH_WARP_REQUEST, "Camunda", "wrapRequest", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH Warp request", e); + } + return jsonReq; + } + + private String wrapVIDRequest(String requestId, boolean isBaseVfModule, + int recipeTimeout, String requestAction, String serviceInstanceId, + String vnfId, String vfModuleId, String volumeGroupId, String networkId, + String serviceType, String vnfType, String vfModuleType, String networkType, + String requestDetails){ + String jsonReq = null; + if(requestId == null){ + requestId =""; + } + if(requestAction == null){ + requestAction =""; + } + if(serviceInstanceId == null){ + serviceInstanceId =""; + } + if(vnfId == null){ + vnfId =""; + } + if(vfModuleId == null){ + vfModuleId =""; + } + if(volumeGroupId == null){ + volumeGroupId =""; + } + if(networkId == null){ + networkId =""; + } + if(serviceType == null){ + serviceType =""; + } + if(vnfType == null){ + vnfType =""; + } + if(vfModuleType == null){ + vfModuleType =""; + } + if(networkType == null){ + networkType =""; + } + if(requestDetails == null){ + requestDetails =""; + } + + + + try{ + CamundaVIDRequest camundaRequest = new CamundaVIDRequest(); + BpmnRequest bpmnRequest = new BpmnRequest(); + CamundaInput serviceInput = new CamundaInput(); + CamundaInput host = new CamundaInput(); + CamundaInput requestIdInput= new CamundaInput(); + CamundaBooleanInput isBaseVfModuleInput = new CamundaBooleanInput(); + CamundaIntegerInput recipeTimeoutInput = new CamundaIntegerInput(); + CamundaInput requestActionInput = new CamundaInput(); + CamundaInput serviceInstanceIdInput = new CamundaInput(); + CamundaInput vnfIdInput = new CamundaInput(); + CamundaInput vfModuleIdInput = new CamundaInput(); + CamundaInput volumeGroupIdInput = new CamundaInput(); + CamundaInput networkIdInput = new CamundaInput(); + CamundaInput serviceTypeInput = new CamundaInput(); + CamundaInput vnfTypeInput = new CamundaInput(); + CamundaInput vfModuleTypeInput = new CamundaInput(); + CamundaInput networkTypeInput = new CamundaInput(); + + host.setValue(parseURL()); + requestIdInput.setValue(requestId); + isBaseVfModuleInput.setValue(isBaseVfModule); + recipeTimeoutInput.setValue(recipeTimeout); + requestActionInput.setValue(requestAction); + serviceInstanceIdInput.setValue(serviceInstanceId); + vnfIdInput.setValue(vnfId); + vfModuleIdInput.setValue(vfModuleId); + volumeGroupIdInput.setValue(volumeGroupId); + networkIdInput.setValue(networkId); + serviceTypeInput.setValue(serviceType); + vnfTypeInput.setValue(vnfType); + 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.setIsBaseVfModule(isBaseVfModuleInput); + camundaRequest.setRecipeTimeout(recipeTimeoutInput); + camundaRequest.setRequestAction(requestActionInput); + camundaRequest.setServiceInstanceId(serviceInstanceIdInput); + camundaRequest.setVnfId(vnfIdInput); + camundaRequest.setVfModuleId(vfModuleIdInput); + camundaRequest.setVolumeGroupId(volumeGroupIdInput); + camundaRequest.setNetworkId(networkIdInput); + camundaRequest.setServiceType(serviceTypeInput); + camundaRequest.setVnfType(vnfTypeInput); + camundaRequest.setVfModuleType(vfModuleTypeInput); + camundaRequest.setNetworkType(networkTypeInput); + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true); + + jsonReq = mapper.writeValueAsString(camundaRequest); + msoLogger.debug("request body is " + jsonReq); + }catch(Exception e){ + msoLogger.error(MessageEnum.APIH_WARP_REQUEST, "Camunda", "wrapVIDRequest", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH Warp request", e); + } + return jsonReq; + } + + private String parseURL(){ + String[] parts = url.split(":"); + String host = ""; + if(parts.length>=2){ + host = parts[1]; + if(host.length()>2){ + host = host.substring(2); + } + } + return host; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java new file mode 100644 index 0000000000..3a9ad60ac2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java @@ -0,0 +1,68 @@ +/*- + * ============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.apihandler.common; + + +public final class CommonConstants { + + public static final String DEFAULT_BPEL_AUTH = "admin:admin"; + public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + + public static final String REQUEST_ID_HEADER = "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 CAMUNDA_SERVICE_INPUT = "bpmnRequest"; + public static final String CAMUNDA_ROOT_INPUT = "variables"; + public static final String CONTENT_TYPE_JSON= "application/json"; + public static final String CAMUNDA_TYPE = "type"; + public static final String CAMUNDA_VALUE = "value"; + public static final String CAMUNDA_URL = "camundaURL"; + public static final String CAMUNDA_AUTH = "camundaAuth"; + public static final String BPEL_SEARCH_STR = "active-bpel"; + public static final String BPEL_URL = "bpelURL"; + public static final String BPEL_AUTH = "bpelAuth"; + public static final int BPEL = 0; + public static final int CAMUNDA = 1; + public static final String CAMUNDA_HOST = "host"; + public static final String SDNC_UUID_HEADER = "att-mso-sdnc-request-id"; + + public static final String REQUEST_ID_VARIABLE = "requestId"; + public static final String IS_BASE_VF_MODULE_VARIABLE = "isBaseVfModule"; + public static final String RECIPE_TIMEOUT_VARIABLE = "recipeTimeout"; + public static final String REQUEST_ACTION_VARIABLE = "requestAction"; + public static final String SERVICE_INSTANCE_ID_VARIABLE = "serviceInstanceId"; + public static final String VNF_ID_VARIABLE = "vnfId"; + public static final String VF_MODULE_ID_VARIABLE = "vfModuleId"; + public static final String VOLUME_GROUP_ID_VARIABLE = "volumeGroupId"; + public static final String NETWORK_ID_VARIABLE = "networkId"; + public static final String SERVICE_TYPE_VARIABLE = "serviceType"; + public static final String VNF_TYPE_VARIABLE = "vnfType"; + public static final String VF_MODULE_TYPE_VARIABLE = "vfModuleType"; + public static final String NETWORK_TYPE_VARIABLE = "networkType"; + public static final String REQUEST_DETAILS_VARIABLE = "requestDetails"; + + private CommonConstants () { + // prevent creating an instance of this class + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java new file mode 100644 index 0000000000..498952fe83 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ErrorNumbers.java @@ -0,0 +1,70 @@ +/*- + * ============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.apihandler.common; + +public final class ErrorNumbers { + + public static final String REQUEST_FAILED_SCHEMA_VALIDATION = "1000"; + public static final String RECIPE_DOES_NOT_EXIST = "1010"; + public static final String VFMODULE_TYPE_DOES_NOT_EXIST = "1011"; + public static final String SERVICE_PARAMETERS_FAILED_SCHEMA_VALIDATION = "1020"; + public static final String LOCKED_SAME_SERVICE_TYPE_AND_REQUEST_ACTION = "1030"; + public static final String LOCKED_CANCEL_ON_REQUEST_IN_PROGRESS = "1031"; + public static final String LOCKED_REQUEST_IN_PROGRESS_TIMEOUT = "1032"; + public static final String LOCKED_NOT_ALLOWED_FOR_REQUEST_IN_PROGRESS = "1033"; + public static final String WITHDRAW_AFTER_COMPLETE = "1034"; + public static final String COMPLETE_AFTER_WITHDRAW = "1035"; // NOT USED + public static final String REQUEST_PREVIOUSLY_COMPLETED = "1036"; + public static final String CANNOT_RETRY_FINAL_ACTIVATION = "1037"; + public static final String PREVIOUSLY_COMPLETED_WITH_DIFF_ORDER_VERSION = "1038"; + public static final String LOCKED_DIFFERENT_REQUEST_ACTION = "1040"; + public static final String LOCKED_DIFF_REQUEST_ACTION_SAME_SERVICE_INSTANCE_ID = "1041"; + public static final String REQUEST_TIMED_OUT = "1050"; + + public static final String DISCONNECT_ALREADY_COMPLETE = "1100"; + public static final String CANCEL_ALREADY_COMPLETE = "1110"; + + public static final String LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS = "1400"; + public static final String LOCKED_SAME_ACTION_AND_VNF_ID = "1410"; + + public static final String ERROR_FROM_BPEL = "2000"; + public static final String NO_COMMUNICATION_TO_BPEL = "2010"; + public static final String NO_RESPONSE_FROM_BPEL = "2020"; + + public static final String COULD_NOT_WRITE_TO_REQUESTS_DB = "4000"; + public static final String NO_COMMUNICATION_TO_REQUESTS_DB = "4010"; + public static final String NO_COMMUNICATION_TO_CATALOG_DB = "4020"; + public static final String ERROR_FROM_CATALOG_DB = "4030"; + + public static final String ERROR_FROM_SDNC = "5300"; + public static final String NO_COMMUNICATION_TO_SDNC = "5310"; + public static final String NO_RESPONSE_FROM_SDNC = "5320"; + + public static final String NO_COMMUNICATION_TO_SDNC_ADAPTER = "7000"; + public static final String NO_RESPONSE_FROM_SDNC_ADAPTER = "7010"; + public static final String ERROR_FROM_SDNC_ADAPTER = "7020"; + + public static final String SVC_GENERAL_SERVICE_ERROR = "SVC0001"; + public static final String SVC_BAD_PARAMETER = "SVC0002"; + public static final String SVC_NO_SERVER_RESOURCES = "SVC1000"; + public static final String SVC_DETAILED_SERVICE_ERROR = "SVC2000"; + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java new file mode 100644 index 0000000000..ea26d25212 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/LSInputImpl.java @@ -0,0 +1,122 @@ +/*- + * ============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.apihandler.common; + + +import java.io.InputStream; +import java.io.Reader; + +import org.w3c.dom.ls.LSInput; + +public class LSInputImpl implements LSInput { + + protected String fPublicId; + protected String fSystemId; + protected String fBaseSystemId; + protected InputStream fByteStream; + protected Reader fCharStream; + protected String fData; + protected String fEncoding; + protected boolean fCertifiedText; + + public LSInputImpl () { + } + + @Override + public InputStream getByteStream () { + return fByteStream; + } + + @Override + public void setByteStream (InputStream byteStream) { + fByteStream = byteStream; + } + + @Override + public Reader getCharacterStream () { + return fCharStream; + } + + @Override + public void setCharacterStream (Reader characterStream) { + fCharStream = characterStream; + } + + @Override + public String getStringData () { + return fData; + } + + @Override + public void setStringData (String stringData) { + fData = stringData; + } + + @Override + public String getEncoding () { + return fEncoding; + } + + @Override + public void setEncoding (String encoding) { + fEncoding = encoding; + } + + @Override + public String getPublicId () { + return fPublicId; + } + + @Override + public void setPublicId (String publicId) { + fPublicId = publicId; + } + + @Override + public String getSystemId () { + return fSystemId; + } + + @Override + public void setSystemId (String systemId) { + fSystemId = systemId; + } + + @Override + public String getBaseURI () { + return fBaseSystemId; + } + + @Override + public void setBaseURI (String baseURI) { + fBaseSystemId = baseURI; + } + + @Override + public boolean getCertifiedText () { + return fCertifiedText; + } + + @Override + public void setCertifiedText (boolean certifiedText) { + fCertifiedText = certifiedText; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/PathResourceResolver.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/PathResourceResolver.java new file mode 100644 index 0000000000..ec1e1aee97 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/PathResourceResolver.java @@ -0,0 +1,64 @@ +/*- + * ============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.apihandler.common; + + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.w3c.dom.ls.LSInput; +import org.w3c.dom.ls.LSResourceResolver; + +import org.openecomp.mso.logger.MsoLogger; + +public class PathResourceResolver implements LSResourceResolver { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); + + private String path; + + public PathResourceResolver(String path) { + + this.path = path; + } + + @Override + public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { + + LSInputImpl input = new LSInputImpl(); + + InputStream stream = null; + try { + stream = new FileInputStream(path + systemId); + } catch (FileNotFoundException e) { + msoLogger.debug ("Could not resolve resource based on file: " + path + systemId, e); + } + + input.setPublicId(publicId); + input.setSystemId(systemId); + input.setBaseURI(baseURI); + input.setCharacterStream(new InputStreamReader(stream)); + + return input; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java new file mode 100644 index 0000000000..0b796d5ac2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java @@ -0,0 +1,95 @@ +/*- + * ============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.apihandler.common; + +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.util.Properties; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.utils.CryptoUtils; + +public abstract class RequestClient { + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); + protected MsoJavaProperties props; + protected String url; + protected HttpClient client; + private int type; + + public RequestClient(int type){ + this.type = type; + } + + public void setProps(MsoJavaProperties props) { + this.props = props; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUrl() { + return url; + } + + public int getType(){ + return type; + } + + public HttpClient getClient() { + return client; + } + + public void setClient(HttpClient client) { + this.client = client; + } + + public abstract HttpResponse post(String request, String requestId, String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws ClientProtocolException, IOException; + + public abstract HttpResponse post(String request) throws ClientProtocolException, IOException; + + public abstract HttpResponse post(String requestId, boolean isBaseVfModule, + int recipeTimeout, String requestAction, String serviceInstanceId, + String vnfId, String vfModuleId, String volumeGroupId, String networkId, + String serviceType, String vnfType, String vfModuleType, String networkType, + String requestDetails) + throws ClientProtocolException, IOException; + + protected String getEncryptedPropValue (String prop, String defaultValue, String encryptionKey) { + try { + String result = CryptoUtils.decrypt(prop, encryptionKey); + return result; + } + catch (GeneralSecurityException e) { + msoLogger.debug("Security exception", e); + } + return defaultValue; + } + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java new file mode 100644 index 0000000000..9dc43c7e7a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientFactory.java @@ -0,0 +1,56 @@ +/*- + * ============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.apihandler.common; + + +import java.util.Properties; + +import org.apache.http.impl.client.DefaultHttpClient; + +import org.openecomp.mso.properties.MsoJavaProperties; + +public class RequestClientFactory { + + //based on URI, returns BPEL or Camunda client + public static RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{ + RequestClient retClient; + if(props ==null){ + throw new IllegalStateException("properties is null"); + } + String url = null; + if(orchestrationURI.contains(CommonConstants.BPEL_SEARCH_STR)){ + url = props.getProperty(CommonConstants.BPEL_URL,null) + orchestrationURI; + retClient= new BPELRestClient(); + + }else{ + url = props.getProperty(CommonConstants.CAMUNDA_URL,null) + orchestrationURI; + retClient = new CamundaClient(); + } + retClient.setClient(new DefaultHttpClient()); + retClient.setProps(props); + retClient.setUrl(url); + return retClient; + + } + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java new file mode 100644 index 0000000000..2edf686e07 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ResponseHandler.java @@ -0,0 +1,173 @@ +/*- + * ============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.apihandler.common; + + +import java.io.IOException; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.util.EntityUtils; +import org.codehaus.jackson.map.ObjectMapper; + +import org.openecomp.mso.apihandler.camundabeans.CamundaResponse; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.logger.MessageEnum; + +public class ResponseHandler { + + private CamundaResponse response; + private int status; + private String responseBody=""; + private HttpResponse httpResponse; + private int type; + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); + + public ResponseHandler(HttpResponse httpResponse, int type) { + this.httpResponse = httpResponse; + this.type=type; + parseResponse(); + } + + + private void parseResponse() { + int statusCode = httpResponse.getStatusLine().getStatusCode(); + msoLogger.debug("Returned status is: " + statusCode); + status = setStatus(statusCode); + msoLogger.debug("Parsed status is: " + status); + if(type==CommonConstants.CAMUNDA){ + parseCamunda(); + }else{ + parseBpel(); + } + + } + + + + private void parseCamunda(){ + try{ + HttpEntity entity = httpResponse.getEntity(); + responseBody = EntityUtils.toString(entity); + } catch (IOException e) { + msoLogger.debug("IOException getting Camunda response body", e); + } + + ObjectMapper mapper = new ObjectMapper(); + try { + response = mapper.readValue(responseBody, CamundaResponse.class); + } catch (IOException e) { + msoLogger.debug("IOException getting Camunda response body", e); + } + msoLogger.debug("json response is: " + responseBody); + if(response!=null){ + responseBody = response.getResponse(); + } + msoLogger.debug("response body is: " + responseBody); + + + if(status!=HttpStatus.SC_ACCEPTED){ + msoLogger.error(MessageEnum.APIH_ERROR_FROM_BPEL_SERVER, "Camunda", String.valueOf(status), responseBody, "Camunda", "parseCamunda", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH from Camunda"); + } + } + + private void parseBpel(){ + + HttpEntity bpelEntity = httpResponse.getEntity(); + + try { + if (bpelEntity!=null) { + responseBody = EntityUtils.toString(bpelEntity); + msoLogger.debug("response body is: " + responseBody); + + } + if(status!=HttpStatus.SC_ACCEPTED){ + msoLogger.error(MessageEnum.APIH_ERROR_FROM_BPEL_SERVER, "BPEL", String.valueOf(status), responseBody, "BPEL", "parseBpel", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH from BPEL"); + } + } + catch (IOException e) { + msoLogger.debug("IOException getting BPEL response body", e); + } + } + + + + + private int setStatus(int statusCode){ + int status = 0; + switch(statusCode) { + case HttpStatus.SC_ACCEPTED: + case HttpStatus.SC_OK: + status = HttpStatus.SC_ACCEPTED; + break; + case HttpStatus.SC_BAD_REQUEST: + status = HttpStatus.SC_BAD_REQUEST; + break; + case HttpStatus.SC_UNAUTHORIZED: + case HttpStatus.SC_FORBIDDEN: + status = HttpStatus.SC_INTERNAL_SERVER_ERROR; + break; + case HttpStatus.SC_NOT_FOUND: + status = HttpStatus.SC_NOT_IMPLEMENTED; + break; + case HttpStatus.SC_INTERNAL_SERVER_ERROR: + status = HttpStatus.SC_BAD_GATEWAY; + break; + case HttpStatus.SC_SERVICE_UNAVAILABLE: + status = HttpStatus.SC_SERVICE_UNAVAILABLE; + break; + default: + status = HttpStatus.SC_INTERNAL_SERVER_ERROR; + break; + } + return status; + } + + + public CamundaResponse getResponse() { + return response; + } + + + public void setResponse(CamundaResponse response) { + this.response = response; + } + + + public String getResponseBody() { + return responseBody; + } + + + public void setResponseBody(String responseBody) { + this.responseBody = responseBody; + } + + + public int getStatus() { + return status; + } + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java new file mode 100644 index 0000000000..0136a2d3b7 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/ValidationException.java @@ -0,0 +1,44 @@ +/*- + * ============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.apihandler.common; + + +public class ValidationException extends Exception { + + /** + * This class simply extends Exception (without addition additional functionality) + * to provide an identifier for RequestsDB related exceptions on create, delete, query. + * + * + **/ + + private static final long serialVersionUID = 1L; + private static final String validationFailMessage = "No valid $ELEMENT is specified"; + + public ValidationException (String msg) { + super (validationFailMessage.replaceAll ("\\$ELEMENT", msg)); + } + + public ValidationException (String msg, Exception cause) { + super (validationFailMessage.replaceAll ("\\$ELEMENT", msg), cause); + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java new file mode 100644 index 0000000000..bd73b226a2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/XMLValidator.java @@ -0,0 +1,103 @@ +/*- + * ============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.apihandler.common; + + +import java.io.FileInputStream; +import java.io.IOException; + +import javax.xml.XMLConstants; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +import org.apache.commons.io.IOUtils; +import org.xml.sax.SAXException; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; + +public class XMLValidator { + + private static String XSDS_PATH; + + static { + String prefixMsoPropertiesPath = System.getProperty ("mso.config.path"); + if (prefixMsoPropertiesPath == null) { + prefixMsoPropertiesPath = ""; + } + XSDS_PATH = prefixMsoPropertiesPath + "xsds/"; + } + + private String stringXsd; + private String errorMsg = null; + private SchemaFactory factory; + private Schema schema; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + + public XMLValidator (String xsdFile) { + + try (FileInputStream xsdStream = new FileInputStream (XSDS_PATH + xsdFile)) { + + stringXsd = IOUtils.toString (xsdStream); + + factory = SchemaFactory.newInstance (XMLConstants.W3C_XML_SCHEMA_NS_URI); + factory.setResourceResolver ((new PathResourceResolver (XSDS_PATH))); + factory.setFeature (XMLConstants.FEATURE_SECURE_PROCESSING, true); + + String quotedXsd = stringXsd.replaceAll (""", "\""); + Source src = new StreamSource (new java.io.StringReader (quotedXsd)); + schema = factory.newSchema (src); + + } catch (IOException | SAXException e) { + msoLogger.debug ("Cannot open file " + XSDS_PATH + xsdFile, e); + errorMsg = "ErrorDetails: xsd file " + xsdFile + "could not be opened - " + e.getMessage (); + } + } + + // Returns null when XML valid, otherwise returns error details. + public String isXmlValid (String stringXml) { + try { + if (errorMsg != null && !errorMsg.isEmpty ()) { + return errorMsg; + } + Source src2 = new StreamSource (new java.io.StringReader (stringXml)); + Validator validator = schema.newValidator (); + validator.validate (src2); + + } catch (IOException | SAXException e) { + msoLogger.debug ("Exception: ", e); + return ("ErrorDetails: " + e.getMessage ()); + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_CANNOT_READ_SCHEMA, "", "", MsoLogger.ErrorCode.SchemaError, "APIH cannot read schema file", e); + alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, "Unable to read the schema file"); + return "ErrorDetails: " + "Unable to read the schema file"; + } + + return null; + } +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/package-info.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/package-info.java new file mode 100644 index 0000000000..790edd3f3e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/package-info.java @@ -0,0 +1,25 @@ +/*- + * ============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========================================================= + */ + +/** + * Common classes for API Handlers. + */ +package org.openecomp.mso.apihandler.common; + diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java new file mode 100644 index 0000000000..46e3a4602f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java @@ -0,0 +1,126 @@ +/*- + * ============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.camunda.tests; + + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.Properties; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.ProtocolVersion; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.message.BasicHttpResponse; +import org.apache.http.message.BasicStatusLine; +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.JsonMappingException; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; + +import org.openecomp.mso.apihandler.common.CommonConstants; +import org.openecomp.mso.apihandler.common.RequestClient; +import org.openecomp.mso.apihandler.common.RequestClientFactory; +import org.openecomp.mso.properties.MsoJavaProperties; + + +/** + * This class implements test methods of Camunda Beans. + * + * + */ +public class BPELRestClientTest { + + + + @Mock + private HttpClient mockHttpClient; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void tesBPELPost() throws JsonGenerationException, + JsonMappingException, IOException { + + + String responseBody ="<layer3activate:service-response xmlns:layer3activate=\"http://ecomp.att.com/mso/request/layer3serviceactivate/schema/v1\"" + + "xmlns:reqtype=\"http://ecomp.att.com/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>" + + "<reqtype:request-action>Layer3ServiceActivateRequest</reqtype:request-action>" + + "<reqtype:source>OMX</reqtype:source>" + + "<reqtype:ack-final-indicator>n</reqtype:ack-final-indicator>" + + "</layer3activate:service-response>"; + + HttpResponse mockResponse = createResponse(200, responseBody); + mockHttpClient = Mockito.mock(HttpClient.class); + Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) + .thenReturn(mockResponse); + + String reqXML = "<xml>test</xml>"; + String orchestrationURI = "/active-bpel/services/REST/MsoLayer3ServiceActivate"; + + MsoJavaProperties props = new MsoJavaProperties(); + props.setProperty(CommonConstants.BPEL_URL, "http://localhost:8089"); + props.setProperty("bpelAuth", "786864AA53D0DCD881AED1154230C0C3058D58B9339D2EFB6193A0F0D82530E1"); + + RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); + requestClient.setClient(mockHttpClient); + HttpResponse response = requestClient.post(reqXML, "reqId", "timeout", "version", null, null); + + + int statusCode = response.getStatusLine().getStatusCode(); + assertEquals(requestClient.getType(), CommonConstants.BPEL); + assertEquals(statusCode, HttpStatus.SC_OK); + + + } + + private HttpResponse createResponse(int respStatus, + String respBody) { + HttpResponse response = new BasicHttpResponse( + new BasicStatusLine( + new ProtocolVersion("HTTP", 1, 1), respStatus, "")); + response.setStatusCode(respStatus); + try { + response.setEntity(new StringEntity(respBody)); + response.setHeader("Content-Type", "text/xml"); + } catch (Exception e) { + e.printStackTrace(); + } + return response; + } + + + + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java new file mode 100644 index 0000000000..d8c0e52005 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java @@ -0,0 +1,123 @@ +/*- + * ============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.camunda.tests; + + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import java.util.Properties; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.ProtocolVersion; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.message.BasicHttpResponse; +import org.apache.http.message.BasicStatusLine; +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.JsonMappingException; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; + +import org.openecomp.mso.apihandler.common.CommonConstants; +import org.openecomp.mso.apihandler.common.RequestClient; +import org.openecomp.mso.apihandler.common.RequestClientFactory; +import org.openecomp.mso.properties.MsoJavaProperties; + + +/** + * This class implements test methods of Camunda Beans. + * + * + */ +public class CamundaClientTest { + + + + @Mock + private HttpClient mockHttpClient; + + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void tesCamundaPost() throws JsonGenerationException, + JsonMappingException, IOException { + + + String responseBody ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; + + HttpResponse mockResponse = createResponse(200, responseBody); + mockHttpClient = Mockito.mock(HttpClient.class); + Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) + .thenReturn(mockResponse); + + String reqXML = "<xml>test</xml>"; + String orchestrationURI = "/engine-rest/process-definition/key/dummy/start"; + + MsoJavaProperties props = new MsoJavaProperties(); + props.setProperty(CommonConstants.CAMUNDA_URL, "http://localhost:8089"); + + RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); + requestClient.setClient(mockHttpClient); + HttpResponse response = requestClient.post(reqXML, "reqId", "timeout", "version", null, null); + + + int statusCode = response.getStatusLine().getStatusCode(); + assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); + assertEquals(statusCode, HttpStatus.SC_OK); + + props.setProperty (CommonConstants.CAMUNDA_AUTH, "ABCD1234"); + requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); + requestClient.setClient(mockHttpClient); + response = requestClient.post(null, "reqId", null, null, null, null); + assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); + assertEquals(statusCode, HttpStatus.SC_OK); + } + + private HttpResponse createResponse(int respStatus, + String respBody) { + HttpResponse response = new BasicHttpResponse( + new BasicStatusLine( + new ProtocolVersion("HTTP", 1, 1), respStatus, "")); + response.setStatusCode(respStatus); + try { + response.setEntity(new StringEntity(respBody)); + response.setHeader("Content-Type", "application/json"); + } catch (Exception e) { + e.printStackTrace(); + } + return response; + } + + + + + +} 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 new file mode 100644 index 0000000000..bd2fee6f1e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaRequestTest.java @@ -0,0 +1,81 @@ +/*- + * ============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.camunda.tests; + + + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig; +import org.junit.Test; + +import org.openecomp.mso.apihandler.camundabeans.CamundaInput; +import org.openecomp.mso.apihandler.camundabeans.CamundaRequest; +import org.openecomp.mso.apihandler.common.CommonConstants; + +/** + * This class implements test methods of Camunda Beans. + * + * + */ +public class CamundaRequestTest { + + @Test + public final void testSerialization() throws JsonGenerationException, + JsonMappingException, IOException { + CamundaRequest camundaRequest = new CamundaRequest(); + CamundaInput camundaInput = new CamundaInput(); + CamundaInput host = new CamundaInput(); + CamundaInput schema = new CamundaInput(); + CamundaInput reqid = new CamundaInput(); + CamundaInput svcid = new CamundaInput(); + CamundaInput timeout = new CamundaInput(); + camundaInput + .setValue("<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>"); + camundaRequest.setServiceInput(camundaInput); + host.setValue("localhost"); + camundaRequest.setHost(host); + schema.setValue("v1"); + camundaRequest.setSchema(schema); + reqid.setValue("reqid123"); + camundaRequest.setReqid(reqid); + svcid.setValue("svcid123"); + camundaRequest.setSvcid(svcid); + timeout.setValue(""); + camundaRequest.setTimeout(timeout); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true); + + 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\"}}}", + json); + + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java new file mode 100644 index 0000000000..aff8ab2a2c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java @@ -0,0 +1,59 @@ +/*- + * ============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.camunda.tests; + + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Test; + +import org.openecomp.mso.apihandler.camundabeans.CamundaResponse; + +/** + * This class implements test methods of Camunda Beans. + * + * + */ +public class CamundaResponseTest { + + @Test + public final void testDeserialization() throws JsonGenerationException, + JsonMappingException, IOException { + ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally + mapper.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + + String responseBody = "{ \"response\": \"<xml>xml</xml>\","+ + "\"messageCode\": 200,"+ + "\"message\": \"Successfully started the process\"," + + "\"processInstanceID\":null,\"variables\":null}"; + + CamundaResponse response = mapper.readValue(responseBody, CamundaResponse.class); + assertEquals(response.toString(), "CamundaResponse [response=<xml>xml</xml>, messageCode=200, message=Successfully started the process]"); + + } + +} 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 new file mode 100644 index 0000000000..ba2c5524b5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/ResponseHandlerTest.java @@ -0,0 +1,131 @@ +/*- + * ============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.camunda.tests; + + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.ProtocolVersion; +import org.apache.http.entity.StringEntity; +import org.apache.http.message.BasicHttpResponse; +import org.apache.http.message.BasicStatusLine; +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.map.JsonMappingException; +import org.junit.Test; + +import org.openecomp.mso.apihandler.common.ResponseHandler; + +/** + * This class implements test methods of CamundaResoponseHandler. + * + * + */ +public class ResponseHandlerTest { + + @Test + public void tesParseCamundaResponse () throws JsonGenerationException, JsonMappingException, IOException { + // String body + // ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; + + String body = "{ \"response\": \"<xml>xml</xml>\"," + "\"messageCode\": 200," + + "\"message\": \"Successfully started the process\"}"; + + HttpResponse response = createResponse (200, body, "application/json"); + + ResponseHandler respHandler = new ResponseHandler (response, 1); + + int status = respHandler.getStatus (); + assertEquals (status, HttpStatus.SC_ACCEPTED); + assertEquals (respHandler.getResponse ().getMessage (), "Successfully started the process"); + + } + + @Test + public void tesParseBpelResponse () throws 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\"" + + "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>" + + "<reqtype:request-action>Layer3ServiceActivateRequest</reqtype:request-action>" + + "<reqtype:source>OMX</reqtype:source>" + + "<reqtype:ack-final-indicator>n</reqtype:ack-final-indicator>" + + "</layer3activate:service-response>"; + + HttpResponse response = createResponse (200, body, "text/xml"); + + ResponseHandler respHandler = new ResponseHandler (response, 0); + + int status = respHandler.getStatus (); + assertEquals (status, HttpStatus.SC_ACCEPTED); + assertTrue (respHandler.getResponseBody () != null); + } + + @Test + public void tes404ErrorResponse () throws JsonGenerationException, JsonMappingException, IOException { + + + HttpResponse response = createResponse (HttpStatus.SC_NOT_FOUND, "<html>error</html>", "text/html"); + ResponseHandler respHandler = new ResponseHandler (response, 1); + + int status = respHandler.getStatus (); + + assertEquals (HttpStatus.SC_NOT_IMPLEMENTED, status); + + } + + @Test + public void tesGenricErrorResponse () throws JsonGenerationException, JsonMappingException, IOException { + + String body = "{ \"response\": \"<xml>xml</xml>\"," + "\"messageCode\": 500," + + "\"message\": \"Something went wrong\"}"; + + HttpResponse response = createResponse (500, body, "application/json"); + + ResponseHandler respHandler = new ResponseHandler (response, 1); + + int status = respHandler.getStatus (); + assertEquals (HttpStatus.SC_BAD_GATEWAY, status); + assertEquals (respHandler.getResponse ().getMessage (), "Something went wrong"); + System.out.println (respHandler.getResponseBody ()); + + } + + private HttpResponse createResponse (int respStatus, String respBody, String contentType) { + HttpResponse response = new BasicHttpResponse (new BasicStatusLine (new ProtocolVersion ("HTTP", 1, 1), + respStatus, + "")); + response.setStatusCode (respStatus); + try { + response.setEntity (new StringEntity (respBody)); + response.setHeader ("Content-Type", contentType); + } catch (Exception e) { + e.printStackTrace (); + } + return response; + } + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/resources/logback-test.xml b/mso-api-handlers/mso-api-handler-common/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..d2c17192ea --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/test/resources/logback-test.xml @@ -0,0 +1,48 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<configuration > + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration> diff --git a/mso-api-handlers/mso-api-handler-infra/WebContent/META-INF/MANIFEST.MF b/mso-api-handlers/mso-api-handler-infra/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5e9495128c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0
+Class-Path:
+
diff --git a/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/beans.xml b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/beans.xml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/beans.xml diff --git a/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/jboss-deployment-structure.xml b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..88d5024f0d --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,17 @@ +<jboss-deployment-structure>
+ <deployment>
+ <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
+ <exclusions>
+ <module name="org.apache.log4j" />
+ <module name="org.slf4j" />
+ <module name="org.slf4j.impl" />
+ </exclusions>
+ <dependencies>
+ <module name="org.jboss.jandex" slot="main" />
+ <module name="org.javassist" slot="main" />
+ <module name="org.antlr" slot="main" />
+ <module name="org.dom4j" slot="main" />
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
+
diff --git a/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/jboss-web.xml b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..e1023bfe19 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?>
+
+<jboss-web>
+ <context-root>ecomp/mso/infra</context-root>
+ <security-domain>other</security-domain>
+</jboss-web>
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/web.xml b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..e34740d613 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/WebContent/WEB-INF/web.xml @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
+ <display-name>MSO API Handler Infra</display-name>
+
+
+ <context-param>
+ <param-name>resteasy.jndi.resources</param-name>
+ <param-value>java:module/MsoPropertiesFactory</param-value>
+ </context-param>
+
+ <!-- enable the Asynchronous Job Service -->
+ <context-param>
+ <param-name>resteasy.async.job.service.enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!-- The next context parameters are all optional.
+ Their default values are shown as example param-values -->
+
+ <!-- How many jobs results can be held in memory at once? -->
+ <context-param>
+ <param-name>resteasy.async.job.service.max.job.results</param-name>
+ <param-value>100</param-value>
+ </context-param>
+
+ <!-- Maximum wait time on a job when a client is querying for it -->
+ <context-param>
+ <param-name>resteasy.async.job.service.max.wait</param-name>
+ <param-value>300000</param-value>
+ </context-param>
+
+ <!-- Thread pool size of background threads that run the job -->
+ <context-param>
+ <param-name>resteasy.async.job.service.thread.pool.size</param-name>
+ <param-value>100</param-value>
+ </context-param>
+
+ <!-- Set the base path for the Job uris -->
+ <context-param>
+ <param-name>resteasy.async.job.service.base.path</param-name>
+ <param-value>/asynch/jobs</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!--
+ <context-param>
+ <param-name>resteasy.servlet.mapping.prefix</param-name>
+ <param-value>/v1</param-value>
+ </context-param>
+ -->
+ <context-param>
+ <param-name>log.configuration</param-name>
+ <param-value>logback.apihandler-infra.xml</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>mso.configuration</param-name>
+ <param-value>MSO_PROP_APIHANDLER_INFRA=mso.apihandler-infra.properties,MSO_PROP_TOPOLOGY=topology.properties</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>resteasy.resources</param-name>
+ <param-value>org.openecomp.mso.logger.MsoLoggingServlet</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>
+ org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
+ </listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>msoapihandler-infra-servlet</servlet-name>
+ <servlet-class>
+ org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
+ </servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>msoapihandler-infra-servlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>HealthcheckNoAuth</web-resource-name>
+ <description>No Authentication for Healthcheck</description>
+ <url-pattern>/healthcheck</url-pattern>
+ <url-pattern>/nodehealthcheck</url-pattern>
+ <url-pattern>/globalhealthcheck</url-pattern>
+ <http-method>GET</http-method>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>SiteStatus</web-resource-name>
+ <description>SiteStatus APIs</description>
+ <url-pattern>/setStatus/*</url-pattern>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>SiteControl-Client</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>HTTPBasicAuth</web-resource-name>
+ <description>Authentication for Infra Portal</description>
+ <url-pattern>/*</url-pattern>
+ <http-method>POST</http-method>
+ <http-method>GET</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>InfraPortal-Client</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>ApplicationRealm</realm-name>
+ </login-config>
+ <security-role>
+ <role-name>InfraPortal-Client</role-name>
+ </security-role>
+ <security-role>
+ <role-name>SiteControl-Client</role-name>
+ </security-role>
+
+ <filter>
+ <filter-name>LogFilter</filter-name>
+ <filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>LogFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+</web-app>
diff --git a/mso-api-handlers/mso-api-handler-infra/WebContent/check.html b/mso-api-handlers/mso-api-handler-infra/WebContent/check.html new file mode 100644 index 0000000000..ea2f0e265a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/WebContent/check.html @@ -0,0 +1,11 @@ +<!DOCTYPE html>
+<html>
+<head>
+<meta charset="ISO-8859-1">
+<title>Health Check</title>
+</head>
+<body>
+Application ready
+</body>
+</html>
+
diff --git a/mso-api-handlers/mso-api-handler-infra/WebContent/index.xhtml b/mso-api-handlers/mso-api-handler-infra/WebContent/index.xhtml new file mode 100644 index 0000000000..f902af8cc0 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/WebContent/index.xhtml @@ -0,0 +1,19 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<f:loadBundle basename="resources.application" var="msg"/>
+
+<head>
+ <title><h:outputText value="#{msg.welcomeTitle}" /></title>
+</head>
+
+<body>
+<h3><h:outputText value="#{msg.welcomeHeading}" /></h3>
+<p><h:outputText value="#{msg.welcomeMessage}" /></p>
+</body>
+</html>
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml new file mode 100644 index 0000000000..74ec57dbc7 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@ -0,0 +1,108 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-api-handlers</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + + + <artifactId>mso-api-handler-infra</artifactId> + + <name>mso-api-handler-infra</name> + <description>ECOMP MSO API Handler Infra</description> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>resteasy-jaxrs</artifactId> + <version>3.0.19.Final</version> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>2.2.0.Final</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>javax.activation</groupId> + <artifactId>activation</artifactId> + <version>1.1.1</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-catalog-db</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-requests-db</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-api-handler-common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + + </dependencies> + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.3</version> + <configuration> + <warSourceDirectory>WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + <attachClasses>true</attachClasses> + </configuration> + </plugin> + </plugins> + </build> + <packaging>war</packaging> +</project>
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java new file mode 100644 index 0000000000..8df4c87898 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java @@ -0,0 +1,31 @@ +/*- + * ============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.apihandlerinfra; + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum Action { + createInstance, + updateInstance, + deleteInstance, + configureInstance +} 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 new file mode 100644 index 0000000000..34d739b310 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Constants.java @@ -0,0 +1,49 @@ +/*- + * ============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.apihandlerinfra; + + +public class Constants { + + public static final String VNF_TYPES_PATH = "/{version: v1|v2|v3}/vnf-types"; + 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_-]*$"; + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java new file mode 100644 index 0000000000..0ae1695516 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java @@ -0,0 +1,112 @@ +/*- + * ============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.apihandlerinfra; + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.core.Response; +import org.openecomp.mso.HealthCheckUtils; + +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.utils.UUIDChecker; + +@Path("/") +public class HealthcheckHandler { + + public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + @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("/nodehealthcheck") + @Produces("text/html") + public Response nodeHealthcheck () { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("NodeHealthcheck"); + // Generate a Request Id + String requestId = UUIDChecker.generateUUID(msoLogger); + HealthCheckUtils healthCheck = new HealthCheckUtils (); + if (!healthCheck.siteStatusCheck (msoLogger, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + if (healthCheck.verifyNodeHealthCheck(HealthCheckUtils.NodeType.APIH, requestId)) { + msoLogger.debug("nodeHealthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } else { + msoLogger.debug("nodeHealthcheck - At leaset one of the sub-modules is not available."); + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + } + + @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; + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/InfraUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/InfraUtils.java new file mode 100644 index 0000000000..37cbb4de66 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/InfraUtils.java @@ -0,0 +1,56 @@ +/*- + * ============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.apihandlerinfra; + + + +import org.openecomp.mso.properties.MsoJavaProperties; + +public class InfraUtils { + public static boolean isActionAllowed(MsoJavaProperties props, String requestType, String version, String action) { + // Check for allowable actions + String actionsPropertyName = requestType + "." + version + ".ApiAllowableActions"; + String allowableActions = props.getProperty(actionsPropertyName, null); + boolean actionAllowed = false; + if (allowableActions != null) { + String allowableActionsList[] = allowableActions.split(","); + for (int i=0; i<allowableActionsList.length; i++) { + if (action.equals (allowableActionsList[i])) { + actionAllowed = true; + break; + } + } + } + else { + actionAllowed = true; + } + return actionAllowed; + } + + // Checks if the name is acceptable for heat stack + public static boolean isValidHeatName(String name) { + if (name.matches("^[a-zA-Z][a-zA-Z0-9_\\.-]*$")) + return true; + return false; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java new file mode 100644 index 0000000000..cdccaf27e3 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Messages.java @@ -0,0 +1,49 @@ +/*- + * ============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.apihandlerinfra; + + +import java.util.HashMap; +import java.util.Map; + +import org.openecomp.mso.apihandler.common.ErrorNumbers; + +public class Messages { + + public static final Map<String,String> errors = new HashMap<String,String>(); + static { + errors.put(ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + "_service", "Service request FAILED schema validation. %s"); + errors.put(ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + "_feature", "Feature request FAILED schema validation. %s"); + errors.put(ErrorNumbers.RECIPE_DOES_NOT_EXIST, "Recipe for %s-type and action specified does not exist in catalog %s"); + errors.put(ErrorNumbers.SERVICE_PARAMETERS_FAILED_SCHEMA_VALIDATION, "Service specific parameters passed in request FAILED schema validation. %s"); + + errors.put(ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS, "%s-name (%s) is locked (status = %s) because already working on a CREATE request with same %s-name."); + errors.put(ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID, "%s-id (%s) is locked (status = %s) because already working on a request with same action (%s) for this %s-id."); + errors.put(ErrorNumbers.REQUEST_TIMED_OUT, "Service request timed out before completing"); + errors.put(ErrorNumbers.ERROR_FROM_BPEL, "BPEL returned an error: %s"); + errors.put(ErrorNumbers.NO_COMMUNICATION_TO_BPEL, "Could not communicate with BPEL %s"); + errors.put(ErrorNumbers.NO_RESPONSE_FROM_BPEL, "No response from BPEL %s"); + errors.put(ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, "Could not insert or update record in MSO_REQUESTS DB %s"); + errors.put(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, "Could not communicate with MSO_REQUESTS DB %s"); + errors.put(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB, "Could not communicate with MSO_CATALOG DB %s"); + errors.put(ErrorNumbers.ERROR_FROM_CATALOG_DB, "Received error from MSO_CATALOG DB %s"); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ModelType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ModelType.java new file mode 100644 index 0000000000..2f01c4fcdb --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ModelType.java @@ -0,0 +1,32 @@ +/*- + * ============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.apihandlerinfra; + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum ModelType { + service, + vnf, + vfModule, + volumeGroup, + network +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoException.java new file mode 100644 index 0000000000..2ef1e4a0ec --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoException.java @@ -0,0 +1,26 @@ +/*- + * ============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.apihandlerinfra; + +public enum MsoException { + ServiceException, + PolicyException, +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoPropertiesUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoPropertiesUtils.java new file mode 100644 index 0000000000..0dd9a03c90 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoPropertiesUtils.java @@ -0,0 +1,59 @@ +/*- + * ============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.apihandlerinfra; + +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +public class MsoPropertiesUtils { + + private final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory (); + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + private static boolean noProperties = true; + + public synchronized static MsoJavaProperties loadMsoProperties () { + MsoJavaProperties msoProperties; + try { + msoProperties = msoPropertiesFactory.getMsoJavaProperties (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; + } + } + + public synchronized static final boolean getNoPropertiesState() { + return noProperties; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java new file mode 100644 index 0000000000..55c12eb6ff --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java @@ -0,0 +1,850 @@ +/*- + * ============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.apihandlerinfra; + +import java.io.StringReader; +import java.io.StringWriter; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.StringTokenizer; + +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.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.map.ObjectMapper; +import org.codehaus.jackson.map.SerializationConfig.Feature; +import org.codehaus.jackson.map.annotate.JsonSerialize; +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; +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.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.logger.MessageEnum; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.requestsdb.HibernateUtil; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.utils.UUIDChecker; + +public class MsoRequest { + + private String requestId; + private String requestXML; + private String requestJSON; + private String requestUri; + private VnfRequest vnfReq; + private RequestInfo requestInfo; + private ModelInfo modelInfo; + private CloudConfiguration cloudConfiguration ; + private VnfInputs vnfInputs; + private String vnfParams; + private Action action; + private String errorMessage; + private String errorCode; + private String httpResponse; + private String responseBody; + private RequestStatusType status; + private ServiceInstancesRequest sir; + private long startTime; + private long progress = Constants.PROGRESS_REQUEST_RECEIVED; + private String serviceInstanceType; + private String vnfType; + private String vfModuleType; + private String vfModuleModelName; + private String networkType; + private String asdcServiceModelVersion; + private String requestScope; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + private static final String NOT_PROVIDED = "not provided"; + + MsoRequest (String requestId) { + this.requestId = requestId; + Calendar startTimeCalendar = Calendar.getInstance (); + this.startTime = startTimeCalendar.getTimeInMillis (); + MsoLogger.setLogContext (requestId, null); + + } + + MsoRequest () { + + Calendar startTimeCalendar = Calendar.getInstance (); + this.startTime = startTimeCalendar.getTimeInMillis (); + 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); + } + + String requestErrorStr = null; + + try{ + 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); + } + + + return Response.status (httpResponseCode).entity(requestErrorStr).build (); + + } + + + // Parse request JSON + void parse (ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, Action action) throws ValidationException { + + msoLogger.debug ("Validating the Service Instance request"); + + this.sir = sir; + this.action = action; + + try{ + 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"); + } + + 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")); + } + } + + this.modelInfo = sir.getRequestDetails().getModelInfo(); + + if (this.modelInfo == null) { + throw new ValidationException ("model-info"); + } + + this.requestInfo = sir.getRequestDetails().getRequestInfo(); + + if (this.requestInfo == null) { + throw new ValidationException ("requestInfo"); + } + + if (modelInfo.getModelType () == null) { + throw new ValidationException ("modelType"); + } + + this.requestScope = modelInfo.getModelType().name(); + + if (empty (modelInfo.getModelInvariantId ()) && !(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"); + } + + if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) { + throw new ValidationException ("modelCustomizationName"); + } + + this.cloudConfiguration = sir.getRequestDetails ().getCloudConfiguration (); + if (!requestScope.equalsIgnoreCase (ModelType.service.name ()) && 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 (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(requestScope.equalsIgnoreCase(ModelType.service.name())){ + 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"); + } + + 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"); + } + + if (empty (requestInfo.getSource ())) { + throw new ValidationException ("source"); + } + + + RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); + + String serviceModelName = null; + String vnfModelName = null; + String asdcServiceModelVersion = null; + String volumeGroupId = null; + boolean isRelatedServiceInstancePresent = false; + boolean isRelatedVnfInstancePresent = false; + + if (instanceList != null) { + for(RelatedInstanceList relatedInstanceList : instanceList){ + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + + 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"); + } + + if (!UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) { + throw new ValidationException ("instanceId format in relatedInstance"); + } + + if (relatedInstance.getModelInfo () == null) { + throw new ValidationException ("modelInfo in relatedInstance"); + } + + if (relatedInstance.getModelInfo ().getModelType () == null) { + throw new ValidationException ("modelType in relatedInstance"); + } + + 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"); + } + } + + 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 (action != Action.deleteInstance && !requestScope.equalsIgnoreCase(ModelType.service.name ()) && + !requestScope.equalsIgnoreCase(ModelType.network.name ())) { + throw new ValidationException ("related instances"); + } + + } + + public Map<String, List<String>> getOrchestrationFilters (MultivaluedMap<String, String> queryParams) throws ValidationException { + + 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); + } + + }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.beginTransaction (); + + InfraActiveRequests aq = new InfraActiveRequests (); + aq.setRequestId (requestId); + + aq.setRequestAction(action.name()); + aq.setAction(action.name()); + + Timestamp startTimeStamp = new Timestamp (Calendar.getInstance ().getTimeInMillis ()); + + 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 (modelInfo != null) { + aq.setRequestScope(requestScope); + } + + if (cloudConfiguration != null) { + if(cloudConfiguration.getLcpCloudRegionId() != null) { + aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId()); + } + + if(cloudConfiguration.getTenantId() != null) { + aq.setTenantId(cloudConfiguration.getTenantId()); + } + + } + + if(sir.getServiceInstanceId() != null){ + aq.setServiceInstanceId(sir.getServiceInstanceId()); + } + + if(sir.getVnfInstanceId() != null){ + aq.setVnfId(sir.getVnfInstanceId()); + } + + + if(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(requestScope.equalsIgnoreCase(ModelType.volumeGroup.name())){ + 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(requestScope.equalsIgnoreCase(ModelType.vnf.name())){ + aq.setVnfName(requestInfo.getInstanceName()); + RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); + + if (instanceList != null) { + + for(RelatedInstanceList relatedInstanceList : instanceList){ + + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){ + aq.setVnfType(vnfType); + } + } + } + //aq.setVnfType(sir.getRequestDetails().getRelatedInstanceList()); + + } + + aq.setRequestBody (this.requestJSON); + + + aq.setRequestStatus (status.toString ()); + aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); + + if ((status == Status.FAILED) || (status == Status.COMPLETE)) { + aq.setStatusMessage (this.errorMessage); + aq.setResponseBody (this.responseBody); + aq.setProgress(new Long(100)); + + Calendar endTime = Calendar.getInstance (); + Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ()); + aq.setEndTime (endTimeStamp); + } + + msoLogger.debug ("About to insert a record"); + + session.save (aq); + session.getTransaction ().commit (); + session.close (); + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e); + if (session != null) { + session.close (); + } + if (!status.equals (Status.FAILED)) { + throw e; + } + } + } + + public void updateFinalStatus (Status status) { + int result = 0; + try { + 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 when updating record in DB"); + msoLogger.debug ("Exception: ", e); + } + } + + public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { + return buildResponseWithError (httpResponseCode, errorCode, inProgress, null); + } + + public Response buildResponseWithError (int httpResponseCode, + String errorCode, + InfraActiveRequests inProgress, + String errorString) { + + + + // Log the failed request into the MSO Requests database + + return Response.status (httpResponseCode).entity (null).build (); + + } + + public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) { + + + + return Response.status (httpResponseCode).entity (null).build (); + } + + public String getRequestUri () { + return requestUri; + } + + public void setRequestUri (String requestUri) { + this.requestUri = requestUri; + } + + public VnfInputs getVnfInputs () { + return vnfInputs; + } + + public RequestInfo getRequestInfo () { + return requestInfo; + } + + public String getResponseBody () { + return responseBody; + } + + public void setResponseBody (String responseBody) { + this.responseBody = responseBody; + } + + public String getHttpResponse () { + return httpResponse; + } + + public void setHttpResponse (String httpResponse) { + this.httpResponse = httpResponse; + } + + public String getRequestId () { + return requestId; + } + + public String getRequestXML () { + return requestXML; + } + + public void setRequestXML (String requestXML) { + this.requestXML = requestXML; + } + + public RequestStatusType getStatus () { + return status; + } + + public String getServiceType () { + if (this.vnfInputs.getServiceType () != null) + return this.vnfInputs.getServiceType (); + if (this.vnfInputs.getServiceId () != null) + return this.vnfInputs.getServiceId (); + return null; + } + + public void setStatus (RequestStatusType status) { + this.status = status; + switch (status) { + case FAILED: + case COMPLETE: + this.progress = Constants.PROGRESS_REQUEST_COMPLETED; + break; + case IN_PROGRESS: + this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; + break; + } + } + + public ModelInfo getModelInfo() { + return modelInfo; + } + + public ServiceInstancesRequest getServiceInstancesRequest() { + return sir; + } + + public String getServiceInstanceType () { + return serviceInstanceType; + } + + public String getNetworkType () { + return networkType; + } + + public String getVnfType () { + return vnfType; + } + + public String getVfModuleModelName () { + return vfModuleModelName; + } + + public String getVfModuleType () { + return vfModuleType; + } + + public String getAsdcServiceModelVersion () { + return asdcServiceModelVersion; + } + + public static String domToStr (Document doc) { + if (doc == null) { + return null; + } + + try { + StringWriter sw = new StringWriter (); + StreamResult sr = new StreamResult (sw); + TransformerFactory tf = TransformerFactory.newInstance (); + Transformer t = tf.newTransformer (); + t.setOutputProperty (OutputKeys.STANDALONE, "yes"); + NodeList nl = doc.getDocumentElement ().getChildNodes (); + DOMSource source = null; + for (int x = 0; x < nl.getLength (); x++) { + Node e = nl.item (x); + if (e instanceof Element) { + source = new DOMSource (e); + break; + } + } + if (source != null) { + t.transform (source, sr); + + String s = sw.toString (); + return s; + } + + return null; + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in domToStr", e); + } + return null; + } + + public void addBPMNSpecificInputs(String personaModelId, String personaModelVersion, Boolean isBaseVfModule, + String vnfPersonaModelId, String vnfPersonaModelVersion) { + vnfInputs.setPersonaModelId(personaModelId); + vnfInputs.setPersonaModelVersion(personaModelVersion); + vnfInputs.setIsBaseVfModule(isBaseVfModule); + vnfInputs.setVnfPersonaModelId(vnfPersonaModelId); + vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion); + + this.vnfReq.setVnfInputs(vnfInputs); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (this.vnfReq, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Exception: ", e); + } + + this.requestXML = stringWriter.toString (); + msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); + + + } + + private static boolean empty(String s) { + return (s == null || s.trim().isEmpty()); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java new file mode 100644 index 0000000000..59b93eadde --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java @@ -0,0 +1,333 @@ + +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.io.StringReader; +import java.io.StringWriter; +import java.util.LinkedList; +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.sax.SAXSource; + +import org.apache.http.HttpStatus; +import org.xml.sax.InputSource; + +import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.apihandlerinfra.networkbeans.ActionType; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkInputs; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkOutputs; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequests; +import org.openecomp.mso.apihandlerinfra.networkbeans.ObjectFactory; +import org.openecomp.mso.apihandlerinfra.networkbeans.RequestInfo; +import org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.InfraRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.utils.UUIDChecker; + +@Path("/{version: v1|v2|v3}/network-request") +public class NetworkInfoHandler { + + protected ObjectFactory beansObjectFactory = new ObjectFactory (); + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + @GET + public Response queryFilters (@QueryParam("network-type") String networkType, + @QueryParam("service-type") String serviceType, + @QueryParam("aic-node-clli") String aicNodeClli, + @QueryParam("tenant-id") String tenantId, + @PathParam("version") String version) { + MsoLogger.setServiceName ("QueryFilters"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + long startTime = System.currentTimeMillis (); + + msoLogger.debug ("Incoming request received for query filters with Network type " + networkType + + " - service type " + + serviceType + + " - aicNodeClli " + + aicNodeClli + + " - tenant id " + + tenantId); + Response response = null; + if (networkType != null) { + response = this.getRequestList ("vnfType", networkType, version); + } else { + response = queryGenericFilters (serviceType, aicNodeClli, tenantId, version); + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + @GET + @Path(Constants.REQUEST_ID_PATH) + public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + MsoLogger.setServiceName ("GetRequest"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for getRequest with requestId=" + requestId + ", version = " + version); + long startTime = System.currentTimeMillis (); + + Response response = getRequestGeneric (requestId, version); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + protected MsoLogger getMsoLogger () { + return msoLogger; + } + + protected void fillNetworkRequest (NetworkRequest qr, InfraRequests ar, String version) { + NetworkInputs vi = beansObjectFactory.createNetworkInputs (); + + if (ar.getVnfId () != null) { + vi.setNetworkId (ar.getVnfId ()); + } + if (ar.getVnfName () != null) { + vi.setNetworkName (ar.getVnfName ()); + } + if (ar.getVnfType () != null) { + vi.setNetworkType (ar.getVnfType ()); + } + if (version.equals(Constants.SCHEMA_VERSION_V1)) { + if (ar.getServiceType () != null) { + vi.setServiceType (ar.getServiceType ()); + } + if (ar.getAicNodeClli () != null) { + vi.setAicNodeClli (ar.getAicNodeClli ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V2)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V3)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getServiceInstanceId () != null) { + vi.setServiceInstanceId (ar.getServiceInstanceId ()); + } + + } + + if (ar.getTenantId () != null) { + vi.setTenantId (ar.getTenantId ()); + } + if (ar.getProvStatus () != null) { + vi.setProvStatus (ar.getProvStatus ()); + } + qr.setNetworkInputs (vi); + + qr.setNetworkParams (ar.getVnfParams ()); + + try { + String networkoutputs = ar.getVnfOutputs (); + if (networkoutputs != null && networkoutputs.length () > 0) { + msoLogger.debug ("Read NETWORK outputs: " + networkoutputs); + NetworkOutputs networkOutput = null; + + // Now unmarshal it into network outputs + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkOutputs.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); + + InputSource inputSource = new InputSource (new StringReader (networkoutputs)); + SAXSource source = new SAXSource (inputSource); + + networkOutput = jaxbUnmarshaller.unmarshal (source, NetworkOutputs.class).getValue (); + + } catch (Exception e) { + msoLogger.debug ("Validation failed", e); + throw new ValidationException ("format for network outputs"); + } + + qr.setNetworkOutputs (networkOutput); + } + } catch (Exception e) { + msoLogger.debug ("exception reading networkOutputs Clob", e); + } + } + + protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String version) { + if (serviceType != null) { + return this.getRequestList ("serviceType", serviceType, version); + } + if (aicNodeClli != null) { + return this.getRequestList ("aicNodeClli", aicNodeClli, version); + } + if (tenantId != null) { + return this.getRequestList ("tenantId", tenantId, version); + } + return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); + } + + protected Response getRequestGeneric (String requestId, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + MsoLogger.setLogContext (requestId, null); + getMsoLogger ().debug ("getRequest: " + requestId); + + String responseString = null; + + InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, "NETWORK"); + if (activeReq != null) { + // build response for active + responseString = infraRequestsResponse (activeReq, version); + return Response.status (HttpStatus.SC_OK).entity (responseString).build (); + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + protected Response getRequestList (String queryAttribute, String queryValue, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); + + List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute, + queryValue, + "NETWORK"); + + List <NetworkRequest> queryResponseList = new LinkedList <NetworkRequest> (); + + if (activeReqList != null) { + // build response for active + queryResponseList = infraRequestsResponses (activeReqList, version); + + } + + if (queryResponseList != null && !queryResponseList.isEmpty ()) { + String result = this.translateNetworkRequests (queryResponseList); + return Response.status (HttpStatus.SC_OK).entity (result).build (); + + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + private NetworkRequest fillGeneric (InfraRequests ar) { + NetworkRequest qr = beansObjectFactory.createNetworkRequest (); + RequestInfo ri = beansObjectFactory.createRequestInfo (); + ri.setRequestId (ar.getRequestId ()); + ri.setAction (ActionType.fromValue (ar.getAction ())); + ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); + if (ar.getProgress () != null) { + ri.setProgress (ar.getProgress ().intValue ()); + } + if (ar.getSource () != null) { + ri.setSource (ar.getSource ()); + } + + ri.setStartTime (ar.getStartTime ().toString ()); + if (ar.getEndTime () != null) { + ri.setEndTime (ar.getEndTime ().toString ()); + } + + if (ar.getStatusMessage () != null) { + ri.setStatusMessage (ar.getStatusMessage ()); + } + qr.setRequestInfo (ri); + return qr; + } + + private List <NetworkRequest> infraRequestsResponses (List <? extends InfraRequests> arList, String version) { + List <NetworkRequest> queryResponseList = new LinkedList <NetworkRequest> (); + + for (InfraRequests ar : arList) { + NetworkRequest qr = fillGeneric (ar); + fillNetworkRequest (qr, ar, version); + queryResponseList.add (qr); + } + return queryResponseList; + } + + private String translateNetworkRequests (List <NetworkRequest> queryResponseList) { + NetworkRequests queryResponses = new NetworkRequests (); + for (int i = 0; i < queryResponseList.size (); i++) { + queryResponses.getNetworkRequest ().add (queryResponseList.get (i)); + } + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequests.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (queryResponses, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + return stringWriter.toString (); + } + + private String infraRequestsResponse (InfraRequests ar, String version) { + NetworkRequest qr = fillGeneric (ar); + fillNetworkRequest (qr, ar, version); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.marshal (qr, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + String response = stringWriter.toString (); + return response; + } +} 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 new file mode 100644 index 0000000000..f35ddfbda8 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java @@ -0,0 +1,619 @@ +/*- + * ============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.apihandlerinfra; + +import java.io.StringReader; +import java.io.StringWriter; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +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.hibernate.Session; +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.networkbeans.ActionType; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkInputs; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; +import org.openecomp.mso.apihandlerinfra.networkbeans.ObjectFactory; +import org.openecomp.mso.apihandlerinfra.networkbeans.RequestInfo; +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.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; + +public class NetworkMsoInfraRequest { + + private String requestId; + private String requestXML; + private String requestUri; + private RequestInfo rinfo; + private NetworkInputs networkInputs; + private String networkParams; + private ActionType action; + private String errorMessage; + private String httpResponse; + private String responseBody; + private RequestStatusType status; + private long startTime; + private long progress = Constants.PROGRESS_REQUEST_RECEIVED; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + private static final String NOT_PROVIDED = "not provided"; + + NetworkMsoInfraRequest (String requestId) { + this.requestId = requestId; + Calendar startTimeCalendar = Calendar.getInstance (); + this.startTime = startTimeCalendar.getTimeInMillis (); + MsoLogger.setLogContext (requestId, null); + + } + + // Parse request XML + void parse (String reqXML, String version, MsoJavaProperties props) throws ValidationException { + + msoLogger.debug ("Validating the request"); + + this.requestXML = reqXML; + + NetworkRequest networkReq = null; + boolean isWrongRootElement = false; + + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); + + InputSource inputSource = new InputSource (new StringReader (reqXML)); + SAXSource source = new SAXSource (inputSource); + + if (reqXML.contains ("network-request") && !reqXML.contains ("vnf-request")) { + networkReq = jaxbUnmarshaller.unmarshal (source, NetworkRequest.class).getValue (); + } else { + isWrongRootElement = true; + } + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_VNFREQUEST_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception when parsing reqXML", e); + throw new ValidationException ("format for network request"); + } + + if (isWrongRootElement) { + msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR_REASON, "root element is not correct", "", "", MsoLogger.ErrorCode.DataError, "root element <network-request> expected"); + throw new ValidationException ("root element <network-request> expected"); + } + + if (networkReq == null) { + throw new ValidationException ("network-request"); + } + + this.rinfo = networkReq.getRequestInfo (); + + if (this.rinfo == null) { + throw new ValidationException ("request-info"); + } + + action = this.rinfo.getAction (); + if (action == null) { + throw new ValidationException ("action"); + } + + if (!InfraUtils.isActionAllowed (props, "network", version, action.value ())) { + throw new ValidationException ("action allowable for version " + version + " of network request"); + } + + this.networkInputs = networkReq.getNetworkInputs (); + if (this.networkInputs == null) { + throw new ValidationException ("network-inputs"); + } + + // Verify that the elements correspond to the version + + if (version.equals(Constants.SCHEMA_VERSION_V1)) { + if (this.networkInputs.getBackoutOnFailure() != null || this.networkInputs.getAicCloudRegion() != null || + this.networkInputs.getServiceInstanceId() != null) { + throw new ValidationException ("format for v1 version of network request"); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V2)) { + if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null || + this.networkInputs.getServiceInstanceId() != null) { + throw new ValidationException ("format for v2 version of network request"); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V3)) { + if (this.networkInputs.getServiceType() != null || this.networkInputs.getAicNodeClli() != null) { + throw new ValidationException ("format for v3 version of network request"); + } + } + + switch (action) { + case UPDATE: + case DELETE: + if (this.networkInputs.getNetworkId () == null) { + throw new ValidationException ("network-id"); + } + break; + default: + break; + } + + if (ActionType.CREATE.equals (action) && this.networkInputs.getNetworkName () == null) { + throw new ValidationException ("network-name"); + } + + if (this.networkInputs.getNetworkType () == null) { + throw new ValidationException ("network-type"); + } + + if (!version.equals(Constants.SCHEMA_VERSION_V1) && this.networkInputs.getServiceId () == null) { + throw new ValidationException ("service-id "); + } + + if (this.networkInputs.getServiceType () != null && this.networkInputs.getServiceId () != null) { + throw new ValidationException ("service-type or service-id "); + } + + if (version.equals(Constants.SCHEMA_VERSION_V1) && this.networkInputs.getAicNodeClli () == null) { + throw new ValidationException ("aic-node-clli"); + } + + if ((version.equals (Constants.SCHEMA_VERSION_V2) || version.equals (Constants.SCHEMA_VERSION_V3)) && (this.networkInputs.getAicCloudRegion () == null || this.networkInputs.getAicCloudRegion ().isEmpty())) { + throw new ValidationException ("aic-cloud-region"); + } + + if (version.equals(Constants.SCHEMA_VERSION_V3) && this.networkInputs.getServiceInstanceId () == null) { + throw new ValidationException ("service-instance-id"); + } + + if (ActionType.CREATE.equals (action)) { + if (this.networkInputs.getTenantId () == null) { + throw new ValidationException ("tenant-id"); + } + } + + + Object vpN = networkReq.getNetworkParams (); + + if (vpN != null) { + Node node = (Node) vpN; + Document doc = node.getOwnerDocument (); + this.networkParams = domToStr (doc); + } + + msoLogger.debug ("NetworkParams: " + this.networkParams); + + msoLogger.debug ("Request valid"); + + // Rebuild the request string for BPEL to include request-id + rinfo.setRequestId (this.requestId); + networkReq.setRequestInfo (rinfo); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (networkReq, stringWriter); + + } catch (JAXBException e) { + 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"); + msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); + + } + + public void createRequestRecord (Status status) { + + long startTime = System.currentTimeMillis (); + + Session session = null; + try { + + session = HibernateUtil.getSessionFactory ().openSession (); + session.beginTransaction (); + + InfraActiveRequests aq = new InfraActiveRequests (); + aq.setRequestId (requestId); + + Timestamp startTimeStamp = new Timestamp (Calendar.getInstance ().getTimeInMillis ()); + if (rinfo != null) { + if (rinfo.getAction () != null) { + aq.setAction (rinfo.getAction ().value ()); + aq.setRequestAction (RequestActionMap.getMappedRequestAction (rinfo.getAction ().value ())); + } + aq.setSource (rinfo.getSource ()); + } else { + // Set up mandatory parameters + aq.setAction (NOT_PROVIDED); + aq.setRequestAction (NOT_PROVIDED); + } + + aq.setRequestBody (this.requestXML); + aq.setRequestScope (ModelType.network.name ()); + + if (networkInputs != null) { + if (networkInputs.getNetworkId () != null) { + aq.setVnfId (networkInputs.getNetworkId ()); + } + if (networkInputs.getNetworkName () != null) { + aq.setVnfName (networkInputs.getNetworkName ()); + } + if (networkInputs.getNetworkType () != null) { + aq.setVnfType (networkInputs.getNetworkType ()); + } + if (networkInputs.getServiceInstanceId () != null) { + aq.setServiceInstanceId (networkInputs.getServiceInstanceId ()); + } + if (networkInputs.getServiceType () != null) { + aq.setServiceType (networkInputs.getServiceType ()); + } + if (networkInputs.getServiceId () != null) { + aq.setServiceType (networkInputs.getServiceId ()); + } + if (networkInputs.getAicNodeClli () != null) { + aq.setAicNodeClli (networkInputs.getAicNodeClli ()); + } + if (networkInputs.getTenantId () != null) { + aq.setTenantId (networkInputs.getTenantId ()); + } + if (networkInputs.getProvStatus () != null) { + aq.setProvStatus (networkInputs.getProvStatus ()); + } + + } + aq.setStartTime (startTimeStamp); + aq.setRequestStatus (status.toString ()); + aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); + aq.setRequestType ("NETWORK"); + + if (networkParams != null) { + msoLogger.debug ("Storing networkParams: " + networkParams); + aq.setVnfParams (this.networkParams); + } + + if ((status == Status.FAILED) || (status == Status.COMPLETE)) { + aq.setStatusMessage (this.errorMessage); + aq.setResponseBody (this.responseBody); + + Calendar endTime = Calendar.getInstance (); + Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ()); + aq.setEndTime (endTimeStamp); + } + aq.setProgress (this.progress); + + + msoLogger.debug ("About to insert a record"); + + session.save (aq); + session.getTransaction ().commit (); + session.close (); + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "saveRequest", null); + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in createRequestRecord", e); + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "RequestDB", "saveRequest", null); + if (session != null) { + session.close (); + } + if (!status.equals (Status.FAILED)) { + throw e; + } + } + } + + public void updateFinalStatus (Status status) { + try { + 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.SchemaError, "Exception in updateFinalStatus"); + msoLogger.debug ("Exception: ", e); + } + } + + public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { + return buildResponseWithError (httpResponseCode, errorCode, inProgress, null); + } + + public Response buildResponseWithError (int httpResponseCode, + String errorCode, + InfraActiveRequests inProgress, + String errorString) { + + ObjectFactory beansObjectFactory = new ObjectFactory (); + + NetworkRequest vr = beansObjectFactory.createNetworkRequest (); + + RequestInfo ri = beansObjectFactory.createRequestInfo (); + + ri.setRequestId (requestId); + ri.setRequestStatus (this.status); + ri.setAction (this.rinfo.getAction ()); + ri.setSource (this.rinfo.getSource ()); + + String errorMsg = null; + if (errorCode != null) { + // If error code is actually an XML error response from BPEL, treat it specially: + if (!Messages.errors.containsKey (errorCode)) { + if (errorCode.length () > 300) { + errorMsg = errorCode.substring (0, 299); + } else { + errorMsg = errorCode; + } + + } else { + + if (inProgress == null) { + if (errorCode.equals (ErrorNumbers.RECIPE_DOES_NOT_EXIST)) { + errorMsg = String.format (Messages.errors.get (errorCode), "network", errorString); + } else { + errorMsg = String.format (Messages.errors.get (errorCode), errorString); + } + } else if (errorCode.equals (ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS)) { + errorMsg = String.format (Messages.errors.get (errorCode), + "network", + inProgress.getVnfName (), + inProgress.getRequestStatus (), + "network"); + } else if (errorCode.equals (ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID)) { + errorMsg = String.format (Messages.errors.get (errorCode), + "network", + inProgress.getVnfId (), + inProgress.getRequestStatus (), + inProgress.getAction (), + "network"); + } + } + + ri.setStatusMessage (errorMsg); + this.errorMessage = errorMsg; + } + ri.setProgress ((int) this.progress); + + Date startDate = new Date (this.startTime); + SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); + String startTimeString = sdf.format (startDate); + + ri.setStartTime (startTimeString); + + vr.setRequestInfo (ri); + vr.setNetworkInputs (this.networkInputs); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (vr, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Exception: ", e); + } + + String response = stringWriter.toString (); + + this.httpResponse = Integer.toString (httpResponseCode); + this.responseBody = response; + + // Log the failed request into the MSO Requests database + + return Response.status (httpResponseCode).entity (response).build (); + + } + + public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) { + + ObjectFactory beansObjectFactory = new ObjectFactory (); + NetworkRequest vr = beansObjectFactory.createNetworkRequest (); + + RequestInfo ri = beansObjectFactory.createRequestInfo (); + ri.setRequestId (requestId); + + if (this.rinfo != null) { + if (this.rinfo.getAction () != null) { + ri.setAction (this.rinfo.getAction ()); + } else { + ri.setAction (ActionType.NOT_PROVIDED); + } + if (this.rinfo.getSource () != null) { + ri.setSource (this.rinfo.getSource ()); + } + } else { + ri.setAction (ActionType.NOT_PROVIDED); + } + + // Nothing more is expected for this request + + String errorMsg = String.format (Messages.errors.get (ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + + "_service"), + exceptionMessage); + ri.setStatusMessage (errorMsg); + this.errorMessage = errorMsg; + + ri.setProgress ((int) this.progress); + ri.setRequestStatus (RequestStatusType.FAILED); + Date startDate = new Date (this.startTime); + SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); + String startTimeString = sdf.format (startDate); + + ri.setStartTime (startTimeString); + + vr.setRequestInfo (ri); + vr.setNetworkInputs (this.networkInputs); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (vr, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Error marshalling", e); + } + + String response = stringWriter.toString (); + + this.httpResponse = Integer.toString (httpResponseCode); + this.responseBody = response; + + return Response.status (httpResponseCode).entity (response).build (); + } + + public String getRequestUri () { + return requestUri; + } + + public void setRequestUri (String requestUri) { + this.requestUri = requestUri; + } + + public NetworkInputs getNetworkInputs () { + return networkInputs; + } + + public RequestInfo getRequestInfo () { + return rinfo; + } + + public String getResponseBody () { + return responseBody; + } + + public void setResponseBody (String responseBody) { + this.responseBody = responseBody; + } + + public String getHttpResponse () { + return httpResponse; + } + + public void setHttpResponse (String httpResponse) { + this.httpResponse = httpResponse; + } + + public String getRequestId () { + return requestId; + } + + public String getRequestXML () { + return requestXML; + } + + public void setRequestXML (String requestXML) { + this.requestXML = requestXML; + } + + public RequestStatusType getStatus () { + return status; + } + + public void setStatus (RequestStatusType status) { + this.status = status; + switch (status) { + case FAILED: + case COMPLETE: + this.progress = Constants.PROGRESS_REQUEST_COMPLETED; + break; + case IN_PROGRESS: + this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; + break; + } + } + + public String getServiceType () { + if (this.networkInputs.getServiceType () != null) + return this.networkInputs.getServiceType (); + if (this.networkInputs.getServiceId () != null) + return this.networkInputs.getServiceId (); + return null; + } + + public static String domToStr (Document doc) { + if (doc == null) { + return null; + } + + try { + StringWriter sw = new StringWriter (); + StreamResult sr = new StreamResult (sw); + TransformerFactory tf = TransformerFactory.newInstance (); + Transformer t = tf.newTransformer (); + t.setOutputProperty (OutputKeys.STANDALONE, "yes"); + NodeList nl = doc.getDocumentElement ().getChildNodes (); + DOMSource source = null; + for (int x = 0; x < nl.getLength (); x++) { + Node e = nl.item (x); + if (e instanceof Element) { + source = new DOMSource (e); + break; + } + } + if (source != null) { + t.transform (source, sr); + + String s = sw.toString (); + return s; + } + + return null; + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in domToStr", e); + } + return null; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java new file mode 100644 index 0000000000..8d44d213b1 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java @@ -0,0 +1,667 @@ +/*- + * ============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.apihandlerinfra; + + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.sax.SAXSource; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.xml.sax.InputSource; + +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.networkbeans.ActionType; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkInputs; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkOutputs; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequests; +import org.openecomp.mso.apihandlerinfra.networkbeans.ObjectFactory; +import org.openecomp.mso.apihandlerinfra.networkbeans.RequestInfo; +import org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.Recipe; +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.InfraRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.utils.UUIDChecker; + +@Path("/{version: v1|v2|v3}/network-request") +public class NetworkRequestHandler { + + @Context + private UriInfo uriInfo; + + protected ObjectFactory beansObjectFactory = new ObjectFactory (); + + public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + + private static MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties (); + + 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 (); + + @GET + public Response queryFilters (@QueryParam("network-type") String networkType, + @QueryParam("service-type") String serviceType, + @QueryParam("aic-node-clli") String aicNodeClli, + @QueryParam("tenant-id") String tenantId, + @PathParam("version") String version) { + MsoLogger.setServiceName ("QueryFilters"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + long startTime = System.currentTimeMillis (); + + msoLogger.debug ("Incoming request received for query filters with Network type " + networkType + + " - service type " + + serviceType + + " - aicNodeClli " + + aicNodeClli + + " - tenant id " + + tenantId); + Response response = null; + if (networkType != null) { + response = this.getRequestList ("vnfType", networkType, version); + } else { + response = queryGenericFilters (serviceType, aicNodeClli, tenantId, version); + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + @GET + @Path(Constants.REQUEST_ID_PATH) + public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + MsoLogger.setServiceName ("GetRequest"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for getRequest with requestId=" + requestId + ", version = " + version); + long startTime = System.currentTimeMillis (); + + Response response = getRequestGeneric (requestId, version); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + protected MsoLogger getMsoLogger () { + return msoLogger; + } + + protected void fillNetworkRequest (NetworkRequest qr, InfraRequests ar, String version) { + NetworkInputs vi = beansObjectFactory.createNetworkInputs (); + + if (ar.getVnfId () != null) { + vi.setNetworkId (ar.getVnfId ()); + } + if (ar.getVnfName () != null) { + vi.setNetworkName (ar.getVnfName ()); + } + if (ar.getVnfType () != null) { + vi.setNetworkType (ar.getVnfType ()); + } + if (version.equals(Constants.SCHEMA_VERSION_V1)) { + if (ar.getServiceType () != null) { + vi.setServiceType (ar.getServiceType ()); + } + if (ar.getAicNodeClli () != null) { + vi.setAicNodeClli (ar.getAicNodeClli ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V2)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V3)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getServiceInstanceId () != null) { + vi.setServiceInstanceId (ar.getServiceInstanceId ()); + } + + } + + if (ar.getTenantId () != null) { + vi.setTenantId (ar.getTenantId ()); + } + if (ar.getProvStatus () != null) { + vi.setProvStatus (ar.getProvStatus ()); + } + qr.setNetworkInputs (vi); + + qr.setNetworkParams (ar.getVnfParams ()); + + try { + String networkoutputs = ar.getVnfOutputs (); + if (networkoutputs != null && networkoutputs.length () > 0) { + msoLogger.debug ("Read NETWORK outputs: " + networkoutputs); + NetworkOutputs networkOutput = null; + + // Now unmarshal it into network outputs + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkOutputs.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); + + InputSource inputSource = new InputSource (new StringReader (networkoutputs)); + SAXSource source = new SAXSource (inputSource); + + networkOutput = jaxbUnmarshaller.unmarshal (source, NetworkOutputs.class).getValue (); + + } catch (Exception e) { + msoLogger.debug ("Validation failed", e); + throw new ValidationException ("format for network outputs"); + } + + qr.setNetworkOutputs (networkOutput); + } + } catch (Exception e) { + msoLogger.debug ("exception reading networkOutputs Clob", e); + } + } + + protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String version) { + if (serviceType != null) { + return this.getRequestList ("serviceType", serviceType, version); + } + if (aicNodeClli != null) { + return this.getRequestList ("aicNodeClli", aicNodeClli, version); + } + if (tenantId != null) { + return this.getRequestList ("tenantId", tenantId, version); + } + return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); + } + + protected Response getRequestGeneric (String requestId, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + MsoLogger.setLogContext (requestId, null); + getMsoLogger ().debug ("getRequest: " + requestId); + + String responseString = null; + + InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, "NETWORK"); + if (activeReq != null) { + // build response for active + responseString = infraRequestsResponse (activeReq, version); + return Response.status (HttpStatus.SC_OK).entity (responseString).build (); + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + protected Response getRequestList (String queryAttribute, String queryValue, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); + + List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute, + queryValue, + "NETWORK"); + + List <NetworkRequest> queryResponseList = new LinkedList <NetworkRequest> (); + + if (activeReqList != null) { + // build response for active + queryResponseList = infraRequestsResponses (activeReqList, version); + + } + + if (queryResponseList != null && !queryResponseList.isEmpty ()) { + String result = this.translateNetworkRequests (queryResponseList); + return Response.status (HttpStatus.SC_OK).entity (result).build (); + + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + private NetworkRequest fillGeneric (InfraRequests ar) { + NetworkRequest qr = beansObjectFactory.createNetworkRequest (); + RequestInfo ri = beansObjectFactory.createRequestInfo (); + ri.setRequestId (ar.getRequestId ()); + ri.setAction (ActionType.fromValue (ar.getAction ())); + ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); + if (ar.getProgress () != null) { + ri.setProgress (ar.getProgress ().intValue ()); + } + if (ar.getSource () != null) { + ri.setSource (ar.getSource ()); + } + + ri.setStartTime (ar.getStartTime ().toString ()); + if (ar.getEndTime () != null) { + ri.setEndTime (ar.getEndTime ().toString ()); + } + + if (ar.getStatusMessage () != null) { + ri.setStatusMessage (ar.getStatusMessage ()); + } + qr.setRequestInfo (ri); + return qr; + } + + private List <NetworkRequest> infraRequestsResponses (List <? extends InfraRequests> arList, String version) { + List <NetworkRequest> queryResponseList = new LinkedList <NetworkRequest> (); + + for (InfraRequests ar : arList) { + NetworkRequest qr = fillGeneric (ar); + fillNetworkRequest (qr, ar, version); + queryResponseList.add (qr); + } + return queryResponseList; + } + + private String translateNetworkRequests (List <NetworkRequest> queryResponseList) { + NetworkRequests queryResponses = new NetworkRequests (); + for (int i = 0; i < queryResponseList.size (); i++) { + queryResponses.getNetworkRequest ().add (queryResponseList.get (i)); + } + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequests.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (queryResponses, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + return stringWriter.toString (); + } + + private String infraRequestsResponse (InfraRequests ar, String version) { + NetworkRequest qr = fillGeneric (ar); + fillNetworkRequest (qr, ar, version); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.marshal (qr, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + String response = stringWriter.toString (); + return response; + } + + @POST + @Path("/") + @Produces(MediaType.APPLICATION_XML) + public Response manageNetworkRequest (String reqXML, @PathParam("version") String version) { + MsoLogger.setServiceName ("NetworkRequest"); + if ("v1".equals(version)) { + return manageNetworkRequestImpl (reqXML, Constants.SCHEMA_VERSION_V1); + } else if ("v2".equals(version)) { + return manageNetworkRequestImpl (reqXML, Constants.SCHEMA_VERSION_V2); + } else if ("v3".equals(version)) { + return manageNetworkRequestImpl (reqXML, Constants.SCHEMA_VERSION_V3); + } else { + long startTime = System.currentTimeMillis (); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Version not found"); + return Response.status(HttpStatus.SC_NOT_FOUND).build(); + } + } + + private Response manageNetworkRequestImpl (String reqXML, String version) { + String methodName = "NetworkRequest"; + + props = MsoPropertiesUtils.loadMsoProperties (); + + long startTime = System.currentTimeMillis (); + if (MsoPropertiesUtils.getNoPropertiesState()) { + 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); + + 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.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; + } + } +} 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 new file mode 100644 index 0000000000..f89cae988a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java @@ -0,0 +1,101 @@ +/*- + * ============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.apihandlerinfra; + + +import java.io.StringWriter; +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.apache.http.HttpStatus; + +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkType; +import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkTypes; +import org.openecomp.mso.apihandlerinfra.networkbeans.ObjectFactory; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.NetworkResource; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.utils.UUIDChecker; + +@Path(Constants.NETWORK_TYPES_PATH) +public class NetworkTypesHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + @GET + public Response getNetworkTypes () { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("getNetworkTypes"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for getNetworkTypes"); + + List <NetworkResource> networkResources = null; + try (CatalogDatabase db = new CatalogDatabase()){ + networkResources = db.getAllNetworkResources (); + } catch (Exception 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 (networkResources == null) { + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "NetworkType not found"); + msoLogger.debug ("End of the transaction. NetworkType not found the final response status: " + HttpStatus.SC_NOT_FOUND); + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + + ObjectFactory beansObjectFactory = new ObjectFactory (); + NetworkTypes networkTypes = beansObjectFactory.createNetworkTypes (); + for (int i = 0; i < networkResources.size (); i++) { + NetworkType networkType = beansObjectFactory.createNetworkType (); + NetworkResource vr = networkResources.get (i); + networkType.setType (vr.getNetworkType ()); + networkType.setDescription (vr.getDescription ()); + networkType.setId (String.valueOf (vr.getId ())); + networkTypes.getNetworkType ().add (networkType); + } + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (NetworkTypes.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.marshal (networkTypes, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Error marshalling", e); + } + + 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/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java new file mode 100644 index 0000000000..00104daaf6 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java @@ -0,0 +1,251 @@ +/*- + * ============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.apihandlerinfra; + +import java.text.SimpleDateFormat; +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.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +import org.apache.http.HttpStatus; +import 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.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") +public class OrchestrationRequests { + + public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + + /** + * + */ + public OrchestrationRequests() { + // TODO Auto-generated constructor stub + } + + @GET + @Path("/{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("/") + @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(); + } + + 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; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java new file mode 100644 index 0000000000..234f4068e3 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResult.java @@ -0,0 +1,50 @@ +/*- + * ============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.apihandlerinfra; + + +public class RecipeLookupResult { + + private String orchestrationURI; + private int recipeTimeout; + + public RecipeLookupResult(String orchestrationURI, int recipeTimeout) { + this.orchestrationURI = orchestrationURI; + this.recipeTimeout = recipeTimeout; + } + + public String getOrchestrationURI () { + return orchestrationURI; + } + + public void setOrchestrationURI (String orchestrationURI) { + this.orchestrationURI = orchestrationURI; + } + + public int getRecipeTimeout () { + return recipeTimeout; + } + + public void setRecipeTimeout (int recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } +} + diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java new file mode 100644 index 0000000000..940fcc9c57 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java @@ -0,0 +1,52 @@ +/*- + * ============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.apihandlerinfra; + +import java.util.HashMap; +import java.util.Map; + +/* + * Map of actions to RequestActions +*/ +public class RequestActionMap { + private static final Map<String, String> actionMap; + + static { + actionMap = new HashMap<String, String>(); + actionMap.put("CREATE_VF_MODULE", "createInstance"); + actionMap.put("DELETE_VF_MODULE", "deleteInstance"); + actionMap.put("UPDATE_VF_MODULE", "updateInstance"); + actionMap.put("CREATE_VF_MODULE_VOL", "createInstance"); + actionMap.put("DELETE_VF_MODULE_VOL", "deleteInstance"); + actionMap.put("UPDATE_VF_MODULE_VOL", "updateInstance"); + actionMap.put("CREATE", "createInstance"); + actionMap.put("DELETE", "deleteInstance"); + actionMap.put("UPDATE", "updateInstance"); + actionMap.put("createInstance", "createInstance"); + actionMap.put("deleteInstance", "deleteInstance"); + actionMap.put("updateInstance", "updateInstance"); + + } + + public static String getMappedRequestAction(String action) { + return actionMap.get(action); + } +} 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 new file mode 100644 index 0000000000..bfea00fad6 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestHandler.java @@ -0,0 +1,2102 @@ +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 new file mode 100644 index 0000000000..774b9d6f91 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java @@ -0,0 +1,734 @@ +/*- + * ============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.apihandlerinfra; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.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.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.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("/serviceInstances/v2") +public class ServiceInstances { + + private HashMap<String, String> instanceIdMap = new HashMap<String,String>(); + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + + public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties (); + + /** + * + */ + public ServiceInstances() { + // TODO Auto-generated constructor stub + } + + @POST + @Path("/") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response createServiceInstance(String request) { + + Response response = serviceInstances(request, Action.createInstance, null); + + return response; + } + + @DELETE + @Path("/{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("/{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("/{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("/{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("/{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("/{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("/{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("/{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("/{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("/{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("/{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("/{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; + } + } + + 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; + } + +} 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 new file mode 100644 index 0000000000..c98f90d70f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Status.java @@ -0,0 +1,33 @@ +/*- + * ============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.apihandlerinfra; + + +/* + * Enum for Status values returned by API Handler to Tail-F +*/ +public enum Status { + PENDING, + IN_PROGRESS, + COMPLETE, + FAILED, + TIMEOUT +} 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 new file mode 100644 index 0000000000..8a0a1f3152 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java @@ -0,0 +1,104 @@ +/*- + * ============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.apihandlerinfra; + + +import java.io.StringWriter; +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.apache.http.HttpStatus; + +import org.openecomp.mso.apihandlerinfra.vnfbeans.VfModuleModelName; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VfModuleModelNames; +import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.openecomp.mso.logger.MsoLogger; + +@Path(Constants.VF_MODULE_MODEL_NAMES_PATH) +public class VfModuleModelNamesHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + private static final String LOG_SERVICE_NAME = "InfrastructurePortal:MSO-APIH."; + private static final String LOG_REPLY_NAME = "MSO-APIH:InfrastructurePortal."; + + @GET + public Response getVfModuleModelNames () { + long startTime = System.currentTimeMillis (); + String methodName = "getVfModuleModelNames"; + MsoLogger.setServiceName (LOG_SERVICE_NAME + methodName); + 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.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) { + 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 (); + } + + ObjectFactory beansObjectFactory = new ObjectFactory (); + VfModuleModelNames vfModuleModelNames = beansObjectFactory.createVfModuleModelNames (); + for (int i = 0; i < vfModules.size (); i++) { + VfModuleModelName vfModuleModelName = beansObjectFactory.createVfModuleModelName (); + VfModule vm = vfModules.get (i); + vfModuleModelName.setModelName (vm.getType ()); + vfModuleModelName.setModelVersion (vm.getVersion ()); + vfModuleModelName.setModelInvariantUuid (vm.getModelInvariantUuid ()); + vfModuleModelName.setIsBase(vm.isBase()); + vfModuleModelName.setDescription (vm.getDescription ()); + vfModuleModelName.setId (String.valueOf (vm.getId ())); + vfModuleModelName.setAsdcServiceModelVersion(vm.getVersion ()); + vfModuleModelNames.getVfModuleModelName ().add (vfModuleModelName); + } + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VfModuleModelNames.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.marshal (vfModuleModelNames, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Error marshalling", e); + } + + 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/VnfInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java new file mode 100644 index 0000000000..7494747879 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java @@ -0,0 +1,373 @@ +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.io.StringReader; +import java.io.StringWriter; +import java.util.LinkedList; +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.apache.http.HttpStatus; + +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.sax.SAXSource; + +import org.xml.sax.InputSource; + +import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.apihandlerinfra.vnfbeans.ActionType; +import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; +import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestInfo; +import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfOutputs; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequests; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.requestsdb.InfraRequests; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.utils.UUIDChecker; + +@Path("/{version: v1|v2|v3}/vnf-request") +public class VnfInfoHandler { + + protected ObjectFactory beansObjectFactory = new ObjectFactory (); + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + + @GET + public Response queryFilters (@QueryParam("vnf-type") String vnfType, + @QueryParam("service-type") String serviceType, + @QueryParam("aic-node-clli") String aicNodeClli, + @QueryParam("tenant-id") String tenantId, + @QueryParam("volume-group-id") String volumeGroupId, + @QueryParam("volume-group-name") String volumeGroupName, + @QueryParam("vnf-name") String vnfName, + @PathParam("version") String version) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("VNFQueryFilters"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for queryFilter with vnf-type:" + vnfType + + " service-type:" + serviceType + + " aic-node-clli:" + aicNodeClli + + " tenant-id:" + tenantId + + " volume-group-id:" + volumeGroupId + + " volume-group-name:" + volumeGroupName + + " vnf-name: " + vnfName); + Response response = null; + if (vnfType != null) { + response = this.getRequestList ("vnfType", vnfType, version); + } else { + response = queryGenericFilters (serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName, vnfName, version); + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + @GET + @Path(Constants.REQUEST_ID_PATH) + public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("VNFGetRequest"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for getRequest with request-id:" + requestId + ", version = " + version); + + Response response = getRequestGeneric (requestId, version); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + protected MsoLogger getMsoLogger () { + return msoLogger; + } + + protected String getRequestType () { + return VnfRequestType.VNF.toString (); + } + + protected void fillVnfRequest (VnfRequest qr, InfraRequests ar, String version) { + VnfInputs vi = beansObjectFactory.createVnfInputs (); + + if (ar.getVnfId () != null) { + vi.setVnfId (ar.getVnfId ()); + } + if (ar.getVnfName () != null) { + vi.setVnfName (ar.getVnfName ()); + } + if (ar.getVnfType () != null) { + vi.setVnfType (ar.getVnfType ()); + } + if (ar.getTenantId () != null) { + vi.setTenantId (ar.getTenantId ()); + } + if (ar.getProvStatus () != null) { + vi.setProvStatus (ar.getProvStatus ()); + } + if (ar.getVolumeGroupName () != null) { + vi.setVolumeGroupName (ar.getVolumeGroupName ()); + } + if (ar.getVolumeGroupId () != null) { + vi.setVolumeGroupId (ar.getVolumeGroupId ()); + } + if (version.equals(Constants.SCHEMA_VERSION_V1)) { + if (ar.getServiceType () != null) { + vi.setServiceType (ar.getServiceType ()); + } + if (ar.getAicNodeClli () != null) { + vi.setAicNodeClli (ar.getAicNodeClli ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V2)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getVfModuleName () != null) { + vi.setVfModuleName (ar.getVfModuleName ()); + } + if (ar.getVfModuleId () != null) { + vi.setVfModuleId (ar.getVfModuleId ()); + } + if (ar.getVfModuleModelName () != null) { + vi.setVfModuleModelName (ar.getVfModuleModelName ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V3)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getVfModuleName () != null) { + vi.setVfModuleName (ar.getVfModuleName ()); + } + if (ar.getVfModuleId () != null) { + vi.setVfModuleId (ar.getVfModuleId ()); + } + if (ar.getVfModuleModelName () != null) { + vi.setVfModuleModelName (ar.getVfModuleModelName ()); + } + if (ar.getServiceInstanceId () != null) { + vi.setServiceInstanceId (ar.getServiceInstanceId ()); + } + } + qr.setVnfInputs (vi); + + qr.setVnfParams (ar.getVnfParams ()); + + try { + String vnfoutputs = ar.getVnfOutputs (); + if (vnfoutputs != null && vnfoutputs.length () > 0) { + msoLogger.debug ("Read VNF outputs: " + vnfoutputs); + VnfOutputs vnfOutput = null; + + // Now unmarshal it into vnf outputs + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfOutputs.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); + + InputSource inputSource = new InputSource (new StringReader (vnfoutputs)); + SAXSource source = new SAXSource (inputSource); + + vnfOutput = jaxbUnmarshaller.unmarshal (source, VnfOutputs.class).getValue (); + + } catch (Exception e) { + msoLogger.debug ("Validation failed", e); + throw new ValidationException ("format for vnf outputs"); + } + + qr.setVnfOutputs (vnfOutput); + } + } catch (Exception e) { + msoLogger.debug ("exception reading vnfOutputs Clob", e); + } + } + + protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String volumeGroupId, String volumeGroupName, String vnfName, String version) { + if (serviceType != null) { + return this.getRequestList ("serviceType", serviceType, version); + } + if (aicNodeClli != null) { + return this.getRequestList ("aicNodeClli", aicNodeClli, version); + } + if (tenantId != null) { + return this.getRequestList ("tenantId", tenantId, version); + } + if (volumeGroupId != null) { + return this.getRequestList ("volumeGroupId", volumeGroupId, version); + } + if (volumeGroupName != null) { + return this.getRequestList ("volumeGroupName", volumeGroupName, version); + } + if (vnfName != null) { + return this.getRequestList ("vnfName", vnfName, version); + } + return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); + } + + protected Response getRequestGeneric (String requestId, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest: " + requestId); + + String responseString = null; + + InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, getRequestType ()); + if (activeReq != null) { + // build response for active + responseString = infraRequestsResponse (activeReq, version); + return Response.status (HttpStatus.SC_OK).entity (responseString).build (); + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + protected Response getRequestList (String queryAttribute, String queryValue, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); + + List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute, + queryValue, + getRequestType ()); + + List <VnfRequest> queryResponseList = new LinkedList <VnfRequest> (); + + if (activeReqList != null) { + // build response for active + queryResponseList = infraRequestsResponses (activeReqList, version); + + } + + if (queryResponseList != null && !queryResponseList.isEmpty ()) { + String result = this.translateVnfRequests (queryResponseList); + return Response.status (HttpStatus.SC_OK).entity (result).build (); + + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + private VnfRequest fillGeneric (InfraRequests ar) { + VnfRequest qr = beansObjectFactory.createVnfRequest (); + RequestInfo ri = beansObjectFactory.createRequestInfo (); + ri.setRequestId (ar.getRequestId ()); + ri.setAction (ActionType.fromValue (ar.getAction ())); + ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); + if (ar.getProgress () != null) { + ri.setProgress (ar.getProgress ().intValue ()); + } + if (ar.getSource () != null) { + ri.setSource (ar.getSource ()); + } + + ri.setStartTime (ar.getStartTime ().toString ()); + if (ar.getEndTime () != null) { + ri.setEndTime (ar.getEndTime ().toString ()); + } + + if (ar.getStatusMessage () != null) { + ri.setStatusMessage (ar.getStatusMessage ()); + } + qr.setRequestInfo (ri); + return qr; + } + + private List <VnfRequest> infraRequestsResponses (List <? extends InfraRequests> arList, String version) { + List <VnfRequest> queryResponseList = new LinkedList <VnfRequest> (); + + for (InfraRequests ar : arList) { + VnfRequest qr = fillGeneric (ar); + fillVnfRequest (qr, ar, version); + queryResponseList.add (qr); + } + return queryResponseList; + } + + private String translateVnfRequests (List <VnfRequest> queryResponseList) { + VnfRequests queryResponses = new VnfRequests (); + for (int i = 0; i < queryResponseList.size (); i++) { + queryResponses.getVnfRequest ().add (queryResponseList.get (i)); + } + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequests.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (queryResponses, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + return stringWriter.toString (); + } + + private String infraRequestsResponse (InfraRequests ar, String version) { + VnfRequest qr = fillGeneric (ar); + fillVnfRequest (qr, ar, version); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.marshal (qr, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + String response = stringWriter.toString (); + return response; + } +} 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 new file mode 100644 index 0000000000..e22d182086 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java @@ -0,0 +1,714 @@ +/*- + * ============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.apihandlerinfra; + + +import java.io.StringReader; +import java.io.StringWriter; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +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.hibernate.Session; + +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.vnfbeans.ActionType; +import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; +import org.openecomp.mso.apihandlerinfra.vnfbeans.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.logger.MessageEnum; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.requestsdb.HibernateUtil; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; + +public class VnfMsoInfraRequest { + + private String requestId; + private String requestXML; + private String requestUri; + private VnfRequest vnfReq; + private RequestInfo rinfo; + private VnfInputs vnfInputs; + private String vnfParams; + private ActionType action; + private String errorMessage; + private String httpResponse; + private String responseBody; + private RequestStatusType status; + private long startTime; + private long progress = Constants.PROGRESS_REQUEST_RECEIVED; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + private static final String NOT_PROVIDED = "not provided"; + + VnfMsoInfraRequest (String requestId) { + this.requestId = requestId; + Calendar startTimeCalendar = Calendar.getInstance (); + this.startTime = startTimeCalendar.getTimeInMillis (); + MsoLogger.setLogContext (requestId, null); + + } + + // Parse request XML + void parse (String reqXML, String version, MsoJavaProperties props) throws ValidationException { + + msoLogger.debug ("Validating the request"); + + this.requestXML = reqXML; + + VnfRequest vnfReq = null; + boolean isWrongRootElement = false; + + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); + + InputSource inputSource = new InputSource (new StringReader (reqXML)); + SAXSource source = new SAXSource (inputSource); + + if (reqXML.contains ("vnf-request") && !reqXML.contains ("network-request")) { + vnfReq = jaxbUnmarshaller.unmarshal (source, VnfRequest.class).getValue (); + } else { + isWrongRootElement = true; + } + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_VNFREQUEST_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in format for vnf request ", e); + throw new ValidationException ("format for vnf request"); + } + + if (isWrongRootElement) { + msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR_REASON, "root element is not correct", "", "", MsoLogger.ErrorCode.DataError, "root element is not correct"); + throw new ValidationException ("root element <vnf-request> expected"); + } + + if (vnfReq == null) { + throw new ValidationException ("vnf-request"); + } + this.vnfReq = vnfReq; + + this.rinfo = vnfReq.getRequestInfo (); + + if (this.rinfo == null) { + throw new ValidationException ("request-info"); + } + if (this.rinfo.getRequestId () != null) { + msoLogger.info (MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, this.rinfo.getRequestId ()); + } + + action = this.rinfo.getAction (); + if (action == null) { + throw new ValidationException ("action"); + } + + this.vnfInputs = vnfReq.getVnfInputs (); + if (this.vnfInputs == null) { + throw new ValidationException ("vnf-inputs"); + } + + // Verify that BPMN-specific elements are not in the APIH incoming request + if (this.vnfInputs.getPersonaModelId () != null || this.vnfInputs.getPersonaModelVersion () != null || + this.vnfInputs.getIsBaseVfModule () != null || this.vnfInputs.getVnfPersonaModelId () != null || + this.vnfInputs.getVnfPersonaModelVersion () != null) { + throw new ValidationException ("format for vnf request"); + } + // Verify that the elements correspond to the version + + + if (version.equals(Constants.SCHEMA_VERSION_V1)) { + if (this.vnfInputs.getVfModuleName () != null || this.vnfInputs.getVfModuleId () != null || + this.vnfInputs.getVfModuleModelName () != null || this.vnfInputs.getAsdcServiceModelVersion () != null || + this.vnfInputs.getBackoutOnFailure() != null || this.vnfInputs.getAicCloudRegion() != null || + this.vnfInputs.getServiceInstanceId () != null) { + throw new ValidationException ("format for v1 version of vnf request"); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V2)) { + if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null || this.vnfInputs.getServiceInstanceId () != null) { + throw new ValidationException ("format for v2 version of vnf request"); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V3)) { + if (this.vnfInputs.getServiceType() != null || this.vnfInputs.getAicNodeClli() != null) { + throw new ValidationException ("format for v3 version of vnf request"); + } + } + + + if (!InfraUtils.isActionAllowed (props, "vnf", version, action.value ())) { + throw new ValidationException ("action allowable for version " + version + " of vnf request"); + } + + if ((ActionType.UPDATE.equals(action) || ActionType.DELETE.equals(action)) && this.vnfInputs.getVnfId () == null) { + throw new ValidationException("vnf-id"); + } + + if ((ActionType.UPDATE_VF_MODULE.equals (action) || ActionType.DELETE_VF_MODULE.equals (action)) && this.vnfInputs.getVfModuleId () == null) { + throw new ValidationException ("vf-module-id"); + } + + if (ActionType.CREATE.equals (action) && this.vnfInputs.getVnfName () == null) { + throw new ValidationException ("vnf-name"); + } + + if (ActionType.CREATE_VF_MODULE.equals (action)) { + if (this.vnfInputs.getVfModuleName () == null) { + throw new ValidationException ("vf-module-name"); + } + if (!InfraUtils.isValidHeatName(this.vnfInputs.getVfModuleName ())) { + throw new ValidationException ("vf-module-name: no value meeting heat stack name syntax requirements"); + } + } + + if (this.vnfInputs.getVnfType () == null) { + throw new ValidationException ("vnf-type"); + } + + if ((ActionType.CREATE_VF_MODULE.equals (action) || ActionType.UPDATE_VF_MODULE.equals (action) || ActionType.DELETE_VF_MODULE.equals (action)) && this.vnfInputs.getVfModuleModelName () == null) { + throw new ValidationException ("vf-module-model-name"); + } + + if (!version.equals(Constants.SCHEMA_VERSION_V1) && this.vnfInputs.getServiceId () == null) { + throw new ValidationException ("service-id "); + } + + if (this.vnfInputs.getServiceType () != null && this.vnfInputs.getServiceId () != null) { + throw new ValidationException ("service-type or service-id "); + } + + if (version.equals(Constants.SCHEMA_VERSION_V1) && this.vnfInputs.getAicNodeClli () == null) { + throw new ValidationException ("aic-node-clli"); + } + + if ((version.equals(Constants.SCHEMA_VERSION_V2) || version.equals(Constants.SCHEMA_VERSION_V3)) && (this.vnfInputs.getAicCloudRegion () == null || this.vnfInputs.getAicCloudRegion ().isEmpty())) { + throw new ValidationException ("aic-cloud-region"); + } + + if (version.equals(Constants.SCHEMA_VERSION_V3) && this.vnfInputs.getServiceInstanceId () == null) { + throw new ValidationException ("service-instance-id"); + } + + + if (this.vnfInputs.getTenantId () == null) { + throw new ValidationException ("tenant-id"); + } + + Object vp = vnfReq.getVnfParams (); + + if (vp != null) { + msoLogger.debug ("This object is not null"); + + Node node = (Node) vp; + Document doc = node.getOwnerDocument (); + this.vnfParams = domToStr (doc); + } + + msoLogger.debug ("VNFParams: " + this.vnfParams); + + msoLogger.debug ("Request valid"); + + // Rebuild the request string for BPEL to include request-id + rinfo.setRequestId (this.requestId); + this.vnfReq.setRequestInfo (rinfo); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (this.vnfReq, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Exception: ", e); + } + + this.requestXML = stringWriter.toString (); + msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); + + } + + public void createRequestRecord (Status status) { + + Session session = null; + try { + + session = HibernateUtil.getSessionFactory ().openSession (); + session.beginTransaction (); + + InfraActiveRequests aq = new InfraActiveRequests (); + aq.setRequestId (requestId); + aq.setClientRequestId(rinfo.getRequestId()); + + Timestamp startTimeStamp = new Timestamp (Calendar.getInstance ().getTimeInMillis ()); + if (rinfo != null) { + if (rinfo.getAction () != null) { + aq.setAction (rinfo.getAction ().value ()); + aq.setRequestAction (RequestActionMap.getMappedRequestAction (rinfo.getAction ().value ())); + } + aq.setSource (rinfo.getSource ()); + } else { + // Set up mandatory parameters + aq.setAction (NOT_PROVIDED); + aq.setRequestAction (NOT_PROVIDED); + } + + aq.setRequestBody (this.requestXML); + aq.setRequestScope (""); + + if (vnfInputs != null) { + if (vnfInputs.getVnfId () != null) { + aq.setVnfId (vnfInputs.getVnfId ()); + } + if (vnfInputs.getVnfName () != null) { + aq.setVnfName (vnfInputs.getVnfName ()); + } + if (vnfInputs.getVnfType () != null) { + aq.setVnfType (vnfInputs.getVnfType ()); + } + if (vnfInputs.getServiceInstanceId () != null) { + aq.setServiceInstanceId (vnfInputs.getServiceInstanceId ()); + } + if (vnfInputs.getServiceType () != null) { + aq.setServiceType (vnfInputs.getServiceType ()); + } + if (vnfInputs.getServiceId () != null) { + aq.setAaiServiceId (vnfInputs.getServiceId ()); + } + if (vnfInputs.getAicNodeClli () != null) { + aq.setAicNodeClli (vnfInputs.getAicNodeClli ()); + } + if (vnfInputs.getAicCloudRegion () != null) { + aq.setAicCloudRegion (vnfInputs.getAicCloudRegion ()); + } + if (vnfInputs.getTenantId () != null) { + aq.setTenantId (vnfInputs.getTenantId ()); + } + if (vnfInputs.getProvStatus () != null) { + aq.setProvStatus (vnfInputs.getProvStatus ()); + } + if (vnfInputs.getVolumeGroupName () != null) { + aq.setVolumeGroupName (vnfInputs.getVolumeGroupName ()); + } + if (vnfInputs.getVolumeGroupId () != null) { + aq.setVolumeGroupId (vnfInputs.getVolumeGroupId ()); + } + if (vnfInputs.getVfModuleId () != null) { + aq.setVfModuleId (vnfInputs.getVfModuleId ()); + } + if (vnfInputs.getVfModuleName () != null) { + aq.setVfModuleName (vnfInputs.getVfModuleName ()); + } + if (vnfInputs.getVfModuleModelName () != null) { + aq.setVfModuleModelName (vnfInputs.getVfModuleModelName ()); + } + + if (vnfInputs.getVfModuleName () != null || vnfInputs.getVfModuleId () != null) { + aq.setRequestScope (ModelType.vfModule.name ()); + } + else { + aq.setRequestScope (ModelType.vnf.name ()); + } + + + } + + aq.setStartTime (startTimeStamp); + aq.setRequestStatus (status.toString ()); + aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); + aq.setRequestType ("VNF"); + + if (vnfParams != null) { + msoLogger.debug ("Storing vnfParams: " + vnfParams); + aq.setVnfParams (this.vnfParams); + } + + if ((status == Status.FAILED) || (status == Status.COMPLETE)) { + aq.setStatusMessage (this.errorMessage); + aq.setResponseBody (this.responseBody); + + Calendar endTime = Calendar.getInstance (); + Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ()); + aq.setEndTime (endTimeStamp); + } + + aq.setProgress (this.progress); + + + msoLogger.debug ("About to insert a record"); + + session.save (aq); + session.getTransaction ().commit (); + session.close (); + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in createRequestRecord", e); + if (session != null) { + session.close (); + } + if (!status.equals (Status.FAILED)) { + throw e; + } + } + } + + public void updateFinalStatus (Status status) { + int result = 0; + try { + 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.AvailabilityError, "Exception in updateFinalStatus"); + msoLogger.debug ("Exception: ", e); + } + } + + public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { + return buildResponseWithError (httpResponseCode, errorCode, inProgress, null); + } + + public Response buildResponseWithError (int httpResponseCode, + String errorCode, + InfraActiveRequests inProgress, + String errorString) { + + ObjectFactory beansObjectFactory = new ObjectFactory (); + + VnfRequest vr = beansObjectFactory.createVnfRequest (); + + RequestInfo ri = beansObjectFactory.createRequestInfo (); + + ri.setRequestId (requestId); + ri.setRequestStatus (this.status); + ri.setAction (this.rinfo.getAction ()); + ri.setSource (this.rinfo.getSource ()); + + String errorMsg = null; + if (errorCode != null) { + // If error code is actually an XML error response from BPEL, treat it specially: + if (!Messages.errors.containsKey (errorCode)) { + if (errorCode.length () > 300) { + errorMsg = errorCode.substring (0, 299); + } else { + errorMsg = errorCode; + } + + } else { + + if (inProgress == null) { + if (errorCode.equals (ErrorNumbers.RECIPE_DOES_NOT_EXIST)) { + errorMsg = String.format (Messages.errors.get (errorCode), "vnf", errorString); + } else { + errorMsg = String.format (Messages.errors.get (errorCode), errorString); + } + } else if (errorCode.equals (ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS)) { + errorMsg = String.format (Messages.errors.get (errorCode), + "vnf", + inProgress.getVnfName (), + inProgress.getRequestStatus (), + "vnf"); + } else if (errorCode.equals (ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID)) { + errorMsg = String.format (Messages.errors.get (errorCode), + "vnf", + inProgress.getVnfId (), + inProgress.getRequestStatus (), + inProgress.getAction (), + "vnf"); + } + } + + ri.setStatusMessage (errorMsg); + this.errorMessage = errorMsg; + } + ri.setProgress ((int) this.progress); + + Date startDate = new Date (this.startTime); + SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); + String startTimeString = sdf.format (startDate); + + ri.setStartTime (startTimeString); + + if (this.progress == Constants.PROGRESS_REQUEST_COMPLETED) { + ri.setEndTime(startTimeString); + } + + vr.setRequestInfo (ri); + + this.vnfInputs.setIsBaseVfModule(null); + this.vnfInputs.setPersonaModelId(null); + this.vnfInputs.setPersonaModelVersion(null); + this.vnfInputs.setVnfPersonaModelId(null); + this.vnfInputs.setVnfPersonaModelVersion(null); + + vr.setVnfInputs (this.vnfInputs); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (vr, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Exception: ", e); + } + + String response = stringWriter.toString (); + + this.httpResponse = Integer.toString (httpResponseCode); + this.responseBody = response; + + + // Log the failed request into the MSO Requests database + + return Response.status (httpResponseCode).entity (response).build (); + + } + + public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) { + + ObjectFactory beansObjectFactory = new ObjectFactory (); + VnfRequest vr = beansObjectFactory.createVnfRequest (); + + RequestInfo ri = beansObjectFactory.createRequestInfo (); + ri.setRequestId (requestId); + + if (this.rinfo != null) { + if (this.rinfo.getAction () != null) { + ri.setAction (this.rinfo.getAction ()); + } else { + ri.setAction (ActionType.NOT_PROVIDED); + } + if (this.rinfo.getSource () != null) { + ri.setSource (this.rinfo.getSource ()); + } + } else { + ri.setAction (ActionType.NOT_PROVIDED); + } + + // Nothing more is expected for this request + + String errorMsg = String.format (Messages.errors.get (ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + + "_service"), + exceptionMessage); + ri.setStatusMessage (errorMsg); + this.errorMessage = errorMsg; + + ri.setProgress ((int) this.progress); + ri.setRequestStatus (RequestStatusType.FAILED); + Date startDate = new Date (this.startTime); + SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); + String startTimeString = sdf.format (startDate); + + ri.setStartTime (startTimeString); + ri.setEndTime(startTimeString); + + vr.setRequestInfo (ri); + + vr.setVnfInputs (this.vnfInputs); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (vr, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Error marshalling", e); + } + + String response = stringWriter.toString (); + + this.httpResponse = Integer.toString (httpResponseCode); + this.responseBody = response; + + return Response.status (httpResponseCode).entity (response).build (); + } + + public String getRequestUri () { + return requestUri; + } + + public void setRequestUri (String requestUri) { + this.requestUri = requestUri; + } + + public VnfInputs getVnfInputs () { + return vnfInputs; + } + + public RequestInfo getRequestInfo () { + return rinfo; + } + + public String getResponseBody () { + return responseBody; + } + + public void setResponseBody (String responseBody) { + this.responseBody = responseBody; + } + + public String getHttpResponse () { + return httpResponse; + } + + public void setHttpResponse (String httpResponse) { + this.httpResponse = httpResponse; + } + + public String getRequestId () { + return requestId; + } + + public String getRequestXML () { + return requestXML; + } + + public void setRequestXML (String requestXML) { + this.requestXML = requestXML; + } + + public RequestStatusType getStatus () { + return status; + } + + public String getServiceType () { + if (this.vnfInputs.getServiceType () != null) + return this.vnfInputs.getServiceType (); + if (this.vnfInputs.getServiceId () != null) + return this.vnfInputs.getServiceId (); + return null; + } + + public void setStatus (RequestStatusType status) { + this.status = status; + switch (status) { + case FAILED: + case COMPLETE: + this.progress = Constants.PROGRESS_REQUEST_COMPLETED; + break; + case IN_PROGRESS: + this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; + break; + } + } + + public static String domToStr (Document doc) { + if (doc == null) { + return null; + } + + try { + StringWriter sw = new StringWriter (); + StreamResult sr = new StreamResult (sw); + TransformerFactory tf = TransformerFactory.newInstance (); + Transformer t = tf.newTransformer (); + t.setOutputProperty (OutputKeys.STANDALONE, "yes"); + NodeList nl = doc.getDocumentElement ().getChildNodes (); + DOMSource source = null; + for (int x = 0; x < nl.getLength (); x++) { + Node e = nl.item (x); + if (e instanceof Element) { + source = new DOMSource (e); + break; + } + } + if (source != null) { + t.transform (source, sr); + + String s = sw.toString (); + return s; + } + + return null; + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in domToStr", e); + } + return null; + } + + public void addBPMNSpecificInputs(String personaModelId, String personaModelVersion, Boolean isBaseVfModule, + String vnfPersonaModelId, String vnfPersonaModelVersion) { + vnfInputs.setPersonaModelId(personaModelId); + vnfInputs.setPersonaModelVersion(personaModelVersion); + vnfInputs.setIsBaseVfModule(isBaseVfModule); + vnfInputs.setVnfPersonaModelId(vnfPersonaModelId); + vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion); + + this.vnfReq.setVnfInputs(vnfInputs); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (this.vnfReq, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Exception: ", e); + } + + this.requestXML = stringWriter.toString (); + msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); + + + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java new file mode 100644 index 0000000000..617172be08 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java @@ -0,0 +1,804 @@ +/*- + * ============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.apihandlerinfra; + + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; + +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.sax.SAXSource; + +import org.xml.sax.InputSource; + +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.vnfbeans.ActionType; +import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; +import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestInfo; +import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfOutputs; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequests; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.Recipe; +import org.openecomp.mso.db.catalog.beans.VfModule; +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.InfraRequests; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.utils.UUIDChecker; + +@Path("/{version: v1|v2|v3}/vnf-request") +public class VnfRequestHandler { + + @Context + private UriInfo uriInfo; + + protected ObjectFactory beansObjectFactory = new ObjectFactory (); + + public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + + private static MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties (); + + 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 (); + + @GET + public Response queryFilters (@QueryParam("vnf-type") String vnfType, + @QueryParam("service-type") String serviceType, + @QueryParam("aic-node-clli") String aicNodeClli, + @QueryParam("tenant-id") String tenantId, + @QueryParam("volume-group-id") String volumeGroupId, + @QueryParam("volume-group-name") String volumeGroupName, + @QueryParam("vnf-name") String vnfName, + @PathParam("version") String version) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("VNFQueryFilters"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for queryFilter with vnf-type:" + vnfType + + " service-type:" + serviceType + + " aic-node-clli:" + aicNodeClli + + " tenant-id:" + tenantId + + " volume-group-id:" + volumeGroupId + + " volume-group-name:" + volumeGroupName + + " vnf-name: " + vnfName); + Response response = null; + if (vnfType != null) { + response = this.getRequestList ("vnfType", vnfType, version); + } else { + response = queryGenericFilters (serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName, vnfName, version); + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + @GET + @Path(Constants.REQUEST_ID_PATH) + public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("VNFGetRequest"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for getRequest with request-id:" + requestId + ", version = " + version); + + Response response = getRequestGeneric (requestId, version); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + protected MsoLogger getMsoLogger () { + return msoLogger; + } + + protected String getRequestType () { + return VnfRequestType.VNF.toString (); + } + + protected void fillVnfRequest (VnfRequest qr, InfraRequests ar, String version) { + VnfInputs vi = beansObjectFactory.createVnfInputs (); + + if (ar.getVnfId () != null) { + vi.setVnfId (ar.getVnfId ()); + } + if (ar.getVnfName () != null) { + vi.setVnfName (ar.getVnfName ()); + } + if (ar.getVnfType () != null) { + vi.setVnfType (ar.getVnfType ()); + } + if (ar.getTenantId () != null) { + vi.setTenantId (ar.getTenantId ()); + } + if (ar.getProvStatus () != null) { + vi.setProvStatus (ar.getProvStatus ()); + } + if (ar.getVolumeGroupName () != null) { + vi.setVolumeGroupName (ar.getVolumeGroupName ()); + } + if (ar.getVolumeGroupId () != null) { + vi.setVolumeGroupId (ar.getVolumeGroupId ()); + } + if (version.equals(Constants.SCHEMA_VERSION_V1)) { + if (ar.getServiceType () != null) { + vi.setServiceType (ar.getServiceType ()); + } + if (ar.getAicNodeClli () != null) { + vi.setAicNodeClli (ar.getAicNodeClli ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V2)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getVfModuleName () != null) { + vi.setVfModuleName (ar.getVfModuleName ()); + } + if (ar.getVfModuleId () != null) { + vi.setVfModuleId (ar.getVfModuleId ()); + } + if (ar.getVfModuleModelName () != null) { + vi.setVfModuleModelName (ar.getVfModuleModelName ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V3)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getVfModuleName () != null) { + vi.setVfModuleName (ar.getVfModuleName ()); + } + if (ar.getVfModuleId () != null) { + vi.setVfModuleId (ar.getVfModuleId ()); + } + if (ar.getVfModuleModelName () != null) { + vi.setVfModuleModelName (ar.getVfModuleModelName ()); + } + if (ar.getServiceInstanceId () != null) { + vi.setServiceInstanceId (ar.getServiceInstanceId ()); + } + } + qr.setVnfInputs (vi); + + qr.setVnfParams (ar.getVnfParams ()); + + try { + String vnfoutputs = ar.getVnfOutputs (); + if (vnfoutputs != null && vnfoutputs.length () > 0) { + msoLogger.debug ("Read VNF outputs: " + vnfoutputs); + VnfOutputs vnfOutput = null; + + // Now unmarshal it into vnf outputs + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfOutputs.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); + + InputSource inputSource = new InputSource (new StringReader (vnfoutputs)); + SAXSource source = new SAXSource (inputSource); + + vnfOutput = jaxbUnmarshaller.unmarshal (source, VnfOutputs.class).getValue (); + + } catch (Exception e) { + msoLogger.debug ("Validation failed", e); + throw new ValidationException ("format for vnf outputs"); + } + + qr.setVnfOutputs (vnfOutput); + } + } catch (Exception e) { + msoLogger.debug ("exception reading vnfOutputs Clob", e); + } + } + + protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String volumeGroupId, String volumeGroupName, String vnfName, String version) { + if (serviceType != null) { + return this.getRequestList ("serviceType", serviceType, version); + } + if (aicNodeClli != null) { + return this.getRequestList ("aicNodeClli", aicNodeClli, version); + } + if (tenantId != null) { + return this.getRequestList ("tenantId", tenantId, version); + } + if (volumeGroupId != null) { + return this.getRequestList ("volumeGroupId", volumeGroupId, version); + } + if (volumeGroupName != null) { + return this.getRequestList ("volumeGroupName", volumeGroupName, version); + } + if (vnfName != null) { + return this.getRequestList ("vnfName", vnfName, version); + } + return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); + } + + protected Response getRequestGeneric (String requestId, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest: " + requestId); + + String responseString = null; + + InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, getRequestType ()); + if (activeReq != null) { + // build response for active + responseString = infraRequestsResponse (activeReq, version); + return Response.status (HttpStatus.SC_OK).entity (responseString).build (); + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + protected Response getRequestList (String queryAttribute, String queryValue, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); + + List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute, + queryValue, + getRequestType ()); + + List <VnfRequest> queryResponseList = new LinkedList <VnfRequest> (); + + if (activeReqList != null) { + // build response for active + queryResponseList = infraRequestsResponses (activeReqList, version); + + } + + if (queryResponseList != null && !queryResponseList.isEmpty ()) { + String result = this.translateVnfRequests (queryResponseList); + return Response.status (HttpStatus.SC_OK).entity (result).build (); + + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + private VnfRequest fillGeneric (InfraRequests ar) { + VnfRequest qr = beansObjectFactory.createVnfRequest (); + RequestInfo ri = beansObjectFactory.createRequestInfo (); + ri.setRequestId (ar.getRequestId ()); + ri.setAction (ActionType.fromValue (ar.getAction ())); + ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); + if (ar.getProgress () != null) { + ri.setProgress (ar.getProgress ().intValue ()); + } + if (ar.getSource () != null) { + ri.setSource (ar.getSource ()); + } + + ri.setStartTime (ar.getStartTime ().toString ()); + if (ar.getEndTime () != null) { + ri.setEndTime (ar.getEndTime ().toString ()); + } + + if (ar.getStatusMessage () != null) { + ri.setStatusMessage (ar.getStatusMessage ()); + } + qr.setRequestInfo (ri); + return qr; + } + + private List <VnfRequest> infraRequestsResponses (List <? extends InfraRequests> arList, String version) { + List <VnfRequest> queryResponseList = new LinkedList <VnfRequest> (); + + for (InfraRequests ar : arList) { + VnfRequest qr = fillGeneric (ar); + fillVnfRequest (qr, ar, version); + queryResponseList.add (qr); + } + return queryResponseList; + } + + private String translateVnfRequests (List <VnfRequest> queryResponseList) { + VnfRequests queryResponses = new VnfRequests (); + for (int i = 0; i < queryResponseList.size (); i++) { + queryResponses.getVnfRequest ().add (queryResponseList.get (i)); + } + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequests.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (queryResponses, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + return stringWriter.toString (); + } + + private String infraRequestsResponse (InfraRequests ar, String version) { + VnfRequest qr = fillGeneric (ar); + fillVnfRequest (qr, ar, version); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.marshal (qr, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + String response = stringWriter.toString (); + return response; + } + + @POST + @Path("/") + @Produces(MediaType.APPLICATION_XML) + public Response manageVnfRequest (String reqXML, @PathParam("version") String version) { + MsoLogger.setServiceName ("VnfRequest"); + if ("v1".equals(version)) { + return manageVnfRequestImpl (reqXML, Constants.SCHEMA_VERSION_V1); + } else if ("v2".equals(version)) { + return manageVnfRequestImpl (reqXML, Constants.SCHEMA_VERSION_V2); + } else if ("v3".equals(version)) { + return manageVnfRequestImpl (reqXML, Constants.SCHEMA_VERSION_V3); + } else { + long startTime = System.currentTimeMillis (); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Version not found"); + return Response.status(HttpStatus.SC_NOT_FOUND).build(); + } + } + + private Response manageVnfRequestImpl (String reqXML, String version) { + String methodName = "VnfRequest"; + props = MsoPropertiesUtils.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 (MsoPropertiesUtils.getNoPropertiesState()) { + 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 = ""; + + // Query MSO Catalog DB + 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; + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestType.java new file mode 100644 index 0000000000..e8023b8bf9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestType.java @@ -0,0 +1,30 @@ +/*- + * ============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.apihandlerinfra; + + +/* + * Enum for VNF Request Type values +*/ +public enum VnfRequestType { + VNF, + NETWORK +} 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 new file mode 100644 index 0000000000..32fd80d58a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java @@ -0,0 +1,107 @@ +/*- + * ============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.apihandlerinfra; + + +import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfType; +import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfTypes; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.utils.UUIDChecker; +import org.apache.http.HttpStatus; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import java.io.StringWriter; +import java.util.List; + +@Path(Constants.VNF_TYPES_PATH) +public class VnfTypesHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + + @GET + public Response getVnfTypes (@QueryParam("vnf-role") String vnfRole) { + + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("GetVnfTypes"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for getVnfTypes with vnf-role:" + vnfRole); + + List <VnfResource> vnfResources = null; + try(CatalogDatabase db = new CatalogDatabase ()) { + ; + if (vnfRole != null) { + vnfResources = db.getVnfResourcesByRole (vnfRole); + } else { + vnfResources = db.getAllVnfResources (); + } + } catch (Exception 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 (vnfResources == null) { + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Error:no vnf types found"); + msoLogger.debug ("End of the transaction. No VNF Types found. The final response status is: " + HttpStatus.SC_NOT_FOUND); + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + + ObjectFactory beansObjectFactory = new ObjectFactory (); + VnfTypes vnfTypes = beansObjectFactory.createVnfTypes (); + for (int i = 0; i < vnfResources.size (); i++) { + VnfType vnfType = beansObjectFactory.createVnfType (); + VnfResource vr = vnfResources.get (i); + vnfType.setType (vr.getVnfType ()); + vnfType.setDescription (vr.getDescription ()); + vnfType.setId (String.valueOf (vr.getId ())); + vnfTypes.getVnfType ().add (vnfType); + } + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VnfTypes.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.marshal (vnfTypes, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Error marshalling", e); + } + + 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/VolumeInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java new file mode 100644 index 0000000000..3190fc507e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java @@ -0,0 +1,367 @@ +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.io.StringReader; +import java.io.StringWriter; +import java.util.LinkedList; +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.apache.http.HttpStatus; + +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.sax.SAXSource; + +import org.xml.sax.InputSource; + +import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType; +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.VolumeInputs; +import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeOutputs; +import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest; +import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequests; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.requestsdb.InfraRequests; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.utils.UUIDChecker; + +@Path("/{version: v1|v2|v3}/volume-request") +public class VolumeInfoHandler { + + protected ObjectFactory beansObjectFactory = new ObjectFactory (); + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); + + @GET + public Response queryFilters (@QueryParam("vnf-type") String vnfType, + @QueryParam("service-type") String serviceType, + @QueryParam("aic-node-clli") String aicNodeClli, + @QueryParam("tenantId") String tenantId, + @QueryParam("volume-group-id") String volumeGroupId, + @QueryParam("volume-group-name") String volumeGroupName, + @PathParam("version") String version) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("VolumeQueryFilters"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for queryFilter with vnf-type:" + vnfType + + " service-type:" + serviceType + + " aic-node-clli:" + aicNodeClli + + " tenant-id:" + tenantId + + " volume-group-id:" + volumeGroupId + + " volume-group-name:" + volumeGroupName); + Response response = null; + if (vnfType != null) { + response = this.getRequestList ("vnfType", vnfType, version); + } else { + response = queryGenericFilters (serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName, version); + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + @GET + @Path(Constants.REQUEST_ID_PATH) + public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { + + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("VolumeGetRequest"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for getRequest with request-id:" + requestId); + + Response response = getRequestGeneric (requestId, version); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + + } + + + protected MsoLogger getMsoLogger () { + return msoLogger; + } + + + protected void fillVolumeRequest (VolumeRequest qr, InfraRequests ar, String version) { + VolumeInputs vi = beansObjectFactory.createVolumeInputs (); + + if (ar.getVolumeGroupId () != null) { + vi.setVolumeGroupId (ar.getVolumeGroupId ()); + } + if (ar.getVolumeGroupName () != null) { + vi.setVolumeGroupName (ar.getVolumeGroupName ()); + } + if (ar.getVnfType () != null) { + vi.setVnfType (ar.getVnfType ()); + } + + if (version.equals(Constants.SCHEMA_VERSION_V1)) { + if (ar.getServiceType () != null) { + vi.setServiceType (ar.getServiceType ()); + } + if (ar.getAicNodeClli () != null) { + vi.setAicNodeClli (ar.getAicNodeClli ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V2)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getVfModuleModelName () != null) { + vi.setVfModuleModelName (ar.getVfModuleModelName ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V3)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getVfModuleModelName () != null) { + vi.setVfModuleModelName (ar.getVfModuleModelName ()); + } + if (ar.getServiceInstanceId () != null) { + vi.setServiceInstanceId (ar.getServiceInstanceId ()); + } + if (ar.getVnfId () != null) { + vi.setVnfId (ar.getVnfId ()); + } + } + if (ar.getTenantId () != null) { + vi.setTenantId (ar.getTenantId ()); + } + + qr.setVolumeInputs (vi); + + qr.setVolumeParams(ar.getVnfParams ()); + + try { + String volumeoutputs = ar.getVnfOutputs (); + if (volumeoutputs != null && volumeoutputs.length () > 0) { + msoLogger.debug ("Read VOLUME outputs: " + volumeoutputs); + VolumeOutputs volumeOutput = null; + + // Now unmarshal it into network outputs + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeOutputs.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); + + InputSource inputSource = new InputSource (new StringReader (volumeoutputs)); + SAXSource source = new SAXSource (inputSource); + + volumeOutput = (VolumeOutputs) jaxbUnmarshaller.unmarshal (source, VolumeOutputs.class).getValue (); + + } catch (Exception e) { + msoLogger.debug ("Validation failed", e); + throw new ValidationException ("format for volume outputs"); + } + + qr.setVolumeOutputs (volumeOutput); + } + } catch (Exception e) { + msoLogger.debug ("exception reading networkOutputs Clob", e); + } + } + + protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String volumeGroupId, String volumeGroupName, String version) { + if (serviceType != null) { + return this.getRequestList ("serviceType", serviceType, version); + } + if (aicNodeClli != null) { + return this.getRequestList ("aicNodeClli", aicNodeClli, version); + } + if (tenantId != null) { + return this.getRequestList ("tenantId", tenantId, version); + } + if (volumeGroupName != null) { + return this.getRequestList ("volumeGroupName", volumeGroupName, version); + } + if (volumeGroupId != null) { + return this.getRequestList ("volumeGroupId", volumeGroupId, version); + } + return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); + } + + + protected Response getRequestGeneric (String requestId, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest: " + requestId); + + String responseString = null; + + InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, + "VOLUME"); + if (activeReq != null) { + // build response for active + responseString = infraRequestsResponse (activeReq, version); + return Response.status (HttpStatus.SC_OK).entity (responseString).build (); + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + protected Response getRequestList (String queryAttribute, String queryValue, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); + + List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute, + queryValue, + "VOLUME"); + + List <VolumeRequest> queryResponseList = new LinkedList <VolumeRequest> (); + + if (activeReqList != null) { + // build response for active + queryResponseList = infraRequestsResponses (activeReqList, version); + + } + + + if (queryResponseList != null && !queryResponseList.isEmpty ()) { + String result = this.translateVolumeRequests (queryResponseList); + return Response.status (HttpStatus.SC_OK).entity (result).build (); + + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + private VolumeRequest fillGeneric (InfraRequests ar) { + VolumeRequest qr = beansObjectFactory.createVolumeRequest (); + RequestInfo ri = beansObjectFactory.createRequestInfo (); + ri.setRequestId (ar.getRequestId ()); + ri.setAction (ActionType.fromValue (ar.getAction ())); + ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); + if (ar.getProgress () != null) { + ri.setProgress (ar.getProgress ().intValue ()); + } + if (ar.getSource () != null) { + ri.setSource (ar.getSource ()); + } + + ri.setStartTime (ar.getStartTime ().toString ()); + if (ar.getEndTime () != null) { + ri.setEndTime (ar.getEndTime ().toString ()); + } + + if (ar.getStatusMessage () != null) { + ri.setStatusMessage (ar.getStatusMessage ()); + } + qr.setRequestInfo (ri); + return qr; + } + + private List <VolumeRequest> infraRequestsResponses (List <? extends InfraRequests> arList, String version) { + List <VolumeRequest> queryResponseList = new LinkedList <VolumeRequest> (); + + for (InfraRequests ar : arList) { + VolumeRequest qr = fillGeneric (ar); + fillVolumeRequest (qr, ar, version); + queryResponseList.add (qr); + } + return queryResponseList; + } + + private String translateVolumeRequests (List <VolumeRequest> queryResponseList) { + VolumeRequests queryResponses = new VolumeRequests (); + for (int i = 0; i < queryResponseList.size (); i++) { + queryResponses.getVolumeRequest ().add (queryResponseList.get (i)); + } + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequests.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (queryResponses, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + return stringWriter.toString (); + } + + private String infraRequestsResponse (InfraRequests ar, String version) { + VolumeRequest qr = fillGeneric (ar); + fillVolumeRequest (qr, ar, version); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.marshal (qr, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + String response = stringWriter.toString (); + return response; + } + + private String getAuditLogReturnMsg (Response response) { + String returnMsg = ""; + if (response.getStatus() == HttpStatus.SC_OK) { + returnMsg = "Successful. StatusCode=" + HttpStatus.SC_OK; + } else if (response.getStatus() == HttpStatus.SC_NOT_FOUND) { + returnMsg = "Record not found . StatusCode=" + HttpStatus.SC_NOT_FOUND; + } else if (response.getStatus() == HttpStatus.SC_BAD_REQUEST) { + returnMsg = "Bad request: one of the following attribute serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName should be defined. StatusCode=" + HttpStatus.SC_BAD_REQUEST; + } + return returnMsg; + } +} 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 new file mode 100644 index 0000000000..42ef60bfaf --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java @@ -0,0 +1,644 @@ +/*- + * ============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.apihandlerinfra; + +import java.io.StringReader; +import java.io.StringWriter; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +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.hibernate.Query; +import org.hibernate.Session; +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.volumebeans.ActionType; +import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeInputs; +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.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.InfraActiveRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; + +public class VolumeMsoInfraRequest { + + private String requestId; + private String requestXML; + private String requestUri; + private RequestInfo rinfo; + private VolumeInputs volumeInputs; + private String volumeParams; + private ActionType action; + private String errorMessage; + private String httpResponse; + private String responseBody; + private RequestStatusType status; + private long startTime; + private long progress = Constants.PROGRESS_REQUEST_RECEIVED; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + private static final String NOT_PROVIDED = "not provided"; + + VolumeMsoInfraRequest (String requestId) { + this.requestId = requestId; + Calendar startTimeCalendar = Calendar.getInstance (); + this.startTime = startTimeCalendar.getTimeInMillis (); + MsoLogger.setLogContext (requestId, null); + + } + + // Parse request XML + void parse (String reqXML, String version, MsoJavaProperties props) throws ValidationException { + + msoLogger.debug ("Validating the request"); + + this.requestXML = reqXML; + + VolumeRequest volumeReq = null; + boolean isWrongRootElement = false; + + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); + + InputSource inputSource = new InputSource (new StringReader (reqXML)); + SAXSource source = new SAXSource (inputSource); + + if (reqXML.contains ("volume-request") && !reqXML.contains("vnf-request")) { + volumeReq = jaxbUnmarshaller.unmarshal (source, VolumeRequest.class).getValue (); + } else { + isWrongRootElement = true; + } + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_VNFREQUEST_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception when parsing reqXML", e); + throw new ValidationException ("format for volume request"); + } + + if (isWrongRootElement) { + msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR_REASON, "root element is not correct", "", "", MsoLogger.ErrorCode.SchemaError, "root element <volume-request> expected"); + throw new ValidationException ("root element <volume-request> expected"); + } + + if (volumeReq == null) { + throw new ValidationException ("volume-request"); + } + + this.rinfo = volumeReq.getRequestInfo (); + + if (this.rinfo == null) { + throw new ValidationException ("request-info"); + } + + 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 (!InfraUtils.isActionAllowed (props, "volume", version, action.value ())) { + throw new ValidationException ("action allowable for version " + version + " of volume request"); + } + + switch (action) { + case UPDATE: + case DELETE: + case UPDATE_VF_MODULE_VOL: + case DELETE_VF_MODULE_VOL: + if (this.volumeInputs.getVolumeGroupId () == null) { + throw new ValidationException ("volume-group-id"); + } + break; + 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"); + } + 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: + if (this.volumeInputs.getVfModuleModelName () == null) { + throw new ValidationException ("vf-module-model-name"); + } + break; + 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 (this.volumeInputs.getTenantId () == null) { + throw new ValidationException ("tenant-id"); + } + } + + + Object vpN = volumeReq.getVolumeParams (); + + if (vpN != null) { + Node node = (Node) vpN; + Document doc = node.getOwnerDocument (); + this.volumeParams = domToStr (doc); + } + + msoLogger.debug ("VolumeParams: " + this.volumeParams); + + + msoLogger.debug ("Request valid"); + + // Rebuild the request string for BPEL to include request-id + rinfo.setRequestId (this.requestId); + volumeReq.setRequestInfo (rinfo); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (volumeReq, stringWriter); + + } catch (JAXBException e) { + 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"); + + msoLogger.debug("REQUEST XML to BPEL: " + this.requestXML); + + } + + public void createRequestRecord (Status status) { + + Session session = null; + try { + + session = HibernateUtil.getSessionFactory ().openSession (); + session.beginTransaction (); + + InfraActiveRequests aq = new InfraActiveRequests (); + aq.setRequestId (requestId); + + Timestamp startTimeStamp = new Timestamp (Calendar.getInstance ().getTimeInMillis ()); + if (rinfo != null) { + if (rinfo.getAction () != null) { + aq.setAction (rinfo.getAction ().value ()); + aq.setRequestAction (RequestActionMap.getMappedRequestAction (rinfo.getAction ().value ())); + } + aq.setSource (rinfo.getSource ()); + } else { + // Set up mandatory parameters + aq.setAction (NOT_PROVIDED); + aq.setAction (NOT_PROVIDED); + } + + aq.setRequestBody (this.requestXML); + aq.setRequestScope (ModelType.volumeGroup.name ()); + + if (volumeInputs != null) { + if (volumeInputs.getVolumeGroupId () != null) { + aq.setVolumeGroupId (volumeInputs.getVolumeGroupId ()); + } + if (volumeInputs.getVolumeGroupName () != null) { + aq.setVolumeGroupName (volumeInputs.getVolumeGroupName ()); + } + if (volumeInputs.getVnfType () != null) { + aq.setVnfType (volumeInputs.getVnfType ()); + } + if (volumeInputs.getVnfId () != null) { + aq.setVnfId (volumeInputs.getVnfId ()); + } + if (volumeInputs.getServiceInstanceId () != null) { + aq.setServiceInstanceId (volumeInputs.getServiceInstanceId ()); + } + if (volumeInputs.getServiceType () != null) { + aq.setServiceType (volumeInputs.getServiceType ()); + } + if (volumeInputs.getServiceId () != null) { + aq.setAaiServiceId (volumeInputs.getServiceId ()); + } + if (volumeInputs.getAicNodeClli () != null) { + aq.setAicNodeClli (volumeInputs.getAicNodeClli ()); + } + if (volumeInputs.getAicCloudRegion () != null) { + aq.setAicCloudRegion (volumeInputs.getAicCloudRegion ()); + } + if (volumeInputs.getTenantId () != null) { + aq.setTenantId (volumeInputs.getTenantId ()); + } + + } + aq.setStartTime (startTimeStamp); + aq.setRequestStatus (status.toString ()); + aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); + aq.setRequestType ("VOLUME"); + + if (volumeParams != null) { + msoLogger.debug ("Storing volumeParams: " + volumeParams); + aq.setVnfParams (this.volumeParams); + } + + if ((status == Status.FAILED) || (status == Status.COMPLETE)) { + aq.setStatusMessage (this.errorMessage); + aq.setResponseBody (this.responseBody); + + Calendar endTime = Calendar.getInstance (); + Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ()); + aq.setEndTime (endTimeStamp); + } + aq.setProgress (this.progress); + + + msoLogger.debug ("About to insert a record"); + + session.save (aq); + session.getTransaction ().commit (); + session.close (); + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in createRequestRecord", e); + if (session != null) { + session.close (); + } + if (!status.equals (Status.FAILED)) { + throw e; + } + } + } + + public void updateFinalStatus (Status status) { + int result = 0; + try { + 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"); + msoLogger.debug("Exception: ", e); + } + } + + public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { + return buildResponseWithError (httpResponseCode, errorCode, inProgress, null); + } + + public Response buildResponseWithError (int httpResponseCode, + String errorCode, + InfraActiveRequests inProgress, + String errorString) { + + ObjectFactory beansObjectFactory = new ObjectFactory (); + + VolumeRequest vr = beansObjectFactory.createVolumeRequest (); + + RequestInfo ri = beansObjectFactory.createRequestInfo (); + + ri.setRequestId (requestId); + ri.setRequestStatus (this.status); + ri.setAction (this.rinfo.getAction ()); + ri.setSource (this.rinfo.getSource ()); + + String errorMsg = null; + if (errorCode != null) { + // If error code is actually an XML error response from BPEL, treat it specially: + if (!Messages.errors.containsKey (errorCode)) { + if (errorCode.length () > 300) { + errorMsg = errorCode.substring (0, 299); + } else { + errorMsg = errorCode; + } + + } else { + + if (inProgress == null) { + if (errorCode.equals(ErrorNumbers.RECIPE_DOES_NOT_EXIST)) { + errorMsg = String.format (Messages.errors.get (errorCode), "volume", errorString); + } + else { + errorMsg = String.format (Messages.errors.get (errorCode), errorString); + } + } else if (errorCode.equals (ErrorNumbers.LOCKED_CREATE_ON_THE_SAME_VNF_NAME_IN_PROGRESS)) { + errorMsg = String.format (Messages.errors.get (errorCode), + "volume", + inProgress.getVnfName (), + inProgress.getRequestStatus (), + "volume"); + } else if (errorCode.equals (ErrorNumbers.LOCKED_SAME_ACTION_AND_VNF_ID)) { + errorMsg = String.format (Messages.errors.get (errorCode), + "volume", + inProgress.getVnfId (), + inProgress.getRequestStatus (), + inProgress.getAction (), + "volume"); + } + } + + ri.setStatusMessage (errorMsg); + this.errorMessage = errorMsg; + } + ri.setProgress ((int) this.progress); + + Date startDate = new Date (this.startTime); + SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); + String startTimeString = sdf.format (startDate); + + ri.setStartTime (startTimeString); + + vr.setRequestInfo (ri); + vr.setVolumeInputs (this.volumeInputs); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (vr, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Exception: ", e); + } + + String response = stringWriter.toString (); + + this.httpResponse = Integer.toString (httpResponseCode); + this.responseBody = response; + + // Log the failed request into the MSO Requests database + + return Response.status (httpResponseCode).entity (response).build (); + + } + + public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) { + + ObjectFactory beansObjectFactory = new ObjectFactory (); + VolumeRequest vr = beansObjectFactory.createVolumeRequest (); + + RequestInfo ri = beansObjectFactory.createRequestInfo (); + ri.setRequestId (requestId); + + if (this.rinfo != null) { + if (this.rinfo.getAction () != null) { + ri.setAction (this.rinfo.getAction ()); + } else { + ri.setAction (ActionType.NOT_PROVIDED); + } + if (this.rinfo.getSource () != null) { + ri.setSource (this.rinfo.getSource ()); + } + } else { + ri.setAction (ActionType.NOT_PROVIDED); + } + + // Nothing more is expected for this request + + String errorMsg = String.format (Messages.errors.get (ErrorNumbers.REQUEST_FAILED_SCHEMA_VALIDATION + + "_service"), + exceptionMessage); + ri.setStatusMessage (errorMsg); + this.errorMessage = errorMsg; + + ri.setProgress ((int) this.progress); + ri.setRequestStatus (RequestStatusType.FAILED); + Date startDate = new Date (this.startTime); + SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS"); + String startTimeString = sdf.format (startDate); + + ri.setStartTime (startTimeString); + + vr.setRequestInfo (ri); + vr.setVolumeInputs (this.volumeInputs); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (vr, stringWriter); + + } catch (JAXBException e) { + msoLogger.debug ("Error marshalling", e); + } + + String response = stringWriter.toString (); + + this.httpResponse = Integer.toString (httpResponseCode); + this.responseBody = response; + + return Response.status (httpResponseCode).entity (response).build (); + } + + public String getRequestUri () { + return requestUri; + } + + public void setRequestUri (String requestUri) { + this.requestUri = requestUri; + } + + public VolumeInputs getVolumeInputs () { + return volumeInputs; + } + + public RequestInfo getRequestInfo () { + return rinfo; + } + + public String getResponseBody () { + return responseBody; + } + + public void setResponseBody (String responseBody) { + this.responseBody = responseBody; + } + + public String getHttpResponse () { + return httpResponse; + } + + public void setHttpResponse (String httpResponse) { + this.httpResponse = httpResponse; + } + + public String getRequestId () { + return requestId; + } + + public String getRequestXML () { + return requestXML; + } + + public void setRequestXML (String requestXML) { + this.requestXML = requestXML; + } + + public RequestStatusType getStatus () { + return status; + } + + public void setStatus (RequestStatusType status) { + this.status = status; + switch (status) { + case FAILED: + case COMPLETE: + this.progress = Constants.PROGRESS_REQUEST_COMPLETED; + break; + case IN_PROGRESS: + this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; + break; + } + } + + public String getServiceType () { + if (this.volumeInputs.getServiceType () != null) + return this.volumeInputs.getServiceType (); + if (this.volumeInputs.getServiceId () != null) + return this.volumeInputs.getServiceId (); + return null; + } + + public static String domToStr (Document doc) { + if (doc == null) { + return null; + } + + try { + StringWriter sw = new StringWriter (); + StreamResult sr = new StreamResult (sw); + TransformerFactory tf = TransformerFactory.newInstance (); + Transformer t = tf.newTransformer (); + t.setOutputProperty (OutputKeys.STANDALONE, "yes"); + NodeList nl = doc.getDocumentElement ().getChildNodes (); + DOMSource source = null; + for (int x = 0; x < nl.getLength (); x++) { + Node e = nl.item (x); + if (e instanceof Element) { + source = new DOMSource (e); + break; + } + } + if (source != null) { + t.transform (source, sr); + + String s = sw.toString (); + return s; + } + + return null; + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception in domToStr", e); + } + return null; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java new file mode 100644 index 0000000000..7c1b74c684 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java @@ -0,0 +1,746 @@ +/*- + * ============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.apihandlerinfra; + + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; + +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.sax.SAXSource; + +import org.xml.sax.InputSource; + +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.volumebeans.ActionType; +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.VolumeInputs; +import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeOutputs; +import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest; +import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequests; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.Recipe; +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.InfraRequests; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.utils.UUIDChecker; + +@Path("/{version: v1|v2|v3}/volume-request") +public class VolumeRequestHandler { + + @Context + private UriInfo uriInfo; + + protected ObjectFactory beansObjectFactory = new ObjectFactory (); + + public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); + + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + + private static MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties (); + + 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 (); + + @GET + public Response queryFilters (@QueryParam("vnf-type") String vnfType, + @QueryParam("service-type") String serviceType, + @QueryParam("aic-node-clli") String aicNodeClli, + @QueryParam("tenantId") String tenantId, + @QueryParam("volume-group-id") String volumeGroupId, + @QueryParam("volume-group-name") String volumeGroupName, + @PathParam("version") String version) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("VolumeQueryFilters"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for queryFilter with vnf-type:" + vnfType + + " service-type:" + serviceType + + " aic-node-clli:" + aicNodeClli + + " tenant-id:" + tenantId + + " volume-group-id:" + volumeGroupId + + " volume-group-name:" + volumeGroupName); + Response response = null; + if (vnfType != null) { + response = this.getRequestList ("vnfType", vnfType, version); + } else { + response = queryGenericFilters (serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName, version); + } + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + } + + @GET + @Path(Constants.REQUEST_ID_PATH) + public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) { + + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("VolumeGetRequest"); + // Generate a Request Id + UUIDChecker.generateUUID(msoLogger); + msoLogger.debug ("Incoming request received for getRequest with request-id:" + requestId); + + Response response = getRequestGeneric (requestId, version); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + + } + + + protected MsoLogger getMsoLogger () { + return msoLogger; + } + + + protected void fillVolumeRequest (VolumeRequest qr, InfraRequests ar, String version) { + VolumeInputs vi = beansObjectFactory.createVolumeInputs (); + + if (ar.getVolumeGroupId () != null) { + vi.setVolumeGroupId (ar.getVolumeGroupId ()); + } + if (ar.getVolumeGroupName () != null) { + vi.setVolumeGroupName (ar.getVolumeGroupName ()); + } + if (ar.getVnfType () != null) { + vi.setVnfType (ar.getVnfType ()); + } + + if (version.equals(Constants.SCHEMA_VERSION_V1)) { + if (ar.getServiceType () != null) { + vi.setServiceType (ar.getServiceType ()); + } + if (ar.getAicNodeClli () != null) { + vi.setAicNodeClli (ar.getAicNodeClli ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V2)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getVfModuleModelName () != null) { + vi.setVfModuleModelName (ar.getVfModuleModelName ()); + } + } + else if (version.equals(Constants.SCHEMA_VERSION_V3)) { + if (ar.getAaiServiceId () != null) { + vi.setServiceId (ar.getAaiServiceId ()); + } + if (ar.getAicCloudRegion () != null) { + vi.setAicCloudRegion (ar.getAicCloudRegion ()); + } + if (ar.getVfModuleModelName () != null) { + vi.setVfModuleModelName (ar.getVfModuleModelName ()); + } + if (ar.getServiceInstanceId () != null) { + vi.setServiceInstanceId (ar.getServiceInstanceId ()); + } + if (ar.getVnfId () != null) { + vi.setVnfId (ar.getVnfId ()); + } + } + if (ar.getTenantId () != null) { + vi.setTenantId (ar.getTenantId ()); + } + + qr.setVolumeInputs (vi); + + qr.setVolumeParams(ar.getVnfParams ()); + + try { + String volumeoutputs = ar.getVnfOutputs (); + if (volumeoutputs != null && volumeoutputs.length () > 0) { + msoLogger.debug ("Read VOLUME outputs: " + volumeoutputs); + VolumeOutputs volumeOutput = null; + + // Now unmarshal it into network outputs + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeOutputs.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller (); + + InputSource inputSource = new InputSource (new StringReader (volumeoutputs)); + SAXSource source = new SAXSource (inputSource); + + volumeOutput = (VolumeOutputs) jaxbUnmarshaller.unmarshal (source, VolumeOutputs.class).getValue (); + + } catch (Exception e) { + msoLogger.debug ("Validation failed", e); + throw new ValidationException ("format for volume outputs"); + } + + qr.setVolumeOutputs (volumeOutput); + } + } catch (Exception e) { + msoLogger.debug ("exception reading networkOutputs Clob", e); + } + } + + protected Response queryGenericFilters (String serviceType, String aicNodeClli, String tenantId, String volumeGroupId, String volumeGroupName, String version) { + if (serviceType != null) { + return this.getRequestList ("serviceType", serviceType, version); + } + if (aicNodeClli != null) { + return this.getRequestList ("aicNodeClli", aicNodeClli, version); + } + if (tenantId != null) { + return this.getRequestList ("tenantId", tenantId, version); + } + if (volumeGroupName != null) { + return this.getRequestList ("volumeGroupName", volumeGroupName, version); + } + if (volumeGroupId != null) { + return this.getRequestList ("volumeGroupId", volumeGroupId, version); + } + return Response.status (HttpStatus.SC_BAD_REQUEST).entity ("").build (); + } + + + protected Response getRequestGeneric (String requestId, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest: " + requestId); + + String responseString = null; + + InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, + "VOLUME"); + if (activeReq != null) { + // build response for active + responseString = infraRequestsResponse (activeReq, version); + return Response.status (HttpStatus.SC_OK).entity (responseString).build (); + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + protected Response getRequestList (String queryAttribute, String queryValue, String version) { + // Check INFRA_ACTIVE_REQUESTS table to find info + // on this request + + getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue); + + List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute, + queryValue, + "VOLUME"); + + List <VolumeRequest> queryResponseList = new LinkedList <VolumeRequest> (); + + if (activeReqList != null) { + // build response for active + queryResponseList = infraRequestsResponses (activeReqList, version); + + } + + + if (queryResponseList != null && !queryResponseList.isEmpty ()) { + String result = this.translateVolumeRequests (queryResponseList); + return Response.status (HttpStatus.SC_OK).entity (result).build (); + + } else { + // Report that no request has been found + return Response.status (HttpStatus.SC_NOT_FOUND).entity ("").build (); + } + } + + private VolumeRequest fillGeneric (InfraRequests ar) { + VolumeRequest qr = beansObjectFactory.createVolumeRequest (); + RequestInfo ri = beansObjectFactory.createRequestInfo (); + ri.setRequestId (ar.getRequestId ()); + ri.setAction (ActionType.fromValue (ar.getAction ())); + ri.setRequestStatus (RequestStatusType.fromValue (ar.getRequestStatus ())); + if (ar.getProgress () != null) { + ri.setProgress (ar.getProgress ().intValue ()); + } + if (ar.getSource () != null) { + ri.setSource (ar.getSource ()); + } + + ri.setStartTime (ar.getStartTime ().toString ()); + if (ar.getEndTime () != null) { + ri.setEndTime (ar.getEndTime ().toString ()); + } + + if (ar.getStatusMessage () != null) { + ri.setStatusMessage (ar.getStatusMessage ()); + } + qr.setRequestInfo (ri); + return qr; + } + + private List <VolumeRequest> infraRequestsResponses (List <? extends InfraRequests> arList, String version) { + List <VolumeRequest> queryResponseList = new LinkedList <VolumeRequest> (); + + for (InfraRequests ar : arList) { + VolumeRequest qr = fillGeneric (ar); + fillVolumeRequest (qr, ar, version); + queryResponseList.add (qr); + } + return queryResponseList; + } + + private String translateVolumeRequests (List <VolumeRequest> queryResponseList) { + VolumeRequests queryResponses = new VolumeRequests (); + for (int i = 0; i < queryResponseList.size (); i++) { + queryResponses.getVolumeRequest ().add (queryResponseList.get (i)); + } + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequests.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + // output pretty printed + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + + jaxbMarshaller.marshal (queryResponses, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + return stringWriter.toString (); + } + + private String infraRequestsResponse (InfraRequests ar, String version) { + VolumeRequest qr = fillGeneric (ar); + fillVolumeRequest (qr, ar, version); + + StringWriter stringWriter = new StringWriter (); + try { + JAXBContext jaxbContext = JAXBContext.newInstance (VolumeRequest.class); + Marshaller jaxbMarshaller = jaxbContext.createMarshaller (); + + jaxbMarshaller.setProperty (Marshaller.JAXB_FORMATTED_OUTPUT, true); + jaxbMarshaller.marshal (qr, stringWriter); + + } catch (JAXBException e) { + getMsoLogger ().debug ("Marshalling issue", e); + } + + String response = stringWriter.toString (); + return response; + } + + private String getAuditLogReturnMsg (Response response) { + String returnMsg = ""; + if (response.getStatus() == HttpStatus.SC_OK) { + returnMsg = "Successful. StatusCode=" + HttpStatus.SC_OK; + } else if (response.getStatus() == HttpStatus.SC_NOT_FOUND) { + returnMsg = "Record not found . StatusCode=" + HttpStatus.SC_NOT_FOUND; + } else if (response.getStatus() == HttpStatus.SC_BAD_REQUEST) { + returnMsg = "Bad request: one of the following attribute serviceType, aicNodeClli, tenantId, volumeGroupId, volumeGroupName should be defined. StatusCode=" + HttpStatus.SC_BAD_REQUEST; + } + return returnMsg; + } + + @POST + @Path("/") + @Produces(MediaType.APPLICATION_XML) + public Response manageVolumeRequest (String reqXML, @PathParam("version") String version) { + MsoLogger.setServiceName ("VolumeRequest"); + if ("v1".equals(version)) { + return manageVolumeRequestImpl (reqXML, Constants.SCHEMA_VERSION_V1); + } else if ("v2".equals(version)) { + return manageVolumeRequestImpl (reqXML, Constants.SCHEMA_VERSION_V2); + } else if ("v3".equals(version)) { + return manageVolumeRequestImpl (reqXML, Constants.SCHEMA_VERSION_V3); + } else { + long startTime = System.currentTimeMillis (); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Version not found"); + return Response.status(HttpStatus.SC_NOT_FOUND).build(); + } + } + + private Response manageVolumeRequestImpl (String reqXML, String version) { + String methodName = "VolumeRequest"; + props = MsoPropertiesUtils.loadMsoProperties (); + + long startTime = System.currentTimeMillis (); + if (MsoPropertiesUtils.getNoPropertiesState()) { + 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); + db.close (); + 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; + } + + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ActionType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ActionType.java new file mode 100644 index 0000000000..d5e9629ce1 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ActionType.java @@ -0,0 +1,74 @@ +/*- + * ============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========================================================= + */ + +// +// 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.XmlEnum; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for action-type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * <pre> + * <simpleType name="action-type"> + * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> + * <enumeration value="CREATE"/> + * <enumeration value="SETSTATUS"/> + * <enumeration value="REPLACE"/> + * <enumeration value="UPDATE"/> + * <enumeration value="DELETE"/> + * <enumeration value="NOT_PROVIDED"/> + * </restriction> + * </simpleType> + * </pre> + * + */ +@XmlType(name = "action-type") +@XmlEnum +public enum ActionType { + + CREATE, + SETSTATUS, + REPLACE, + UPDATE, + DELETE, + NOT_PROVIDED; + + public String value() { + return name(); + } + + public static ActionType fromValue(String v) { + return valueOf(v); + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkInputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkInputs.java new file mode 100644 index 0000000000..f2bf59e298 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkInputs.java @@ -0,0 +1,378 @@ +/*- + * ============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========================================================= + */ + +// +// 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; +import javax.xml.bind.annotation.XmlRootElement; +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="network-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="network-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="network-type" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="service-instance-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="backout-on-failure" type="{http://www.w3.org/2001/XMLSchema}Boolean"/> + * <choice> + * <element name="service-type" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="service-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </choice> + * <choice> + * <element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="aic-cloud-region" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </choice> + * <element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="tenant-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="prov-status" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "networkId", + "networkName", + "networkType", + "serviceInstanceId", + "backoutOnFailure", + "serviceType", + "serviceId", + "aicNodeClli", + "aicCloudRegion", + "tenantId", + "provStatus" +}) +@XmlRootElement(name = "network-inputs") +public class NetworkInputs { + + @XmlElement(name = "network-id") + protected String networkId; + @XmlElement(name = "network-name") + protected String networkName; + @XmlElement(name = "network-type", required = true) + protected String networkType; + @XmlElement(name = "service-instance-id") + protected String serviceInstanceId; + @XmlElement(name = "backout-on-failure") + protected Boolean backoutOnFailure; + @XmlElement(name = "service-type") + protected String serviceType; + @XmlElement(name = "service-id") + protected String serviceId; + @XmlElement(name = "aic-node-clli") + protected String aicNodeClli; + @XmlElement(name = "aic-cloud-region") + protected String aicCloudRegion; + @XmlElement(name = "tenant-id", required = true) + protected String tenantId; + @XmlElement(name = "prov-status") + protected String provStatus; + + /** + * Gets the value of the networkId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getNetworkId() { + return networkId; + } + + /** + * Sets the value of the networkId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setNetworkId(String value) { + this.networkId = value; + } + + /** + * Gets the value of the networkName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getNetworkName() { + return networkName; + } + + /** + * Sets the value of the networkName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setNetworkName(String value) { + this.networkName = value; + } + + /** + * Gets the value of the networkType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getNetworkType() { + return networkType; + } + + /** + * Sets the value of the networkType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setNetworkType(String value) { + this.networkType = value; + } + + /** + * Gets the value of the serviceInstanceId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceInstanceId() { + return serviceInstanceId; + } + + /** + * Sets the value of the serviceInstanceId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceInstanceId(String value) { + this.serviceInstanceId = value; + } + + /** + * Gets the value of the serviceType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceType() { + return serviceType; + } + + /** + * Sets the value of the serviceType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceType(String value) { + this.serviceType = value; + } + + /** + * Gets the value of the serviceId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceId() { + return serviceId; + } + + /** + * Sets the value of the serviceId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceId (String value) { + this.serviceId = value; + } + + + /** + * Gets the value of the aicNodeClli property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicNodeClli() { + return aicNodeClli; + } + + /** + * Sets the value of the aicNodeClli property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicNodeClli(String value) { + this.aicNodeClli = value; + } + + /** + * Gets the value of the aicCloudRegion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicCloudRegion() { + return aicCloudRegion; + } + + /** + * Sets the value of the aicCloudRegion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicCloudRegion(String value) { + this.aicCloudRegion = value; + } + + + /** + * Gets the value of the tenantId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTenantId() { + return tenantId; + } + + /** + * Sets the value of the tenantId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTenantId(String value) { + this.tenantId = value; + } + + /** + * Gets the value of the provStatus property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProvStatus() { + return provStatus; + } + + /** + * Sets the value of the provStatus property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProvStatus(String value) { + this.provStatus = value; + } + + /** + * Gets the value of the backoutOnFailure property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean getBackoutOnFailure() { + return backoutOnFailure; + } + + /** + * Sets the value of the backoutOnFailure property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setBackoutOnFailure(Boolean value) { + this.backoutOnFailure = value; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputs.java new file mode 100644 index 0000000000..683b76452b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkOutputs.java @@ -0,0 +1,120 @@ +/*- + * ============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========================================================= + */ + +// +// 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; +import javax.xml.bind.annotation.XmlRootElement; +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="network-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="network-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "networkId", + "networkName" +}) +@XmlRootElement(name = "network-outputs") +public class NetworkOutputs { + + @XmlElement(name = "network-id", required = true) + protected String networkId; + @XmlElement(name = "network-name", required = true) + protected String networkName; + + /** + * Gets the value of the networkId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getNetworkId() { + return networkId; + } + + /** + * Sets the value of the networkId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setNetworkId(String value) { + this.networkId = value; + } + + /** + * Gets the value of the networkName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getNetworkName() { + return networkName; + } + + /** + * Sets the value of the networkName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setNetworkName(String value) { + this.networkName = value; + } + +} 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 new file mode 100644 index 0000000000..41e1236a8b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequest.java @@ -0,0 +1,179 @@ +/*- + * ============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========================================================= + */ + +// +// 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; +import javax.xml.bind.annotation.XmlRootElement; +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 ref="{http://ecomp.att.com/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"/> + * </sequence> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestInfo", + "networkInputs", + "networkParams", + "networkOutputs" +}) +@XmlRootElement(name = "network-request") +public class NetworkRequest { + + @XmlElement(name = "request-info", required = true) + protected RequestInfo requestInfo; + @XmlElement(name = "network-inputs") + protected NetworkInputs networkInputs; + @XmlElement(name = "network-params") + protected Object networkParams; + @XmlElement(name = "network-outputs") + protected NetworkOutputs networkOutputs; + + /** + * Gets the value of the requestInfo property. + * + * @return + * possible object is + * {@link RequestInfo } + * + */ + public RequestInfo getRequestInfo() { + return requestInfo; + } + + /** + * Sets the value of the requestInfo property. + * + * @param value + * allowed object is + * {@link RequestInfo } + * + */ + public void setRequestInfo(RequestInfo value) { + this.requestInfo = value; + } + + + /** + * Gets the value of the networkInputs property. + * + * @return + * possible object is + * {@link NetworkInputs } + * + */ + public NetworkInputs getNetworkInputs() { + return networkInputs; + } + + /** + * Sets the value of the networkInputs property. + * + * @param value + * allowed object is + * {@link NetworkInputs } + * + */ + public void setNetworkInputs(NetworkInputs value) { + this.networkInputs = value; + } + + /** + * Gets the value of the networkParams property. + * + * @return + * possible object is + * {@link Object } + * + */ + public Object getNetworkParams() { + return networkParams; + } + + /** + * Sets the value of the networkParams property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setNetworkParams(Object value) { + this.networkParams = value; + } + + /** + * Gets the value of the networkOutputs property. + * + * @return + * possible object is + * {@link NetworkOutputs } + * + */ + public NetworkOutputs getNetworkOutputs() { + return networkOutputs; + } + + /** + * Sets the value of the networkOutputs property. + * + * @param value + * allowed object is + * {@link NetworkOutputs } + * + */ + public void setNetworkOutputs(NetworkOutputs value) { + this.networkOutputs = value; + } + +} 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 new file mode 100644 index 0000000000..1c0cd94ca2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkRequests.java @@ -0,0 +1,99 @@ +/*- + * ============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========================================================= + */ + +// +// 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 java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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 ref="{http://ecomp.att.com/mso/infra/network-request/v1}network-request" maxOccurs="unbounded" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "networkRequest" +}) +@XmlRootElement(name = "network-requests") +public class NetworkRequests { + + @XmlElement(name = "network-request") + protected List<NetworkRequest> networkRequest; + + /** + * Gets the value of the networkRequest property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the vnfRequest property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getNetworkRequest().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link NetworkRequest } + * + * + */ + public List<NetworkRequest> getNetworkRequest() { + if (networkRequest == null) { + networkRequest = new ArrayList<NetworkRequest>(); + } + return this.networkRequest; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkType.java new file mode 100644 index 0000000000..a92fd33234 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkType.java @@ -0,0 +1,148 @@ +/*- + * ============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========================================================= + */ + +// +// 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; +import javax.xml.bind.annotation.XmlRootElement; +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="type" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="description" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "type", + "id", + "description" +}) +@XmlRootElement(name = "network-type") +public class NetworkType { + + @XmlElement(required = true) + protected String type; + @XmlElement(required = true) + protected String id; + @XmlElement(required = true) + protected String description; + + /** + * Gets the value of the type property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the description property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDescription() { + return description; + } + + /** + * Sets the value of the description property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDescription(String value) { + this.description = value; + } + +} 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 new file mode 100644 index 0000000000..e7ddc929b2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/NetworkTypes.java @@ -0,0 +1,99 @@ +/*- + * ============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========================================================= + */ + +// +// 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 java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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 ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vnf-type" maxOccurs="unbounded" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "networkType" +}) +@XmlRootElement(name = "network-types") +public class NetworkTypes { + + @XmlElement(name = "network-type") + protected List<NetworkType> networkType; + + /** + * Gets the value of the networkType property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the vnfType property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getNetworkType().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link NetworkType } + * + * + */ + public List<NetworkType> getNetworkType() { + if (networkType == null) { + networkType = new ArrayList<NetworkType>(); + } + return this.networkType; + } + +} 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 new file mode 100644 index 0000000000..df553da518 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/ObjectFactory.java @@ -0,0 +1,129 @@ +/*- + * ============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========================================================= + */ + +// +// 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.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.openecomp.mso.apihandlerinfra.vnfbeans1 package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _NetworkParams_QNAME = new QName("http://ecomp.att.com/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 + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link RequestInfo } + * + */ + public RequestInfo createRequestInfo() { + return new RequestInfo(); + } + + /** + * Create an instance of {@link NetworkRequest } + * + */ + public NetworkRequest createNetworkRequest() { + return new NetworkRequest(); + } + + /** + * Create an instance of {@link NetworkInputs } + * + */ + public NetworkInputs createNetworkInputs() { + return new NetworkInputs(); + } + + /** + * Create an instance of {@link NetworkOutputs } + * + */ + public NetworkOutputs createNetworkOutputs() { + return new NetworkOutputs(); + } + + /** + * Create an instance of {@link NetworkRequests } + * + */ + public NetworkRequests createNetworkRequests() { + return new NetworkRequests(); + } + + /** + * Create an instance of {@link NetworkTypes } + * + */ + public NetworkTypes createNetworkTypes() { + return new NetworkTypes(); + } + + /** + * Create an instance of {@link NetworkType } + * + */ + public NetworkType createNetworkType() { + return new NetworkType(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://ecomp.att.com/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 new file mode 100644 index 0000000000..c7e20aa034 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestInfo.java @@ -0,0 +1,286 @@ +/*- + * ============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========================================================= + */ + +// +// 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; +import javax.xml.bind.annotation.XmlRootElement; +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="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"/> + * <element name="end-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestId", + "action", + "requestStatus", + "statusMessage", + "progress", + "startTime", + "endTime", + "source" +}) +@XmlRootElement(name = "request-info") +public class RequestInfo { + + @XmlElement(name = "request-id") + protected String requestId; + @XmlElement(required = true) + protected ActionType action; + @XmlElement(name = "request-status") + protected RequestStatusType requestStatus; + @XmlElement(name = "status-message") + protected String statusMessage; + protected Integer progress; + @XmlElement(name = "start-time") + protected String startTime; + @XmlElement(name = "end-time") + protected String endTime; + protected String source; + + /** + * Gets the value of the requestId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRequestId() { + return requestId; + } + + /** + * Sets the value of the requestId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRequestId(String value) { + this.requestId = value; + } + + /** + * Gets the value of the action property. + * + * @return + * possible object is + * {@link ActionType } + * + */ + public ActionType getAction() { + return action; + } + + /** + * Sets the value of the action property. + * + * @param value + * allowed object is + * {@link ActionType } + * + */ + public void setAction(ActionType value) { + this.action = value; + } + + /** + * Gets the value of the requestStatus property. + * + * @return + * possible object is + * {@link RequestStatusType } + * + */ + public RequestStatusType getRequestStatus() { + return requestStatus; + } + + /** + * Sets the value of the requestStatus property. + * + * @param value + * allowed object is + * {@link RequestStatusType } + * + */ + public void setRequestStatus(RequestStatusType value) { + this.requestStatus = value; + } + + /** + * Gets the value of the statusMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStatusMessage() { + return statusMessage; + } + + /** + * Sets the value of the statusMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStatusMessage(String value) { + this.statusMessage = value; + } + + /** + * Gets the value of the progress property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getProgress() { + return progress; + } + + /** + * Sets the value of the progress property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setProgress(Integer value) { + this.progress = value; + } + + /** + * Gets the value of the startTime property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStartTime() { + return startTime; + } + + /** + * Sets the value of the startTime property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStartTime(String value) { + this.startTime = value; + } + + /** + * Gets the value of the endTime property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getEndTime() { + return endTime; + } + + /** + * Sets the value of the endTime property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setEndTime(String value) { + this.endTime = value; + } + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSource() { + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSource(String value) { + this.source = value; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestStatusType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestStatusType.java new file mode 100644 index 0000000000..50d6daae7e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/RequestStatusType.java @@ -0,0 +1,70 @@ +/*- + * ============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========================================================= + */ + +// +// 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.XmlEnum; +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> + * <simpleType name="request-status-type"> + * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> + * <enumeration value="COMPLETE"/> + * <enumeration value="FAILED"/> + * <enumeration value="IN_PROGRESS"/> + * </restriction> + * </simpleType> + * </pre> + * + */ +@XmlType(name = "request-status-type") +@XmlEnum +public enum RequestStatusType { + + COMPLETE, + FAILED, + IN_PROGRESS, + PENDING, + TIMEOUT; + + public String value() { + return name(); + } + + public static RequestStatusType fromValue(String v) { + return valueOf(v); + } + +} 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 new file mode 100644 index 0000000000..54fb4971b5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/networkbeans/package-info.java @@ -0,0 +1,30 @@ +/*- + * ============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========================================================= + */ + +// +// 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 +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://ecomp.att.com/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 new file mode 100644 index 0000000000..9225523d87 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/package-info.java @@ -0,0 +1,30 @@ +/*- + * ============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========================================================= + */ + +// +// 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.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) +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 new file mode 100644 index 0000000000..a9f7f7a880 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/CloudConfiguration.java @@ -0,0 +1,90 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import org.codehaus.jackson.map.annotate.JsonSerialize; + +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class CloudConfiguration { + + protected String aicNodeClli; + protected String tenantId; + protected String lcpCloudRegionId; + + /** + * Gets the value of the aicNodeClli property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicNodeClli() { + return aicNodeClli; + } + + /** + * Sets the value of the aicNodeClli property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicNodeClli(String value) { + this.aicNodeClli = value; + } + + /** + * Gets the value of the tenantId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTenantId() { + return tenantId; + } + + /** + * 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; + } + + public void setLcpCloudRegionId(String lcpCloudRegionId) { + this.lcpCloudRegionId = lcpCloudRegionId; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ExceptionType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ExceptionType.java new file mode 100644 index 0000000000..aa596ef372 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ExceptionType.java @@ -0,0 +1,156 @@ +/*- + * ============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========================================================= + */ + +// +// 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.05.03 at 03:56:30 PM CDT +// + + +package org.openecomp.mso.apihandlerinfra.serviceinstancebeans; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for exceptionType complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="exceptionType"> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="text" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="variables" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="50" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "exceptionType", propOrder = { + "messageId", + "text", + "variables" +}) +@XmlSeeAlso({ + ServiceException.class, + PolicyException.class +}) +public class ExceptionType { + + @XmlElement(required = true) + protected String messageId; + @XmlElement(required = true) + protected String text; + protected List<String> variables; + + /** + * Gets the value of the messageId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessageId() { + return messageId; + } + + /** + * Sets the value of the messageId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessageId(String value) { + this.messageId = value; + } + + /** + * Gets the value of the text property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getText() { + return text; + } + + /** + * Sets the value of the text property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setText(String value) { + this.text = value; + } + + /** + * Gets the value of the variables property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the variables property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getVariables().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List<String> getVariables() { + if (variables == null) { + variables = new ArrayList<String>(); + } + return this.variables; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/GetOrchestrationListResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/GetOrchestrationListResponse.java new file mode 100644 index 0000000000..6df45c7a0f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/GetOrchestrationListResponse.java @@ -0,0 +1,40 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import java.util.List; + +import org.codehaus.jackson.map.annotate.JsonSerialize; + +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class GetOrchestrationListResponse { + + protected List<RequestList> requestList; + + public List<RequestList> getRequestList() { + return requestList; + } + + public void setRequestList(List<RequestList> requestList) { + this.requestList = requestList; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/GetOrchestrationResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/GetOrchestrationResponse.java new file mode 100644 index 0000000000..87aa15717e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/GetOrchestrationResponse.java @@ -0,0 +1,39 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import org.codehaus.jackson.map.annotate.JsonSerialize; + +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class GetOrchestrationResponse { + + protected Request request; + + public Request getRequest() { + return request; + } + + public void setRequest(Request request) { + this.request = request; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/InstanceReferences.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/InstanceReferences.java new file mode 100644 index 0000000000..fd5c73f97f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/InstanceReferences.java @@ -0,0 +1,103 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +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; + protected String vnfInstanceName; + protected String vfModuleInstanceId; + protected String vfModuleInstanceName; + protected String volumeGroupInstanceId; + protected String volumeGroupInstanceName; + protected String networkInstanceId; + protected String networkInstanceName; + + + public String getServiceInstanceId() { + return serviceInstanceId; + } + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + public String getServiceInstanceName() { + return serviceInstanceName; + } + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + public String getVnfInstanceId() { + return vnfInstanceId; + } + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + public String getVnfInstanceName() { + return vnfInstanceName; + } + public void setVnfInstanceName(String vnfInstanceName) { + this.vnfInstanceName = vnfInstanceName; + } + public String getVfModuleInstanceId() { + return vfModuleInstanceId; + } + public void setVfModuleInstanceId(String vfModuleInstanceId) { + this.vfModuleInstanceId = vfModuleInstanceId; + } + public String getVfModuleInstanceName() { + return vfModuleInstanceName; + } + public void setVfModuleInstanceName(String vfModuleInstanceName) { + this.vfModuleInstanceName = vfModuleInstanceName; + } + public String getVolumeGroupInstanceId() { + return volumeGroupInstanceId; + } + public void setVolumeGroupInstanceId(String volumeGroupInstanceId) { + this.volumeGroupInstanceId = volumeGroupInstanceId; + } + public String getVolumeGroupInstanceName() { + return volumeGroupInstanceName; + } + public void setVolumeGroupInstanceName(String volumeGroupInstanceName) { + this.volumeGroupInstanceName = volumeGroupInstanceName; + } + public String getNetworkInstanceId() { + return networkInstanceId; + } + public void setNetworkInstanceId(String networkInstanceId) { + this.networkInstanceId = networkInstanceId; + } + public String getNetworkInstanceName() { + return networkInstanceName; + } + public void setNetworkInstanceName(String networkInstanceName) { + this.networkInstanceName = networkInstanceName; + } + + + +} 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 new file mode 100644 index 0000000000..e361b1db32 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ModelInfo.java @@ -0,0 +1,84 @@ +/*- + * ============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========================================================= + */ + +// +// 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 +// + + +package org.openecomp.mso.apihandlerinfra.serviceinstancebeans; + +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import org.openecomp.mso.apihandlerinfra.ModelType; + +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class ModelInfo { + + protected String modelCustomizationName; + protected String modelInvariantId; + protected ModelType modelType; + protected String modelNameVersionId; + protected String modelName; + protected String modelVersion; + + + public String getModelCustomizationName() { + return modelCustomizationName; + } + public void setModelCustomizationName(String modelCustomizationName) { + this.modelCustomizationName = modelCustomizationName; + } + public String getModelNameVersionId() { + return modelNameVersionId; + } + public void setModelNameVersionId(String modelNameVersionId) { + this.modelNameVersionId = modelNameVersionId; + } + public String getModelName() { + return modelName; + } + public void setModelName(String modelName) { + this.modelName = modelName; + } + public String getModelVersion() { + return modelVersion; + } + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + public ModelType getModelType() { + return modelType; + } + public void setModelType(ModelType modelType) { + this.modelType = modelType; + } + public String getModelInvariantId() { + return modelInvariantId; + } + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + +} 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 new file mode 100644 index 0000000000..4d336c460a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/PolicyException.java @@ -0,0 +1,59 @@ +/*- + * ============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========================================================= + */ + +// +// 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 +// + + +package org.openecomp.mso.apihandlerinfra.serviceinstancebeans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for policyException complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="policyException"> + * <complexContent> + * <extension base="{http://ecomp.att.com/mso/request/types/v1}exceptionType"> + * </extension> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "policyException") +public class PolicyException + extends ExceptionType +{ + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstance.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstance.java new file mode 100644 index 0000000000..90275f67c6 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstance.java @@ -0,0 +1,54 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import org.codehaus.jackson.map.annotate.JsonSerialize; + +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class RelatedInstance { + + protected String instanceName; + protected String instanceId; + protected ModelInfo modelInfo; + + + public String getInstanceName() { + return instanceName; + } + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + public String getInstanceId() { + return instanceId; + } + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + public ModelInfo getModelInfo() { + return modelInfo; + } + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + + +} 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 new file mode 100644 index 0000000000..1244d3b567 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RelatedInstanceList.java @@ -0,0 +1,37 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +public class RelatedInstanceList { + + protected RelatedInstance relatedInstance; + + public RelatedInstance getRelatedInstance() { + return relatedInstance; + } + + public void setRelatedInstance(RelatedInstance relatedInstance) { + this.relatedInstance = relatedInstance; + } + + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/Request.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/Request.java new file mode 100644 index 0000000000..7a88c2dd94 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/Request.java @@ -0,0 +1,85 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import java.util.Date; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +//@JsonRootName(value = "request") +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class Request { + + protected String requestId; + protected String startTime; + protected String requestScope; + protected String requestType; + //protected String requestDetails; + protected RequestDetails requestDetails; + protected InstanceReferences instanceReferences; + protected RequestStatus requestStatus; + + + public String getRequestId() { + return requestId; + } + public void setRequestId(String requestId) { + this.requestId = requestId; + } + public String getStartTime() { + return startTime; + } + public void setStartTime(String startTime) { + this.startTime = startTime; + } + public String getRequestScope() { + return requestScope; + } + public void setRequestScope(String requestScope) { + this.requestScope = requestScope; + } + public String getRequestType() { + return requestType; + } + public void setRequestType(String requestType) { + this.requestType = requestType; + } + public RequestStatus getRequestStatus() { + return requestStatus; + } + public void setRequestStatus(RequestStatus requestStatus) { + this.requestStatus = requestStatus; + } + public InstanceReferences getInstanceReferences() { + return instanceReferences; + } + public void setInstanceReferences(InstanceReferences instanceReferences) { + this.instanceReferences = instanceReferences; + } + public RequestDetails getRequestDetails() { + return requestDetails; + } + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + +} 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 new file mode 100644 index 0000000000..de6cbb7978 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestDetails.java @@ -0,0 +1,165 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import org.codehaus.jackson.map.annotate.JsonRootName; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +@JsonRootName(value = "requestDetails") +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class RequestDetails { + + protected ModelInfo modelInfo; + protected RequestInfo requestInfo; + protected RelatedInstanceList[] relatedInstanceList; + protected SubscriberInfo subscriberInfo; + protected CloudConfiguration cloudConfiguration; + protected RequestParameters requestParameters; + + /** + * Gets the value of the serviceInfo property. + * + * @return + * possible object is + * {@link ModelInfo } + * + */ + public ModelInfo getModelInfo() { + return modelInfo; + } + + /** + * Sets the value of the serviceInfo property. + * + * @param value + * allowed object is + * {@link ModelInfo } + * + */ + public void setModelInfo(ModelInfo value) { + this.modelInfo = value; + } + + /** + * Gets the value of the requestInfo property. + * + * @return + * possible object is + * {@link RequestInfo } + * + */ + public RequestInfo getRequestInfo() { + return requestInfo; + } + + /** + * Sets the value of the requestInfo property. + * + * @param value + * allowed object is + * {@link RequestInfo } + * + */ + public void setRequestInfo(RequestInfo value) { + this.requestInfo = value; + } + + /** + * Gets the value of the subscriberInfo property. + * + * @return + * possible object is + * {@link SubscriberInfo } + * + */ + public SubscriberInfo getSubscriberInfo() { + return subscriberInfo; + } + + /** + * Sets the value of the subscriberInfo property. + * + * @param value + * allowed object is + * {@link SubscriberInfo } + * + */ + public void setSubscriberInfo(SubscriberInfo value) { + this.subscriberInfo = value; + } + + /** + * Gets the value of the cloudConfiguration property. + * + * @return + * possible object is + * {@link CloudConfiguration } + * + */ + public CloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + /** + * Sets the value of the cloudConfiguration property. + * + * @param value + * allowed object is + * {@link CloudConfiguration } + * + */ + public void setCloudConfiguration(CloudConfiguration value) { + this.cloudConfiguration = value; + } + + /** + * Gets the value of the requestParameters property. + * + * @return + * possible object is + * {@link RequestParameters } + * + */ + public RequestParameters getRequestParameters() { + return requestParameters; + } + + /** + * Sets the value of the requestParameters property. + * + * @param value + * allowed object is + * {@link RequestParameters } + * + */ + public void setRequestParameters(RequestParameters value) { + this.requestParameters = value; + } + + public RelatedInstanceList[] getRelatedInstanceList() { + return relatedInstanceList; + } + + public void setRelatedInstanceList(RelatedInstanceList[] relatedInstanceList) { + this.relatedInstanceList = relatedInstanceList; + } + +} 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 new file mode 100644 index 0000000000..3a27238670 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestError.java @@ -0,0 +1,118 @@ +/*- + * ============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========================================================= + */ + +// +// 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.04.07 at 08:25:52 AM CDT +// + + +package org.openecomp.mso.apihandlerinfra.serviceinstancebeans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +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> + * <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"/> + * </choice> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "policyException", + "serviceException" +}) +@XmlRootElement(name = "requestError") +public class RequestError { + + protected PolicyException policyException; + protected ServiceException serviceException; + + /** + * Gets the value of the policyException property. + * + * @return + * possible object is + * {@link PolicyException } + * + */ + public PolicyException getPolicyException() { + return policyException; + } + + /** + * Sets the value of the policyException property. + * + * @param value + * allowed object is + * {@link PolicyException } + * + */ + public void setPolicyException(PolicyException value) { + this.policyException = value; + } + + /** + * Gets the value of the serviceException property. + * + * @return + * possible object is + * {@link ServiceException } + * + */ + public ServiceException getServiceException() { + return serviceException; + } + + /** + * Sets the value of the serviceException property. + * + * @param value + * allowed object is + * {@link ServiceException } + * + */ + public void setServiceException(ServiceException value) { + this.serviceException = value; + } + +} 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 new file mode 100644 index 0000000000..e5f3167c1f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestInfo.java @@ -0,0 +1,191 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import org.codehaus.jackson.map.annotate.JsonSerialize; + +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class RequestInfo { + + protected String billingAccountNumber; + protected String callbackUrl; + protected String correlator; + protected String orderNumber; + protected String productFamilyId; + protected Integer orderVersion; + protected String source; + protected String instanceName; + protected boolean suppressRollback; + + /** + * Gets the value of the callbackUrl property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCallbackUrl() { + return callbackUrl; + } + + /** + * Sets the value of the callbackUrl property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCallbackUrl(String value) { + this.callbackUrl = value; + } + + /** + * Gets the value of the correlator property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCorrelator() { + return correlator; + } + + /** + * Sets the value of the correlator property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCorrelator(String value) { + this.correlator = value; + } + + /** + * Gets the value of the orderNumber property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getOrderNumber() { + return orderNumber; + } + + /** + * Sets the value of the orderNumber property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setOrderNumber(String value) { + this.orderNumber = value; + } + + /** + * Gets the value of the orderVersion property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getOrderVersion() { + return orderVersion; + } + + /** + * Sets the value of the orderVersion property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setOrderVersion(Integer value) { + this.orderVersion = value; + } + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSource() { + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSource(String value) { + this.source = value; + } + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getBillingAccountNumber() { + return billingAccountNumber; + } + + public void setBillingAccountNumber(String billingAccountNumber) { + this.billingAccountNumber = billingAccountNumber; + } + + public String getProductFamilyId() { + return productFamilyId; + } + + public void setProductFamilyId(String productFamilyId) { + this.productFamilyId = productFamilyId; + } + + public boolean isSuppressRollback() { + return suppressRollback; + } + + public void setSuppressRollback(boolean suppressRollback) { + this.suppressRollback = suppressRollback; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestList.java new file mode 100644 index 0000000000..dba82a80fc --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestList.java @@ -0,0 +1,38 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import java.util.List; + + +public class RequestList { + + protected Request request; + + public Request getRequest() { + return request; + } + + public void setRequest(Request request) { + this.request = request; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java new file mode 100644 index 0000000000..1a8204055e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java @@ -0,0 +1,54 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.codehaus.jackson.map.annotate.JsonSerialize; + +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class RequestParameters { + + private String subscriptionServiceType; + private List<Map<String, String>> userParams = new ArrayList<>(); + + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + public List<Map<String, String>> getUserParams() { + return userParams; + } + + public void setUserParams(List<Map<String, String>> userParams) { + this.userParams = userParams; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestReferences.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestReferences.java new file mode 100644 index 0000000000..c2e3ecfbbd --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestReferences.java @@ -0,0 +1,43 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +public class RequestReferences { + + String requestId; + String instanceId; + + + public String getRequestId() { + return requestId; + } + public void setRequestId(String requestId) { + this.requestId = requestId; + } + public String getInstanceId() { + return instanceId; + } + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + +} 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 new file mode 100644 index 0000000000..a9bf5e873f --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestStatus.java @@ -0,0 +1,61 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import java.util.Date; + +import org.codehaus.jackson.map.annotate.JsonSerialize; + +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class RequestStatus { + + protected String requestState; + protected String statusMessage; + protected Integer percentProgress; + protected String finishTime; + + + public String getRequestState() { + return requestState; + } + public void setRequestState(String requestState) { + this.requestState = requestState; + } + public String getStatusMessage() { + return statusMessage; + } + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + public Integer getPercentProgress() { + return percentProgress; + } + public void setPercentProgress(Integer percentProgress) { + this.percentProgress = percentProgress; + } + public String getFinishTime() { + return finishTime; + } + public void setFinishTime(String finishTime) { + this.finishTime = finishTime; + } + +} 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 new file mode 100644 index 0000000000..f207e96cb5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceException.java @@ -0,0 +1,59 @@ +/*- + * ============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========================================================= + */ + +// +// 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 +// + + +package org.openecomp.mso.apihandlerinfra.serviceinstancebeans; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for serviceException complex type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * + * <pre> + * <complexType name="serviceException"> + * <complexContent> + * <extension base="{http://ecomp.att.com/mso/request/types/v1}exceptionType"> + * </extension> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "serviceException") +public class ServiceException + extends ExceptionType +{ + + +} 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 new file mode 100644 index 0000000000..30903b9649 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceInstancesRequest.java @@ -0,0 +1,83 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + + + +public class ServiceInstancesRequest { + + private RequestDetails requestDetails; + private String serviceInstanceId; + private String vnfInstanceId; + private String networkInstanceId; + private String volumeGroupInstanceId; + private String vfModuleInstanceId; + + public RequestDetails getRequestDetails() { + return requestDetails; + } + + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getNetworkInstanceId() { + return networkInstanceId; + } + + public void setNetworkInstanceId(String networkInstanceId) { + this.networkInstanceId = networkInstanceId; + } + + public String getVolumeGroupInstanceId() { + return volumeGroupInstanceId; + } + + public void setVolumeGroupInstanceId(String volumeGroupInstanceId) { + this.volumeGroupInstanceId = volumeGroupInstanceId; + } + + public String getVfModuleInstanceId() { + return vfModuleInstanceId; + } + + public void setVfModuleInstanceId(String vfModuleInstanceId) { + this.vfModuleInstanceId = vfModuleInstanceId; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceInstancesResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceInstancesResponse.java new file mode 100644 index 0000000000..b5be488367 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/ServiceInstancesResponse.java @@ -0,0 +1,36 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +public class ServiceInstancesResponse { + + RequestReferences requestReferences; + + public RequestReferences getRequestReferences() { + return requestReferences; + } + + public void setRequestReferences(RequestReferences requestReferences) { + this.requestReferences = requestReferences; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java new file mode 100644 index 0000000000..bf7a044b28 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/SubscriberInfo.java @@ -0,0 +1,79 @@ +/*- + * ============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.apihandlerinfra.serviceinstancebeans; + +import org.codehaus.jackson.map.annotate.JsonSerialize; + +@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +public class SubscriberInfo { + + protected String globalSubscriberId; + protected String subscriberName; + + /** + * Gets the value of the globalSubscriberId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + /** + * Sets the value of the globalSubscriberId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setGlobalSubscriberId(String value) { + this.globalSubscriberId = value; + } + + /** + * Gets the value of the subscriberName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSubscriberName() { + return subscriberName; + } + + /** + * Sets the value of the subscriberName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSubscriberName(String value) { + this.subscriberName = value; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ActionType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ActionType.java new file mode 100644 index 0000000000..3062dfcb96 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ActionType.java @@ -0,0 +1,80 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for action-type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * <pre> + * <simpleType name="action-type"> + * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> + * <enumeration value="CREATE"/> + * <enumeration value="SETSTATUS"/> + * <enumeration value="REPLACE"/> + * <enumeration value="UPDATE"/> + * <enumeration value="DELETE"/> + * <enumeration value="CREATE_VF_MODULE"/> + * <enumeration value="UPDATE_VF_MODULE"/> + * <enumeration value="DELETE_VF_MODULE"/> + * <enumeration value="NOT_PROVIDED"/> + * </restriction> + * </simpleType> + * </pre> + * + */ +@XmlType(name = "action-type") +@XmlEnum +public enum ActionType { + + CREATE, + SETSTATUS, + REPLACE, + UPDATE, + DELETE, + CREATE_VF_MODULE, + UPDATE_VF_MODULE, + DELETE_VF_MODULE, + NOT_PROVIDED; + + public String value() { + return name(); + } + + public static ActionType fromValue(String v) { + return valueOf(v); + } + +} 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 new file mode 100644 index 0000000000..b1c000f348 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/ObjectFactory.java @@ -0,0 +1,150 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.openecomp.mso.apihandlerinfra.vnfbeans1 package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + 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"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.mso.apihandlerinfra.vnfbeans1 + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link VnfInputs } + * + */ + public VnfInputs createVnfInputs() { + return new VnfInputs(); + } + + /** + * Create an instance of {@link RequestInfo } + * + */ + public RequestInfo createRequestInfo() { + return new RequestInfo(); + } + + /** + * Create an instance of {@link VnfOutputs } + * + */ + public VnfOutputs createVnfOutputs() { + return new VnfOutputs(); + } + + /** + * Create an instance of {@link VnfType } + * + */ + public VnfType createVnfType() { + return new VnfType(); + } + + /** + * Create an instance of {@link VnfRequest } + * + */ + public VnfRequest createVnfRequest() { + return new VnfRequest(); + } + + + /** + * Create an instance of {@link VnfTypes } + * + */ + public VnfTypes createVnfTypes() { + return new VnfTypes(); + } + + /** + * Create an instance of {@link VnfRequests } + * + */ + public VnfRequests createVnfRequests() { + return new VnfRequests(); + } + + /** + * Create an instance of {@link VfModuleModelName } + * + */ + public VfModuleModelName createVfModuleModelName() { + return new VfModuleModelName(); + } + + /** + * Create an instance of {@link VfModuleModelNames } + * + */ + public VfModuleModelNames createVfModuleModelNames() { + return new VfModuleModelNames(); + } + + + + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://ecomp.att.com/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 new file mode 100644 index 0000000000..cb8973b83e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestInfo.java @@ -0,0 +1,286 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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="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"/> + * <element name="end-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestId", + "action", + "requestStatus", + "statusMessage", + "progress", + "startTime", + "endTime", + "source" +}) +@XmlRootElement(name = "request-info") +public class RequestInfo { + + @XmlElement(name = "request-id") + protected String requestId; + @XmlElement(required = true) + protected ActionType action; + @XmlElement(name = "request-status") + protected RequestStatusType requestStatus; + @XmlElement(name = "status-message") + protected String statusMessage; + protected Integer progress; + @XmlElement(name = "start-time") + protected String startTime; + @XmlElement(name = "end-time") + protected String endTime; + protected String source; + + /** + * Gets the value of the requestId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRequestId() { + return requestId; + } + + /** + * Sets the value of the requestId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRequestId(String value) { + this.requestId = value; + } + + /** + * Gets the value of the action property. + * + * @return + * possible object is + * {@link ActionType } + * + */ + public ActionType getAction() { + return action; + } + + /** + * Sets the value of the action property. + * + * @param value + * allowed object is + * {@link ActionType } + * + */ + public void setAction(ActionType value) { + this.action = value; + } + + /** + * Gets the value of the requestStatus property. + * + * @return + * possible object is + * {@link RequestStatusType } + * + */ + public RequestStatusType getRequestStatus() { + return requestStatus; + } + + /** + * Sets the value of the requestStatus property. + * + * @param value + * allowed object is + * {@link RequestStatusType } + * + */ + public void setRequestStatus(RequestStatusType value) { + this.requestStatus = value; + } + + /** + * Gets the value of the statusMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStatusMessage() { + return statusMessage; + } + + /** + * Sets the value of the statusMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStatusMessage(String value) { + this.statusMessage = value; + } + + /** + * Gets the value of the progress property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getProgress() { + return progress; + } + + /** + * Sets the value of the progress property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setProgress(Integer value) { + this.progress = value; + } + + /** + * Gets the value of the startTime property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStartTime() { + return startTime; + } + + /** + * Sets the value of the startTime property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStartTime(String value) { + this.startTime = value; + } + + /** + * Gets the value of the endTime property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getEndTime() { + return endTime; + } + + /** + * Sets the value of the endTime property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setEndTime(String value) { + this.endTime = value; + } + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSource() { + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSource(String value) { + this.source = value; + } + +} 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 new file mode 100644 index 0000000000..4698c785a9 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/RequestStatusType.java @@ -0,0 +1,70 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import javax.xml.bind.annotation.XmlEnum; +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> + * <simpleType name="request-status-type"> + * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> + * <enumeration value="COMPLETE"/> + * <enumeration value="FAILED"/> + * <enumeration value="IN_PROGRESS"/> + * </restriction> + * </simpleType> + * </pre> + * + */ +@XmlType(name = "request-status-type") +@XmlEnum +public enum RequestStatusType { + + COMPLETE, + FAILED, + IN_PROGRESS, + PENDING, + TIMEOUT; + + public String value() { + return name(); + } + + public static RequestStatusType fromValue(String v) { + return valueOf(v); + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelName.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelName.java new file mode 100644 index 0000000000..c9876487d6 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelName.java @@ -0,0 +1,261 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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="model-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="model-version" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="model-invariant-uuid" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="is-base" type="{http://www.w3.org/2001/XMLSchema}Boolean"/> + * <element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="description" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="asdc-service-model-version" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "modelName", + "modelVersion", + "modelInvariantUuid", + "isBase", + "id", + "description", + "asdcServiceModelVersion" +}) +@XmlRootElement(name = "vf-module-model-name") +public class VfModuleModelName { + + @XmlElement(name="model-name", required = true) + protected String modelName; + @XmlElement(name="model-version", required = true) + protected String modelVersion; + @XmlElement(name="model-invariant-uuid", required = true) + protected String modelInvariantUuid; + @XmlElement(name="is-base", required = true) + protected Boolean isBase; + @XmlElement(name="id", required = true) + protected String id; + @XmlElement(name="description", required = true) + protected String description; + @XmlElement(name="asdc-service-model-version", required = true) + protected String asdcServiceModelVersion; + + /** + * Gets the value of the modelName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getModelName() { + return modelName; + } + + /** + * Sets the value of the modelName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setModelName(String value) { + this.modelName = value; + } + + /** + * Gets the value of the modelVersion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getModelVersion() { + return modelVersion; + } + + /** + * Sets the value of the modelVersion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setModelVersion(String value) { + this.modelVersion = value; + } + + /** + * Gets the value of the modelInvariantUuid property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getModelInvariantUuid() { + return modelInvariantUuid; + } + + /** + * Sets the value of the modelInvariantUuid property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setModelInvariantUuid(String value) { + this.modelInvariantUuid = value; + } + + /** + * Gets the value of the isBase property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean getIsBase() { + return isBase; + } + + /** + * Sets the value of the isBase property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setIsBase(Boolean value) { + this.isBase = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the description property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDescription() { + return description; + } + + /** + * Sets the value of the description property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDescription(String value) { + this.description = value; + } + + /** + * Gets the value of the asdcServiceModelVersion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAsdcServiceModelVersion() { + return asdcServiceModelVersion; + } + + /** + * Sets the value of the asdcServiceModelVersion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAsdcServiceModelVersion(String value) { + this.asdcServiceModelVersion = value; + } + +} 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 new file mode 100644 index 0000000000..790a5e80ef --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VfModuleModelNames.java @@ -0,0 +1,99 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +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 ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vf-module-model-name" maxOccurs="unbounded" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vfModuleModelName" +}) +@XmlRootElement(name = "vf-module-model-names") +public class VfModuleModelNames { + + @XmlElement(name = "vf-module-model-name") + protected List<VfModuleModelName> vfModuleModelName; + + /** + * Gets the value of the vfModuleModelName property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the vnfType property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getVfModuleModelName().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link VfModuleModelName } + * + * + */ + public List<VfModuleModelName> getVfModuleModelName() { + if (vfModuleModelName == null) { + vfModuleModelName = new ArrayList<VfModuleModelName>(); + } + return this.vfModuleModelName; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfInputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfInputs.java new file mode 100644 index 0000000000..bfc0d84e43 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfInputs.java @@ -0,0 +1,689 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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="vnf-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vf-module-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vnf-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vf-module-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vnf-type" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vf-module-model-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="asdc-service-model-version" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="service-instance-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="backout-on-failure" type="{http://www.w3.org/2001/XMLSchema}Boolean"/> + * <choice> + * <element name="service-type" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="service-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </choice> + * <choice> + * <element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="aic-cloud-region" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </choice> + * <element name="tenant-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="prov-status" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="volume-group-name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="volume-group-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="persona-model-id" type="{http://www.w3.org/2001/XMLSchema}string"/ minOccurs="0"> + * <element name="persona-model-version" type="{http://www.w3.org/2001/XMLSchema}string"/ minOccurs="0"> + * <element name="is-base-vf-module" type="{http://www.w3.org/2001/XMLSchema}Boolean"/ minOccurs="0"> + * <element name="vnf-persona-model-id" type="{http://www.w3.org/2001/XMLSchema}string"/ minOccurs="0"> + * <element name="vnf-persona-model-version" type="{http://www.w3.org/2001/XMLSchema}string"/ minOccurs="0"> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfId", + "vfModuleId", + "vnfName", + "vfModuleName", + "vnfType", + "vfModuleModelName", + "asdcServiceModelVersion", + "serviceInstanceId", + "backoutOnFailure", + "serviceType", + "serviceId", + "aicNodeClli", + "aicCloudRegion", + "tenantId", + "provStatus", + "volumeGroupName", + "volumeGroupId", + // BEGIN - elements valid only on BPMN interface + "personaModelId", + "personaModelVersion", + "isBaseVfModule", + "vnfPersonaModelId", + "vnfPersonaModelVersion" + // END - elements valid only on BPMN interface +}) +@XmlRootElement(name = "vnf-inputs") +public class VnfInputs { + + @XmlElement(name = "vnf-id") + protected String vnfId; + @XmlElement(name = "vf-module-id") + protected String vfModuleId; + @XmlElement(name = "vnf-name") + protected String vnfName; + @XmlElement(name = "vf-module-name") + protected String vfModuleName; + @XmlElement(name = "vnf-type") + protected String vnfType; + @XmlElement(name = "vf-module-model-name") + protected String vfModuleModelName; + @XmlElement(name = "asdc-service-model-version") + protected String asdcServiceModelVersion; + @XmlElement(name = "service-instance-id") + protected String serviceInstanceId; + @XmlElement(name = "backout-on-failure") + protected Boolean backoutOnFailure; + @XmlElement(name = "service-type") + protected String serviceType; + @XmlElement(name = "service-id") + protected String serviceId; + @XmlElement(name = "aic-node-clli") + protected String aicNodeClli; + @XmlElement(name = "aic-cloud-region") + protected String aicCloudRegion; + @XmlElement(name = "tenant-id", required = true) + protected String tenantId; + @XmlElement(name = "prov-status") + protected String provStatus; + @XmlElement(name = "volume-group-name") + protected String volumeGroupName; + @XmlElement(name = "volume-group-id") + protected String volumeGroupId; + @XmlElement(name = "persona-model-id") + protected String personaModelId; + @XmlElement(name = "persona-model-version") + protected String personaModelVersion; + @XmlElement(name = "is-base-vf-module") + protected Boolean isBaseVfModule; + @XmlElement(name = "vnf-persona-model-id") + protected String vnfPersonaModelId; + @XmlElement(name = "vnf-persona-model-version") + protected String vnfPersonaModelVersion; + + /** + * Gets the value of the vnfId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfId() { + return vnfId; + } + + /** + * Sets the value of the vnfId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfId(String value) { + this.vnfId = value; + } + + /** + * Gets the value of the vnfName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfName() { + return vnfName; + } + + /** + * Sets the value of the vnfName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfName(String value) { + this.vnfName = value; + } + + /** + * Gets the value of the vnfType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfType() { + return vnfType; + } + + /** + * Sets the value of the vnfType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfType(String value) { + this.vnfType = value; + } + + /** + * Gets the value of the serviceInstanceId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceInstanceId() { + return serviceInstanceId; + } + + /** + * Sets the value of the serviceInstanceId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceInstanceId(String value) { + this.serviceInstanceId = value; + } + + /** + * Gets the value of the serviceType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceType() { + return serviceType; + } + + /** + * Sets the value of the serviceType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceType(String value) { + this.serviceType = value; + } + + /** + * Gets the value of the serviceId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceId() { + return serviceId; + } + + /** + * Sets the value of the serviceId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceId (String value) { + this.serviceId = value; + } + + + /** + * Gets the value of the aicNodeClli property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicNodeClli() { + return aicNodeClli; + } + + /** + * Sets the value of the aicNodeClli property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicNodeClli(String value) { + this.aicNodeClli = value; + } + + /** + * Gets the value of the aicCloudRegion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicCloudRegion() { + return aicCloudRegion; + } + + /** + * Sets the value of the aicCloudRegion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicCloudRegion(String value) { + this.aicCloudRegion = value; + } + + /** + * Gets the value of the tenantId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTenantId() { + return tenantId; + } + + /** + * Sets the value of the tenantId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTenantId(String value) { + this.tenantId = value; + } + + /** + * Gets the value of the provStatus property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProvStatus() { + return provStatus; + } + + /** + * Sets the value of the provStatus property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProvStatus(String value) { + this.provStatus = value; + } + + /** + * Gets the value of the volumeGroupName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVolumeGroupName() { + return volumeGroupName; + } + + /** + * Sets the value of the volumeGroupName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVolumeGroupName(String value) { + this.volumeGroupName = value; + } + + /** + * Gets the value of the volumeGroupId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVolumeGroupId() { + return volumeGroupId; + } + + /** + * Sets the value of the volumeGroupId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVolumeGroupId(String value) { + this.volumeGroupId = value; + } + + /** + * Gets the value of the vfModuleId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVfModuleId() { + return vfModuleId; + } + + /** + * Sets the value of the vfModuleId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVfModuleId(String value) { + this.vfModuleId = value; + } + + /** + * Gets the value of the vfModuleName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVfModuleName() { + return vfModuleName; + } + + /** + * Sets the value of the vfModuleName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVfModuleName(String value) { + this.vfModuleName = value; + } + + /** + * Gets the value of the vfModuleModelName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVfModuleModelName() { + return vfModuleModelName; + } + + /** + * Sets the value of the vfModuleModelName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVfModuleModelName(String value) { + this.vfModuleModelName = value; + } + + /** + * Gets the value of the asdcServiceModelVersion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAsdcServiceModelVersion() { + return asdcServiceModelVersion; + } + + /** + * Sets the value of the asdcServiceModelVersion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAsdcServiceModelVersion(String value) { + this.asdcServiceModelVersion = value; + } + + /** + * Gets the value of the backoutOnFailure property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean getBackoutOnFailure() { + return backoutOnFailure; + } + + /** + * Sets the value of the backoutOnFailure property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setBackoutOnFailure(Boolean value) { + this.backoutOnFailure = value; + } + + /** + * Gets the value of the personaModelId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPersonaModelId() { + return personaModelId; + } + + /** + * Sets the value of the personaModelId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPersonaModelId(String value) { + this.personaModelId = value; + } + + /** + * Gets the value of the personaModelVersion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPersonaModelVersion() { + return personaModelVersion; + } + + /** + * Sets the value of the personaModelVersion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPersonaModelVersion(String value) { + this.personaModelVersion = value; + } + + + /** + * Gets the value of the isBaseVfModule property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean getIsBaseVfModule() { + return isBaseVfModule; + } + + /** + * Sets the value of the isBaseVfModule property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setIsBaseVfModule(Boolean value) { + this.isBaseVfModule = value; + } + + /** + * Gets the value of the vnfPersonaModelId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfPersonaModelId() { + return vnfPersonaModelId; + } + + /** + * Sets the value of the vnfPersonaModelId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfPersonaModelId(String value) { + this.vnfPersonaModelId = value; + } + + /** + * Gets the value of the vnfPersonaModelVersion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfPersonaModelVersion() { + return vnfPersonaModelVersion; + } + + /** + * Sets the value of the vnfPersonaModelVersion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfPersonaModelVersion(String value) { + this.vnfPersonaModelVersion = value; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfOutputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfOutputs.java new file mode 100644 index 0000000000..acb2a0a290 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfOutputs.java @@ -0,0 +1,291 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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="vnf-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vf-module-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vnf-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vf-module-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="tenant-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="volume-group-name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="volume-group-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfId", + "vfModuleId", + "vnfName", + "vfModuleName", + "aicNodeClli", + "tenantId", + "volumeGroupName", + "volumeGroupId" +}) +@XmlRootElement(name = "vnf-outputs") +public class VnfOutputs { + + @XmlElement(name = "vnf-id", required = true) + protected String vnfId; + @XmlElement(name = "vf-module-id") + protected String vfModuleId; + @XmlElement(name = "vnf-name", required = true) + protected String vnfName; + @XmlElement(name = "vf-module-name", required = true) + protected String vfModuleName; + @XmlElement(name = "aic-node-clli", required = true) + protected String aicNodeClli; + @XmlElement(name = "tenant-id", required = true) + protected String tenantId; + @XmlElement(name = "volume-group-name") + protected String volumeGroupName; + @XmlElement(name = "volume-group-id") + protected String volumeGroupId; + + /** + * Gets the value of the vnfId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfId() { + return vnfId; + } + + /** + * Sets the value of the vnfId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfId(String value) { + this.vnfId = value; + } + + /** + * Gets the value of the vfModuleId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVfModuleId() { + return vfModuleId; + } + + /** + * Sets the value of the vfModuleId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVfModuleId(String value) { + this.vfModuleId = value; + } + + + + /** + * Gets the value of the vnfName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfName() { + return vnfName; + } + + /** + * Sets the value of the vnfName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfName(String value) { + this.vnfName = value; + } + + /** + * Gets the value of the vfModuleName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVfModuleName() { + return vfModuleName; + } + + /** + * Sets the value of the vfModuleName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVfModuleName(String value) { + this.vfModuleName = value; + } + + + /** + * Gets the value of the aicNodeClli property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicNodeClli() { + return aicNodeClli; + } + + /** + * Sets the value of the aicNodeClli property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicNodeClli(String value) { + this.aicNodeClli = value; + } + + /** + * Gets the value of the tenantId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTenantId() { + return tenantId; + } + + /** + * Sets the value of the tenantId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTenantId(String value) { + this.tenantId = value; + } + + /** + * Gets the value of the volumeGroupName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVolumeGroupName() { + return volumeGroupName; + } + + /** + * Sets the value of the volumeGroupName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVolumeGroupName(String value) { + this.volumeGroupName = value; + } + + /** + * Gets the value of the volumeGroupId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVolumeGroupId() { + return volumeGroupId; + } + + /** + * Sets the value of the volumeGroupId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVolumeGroupId(String value) { + this.volumeGroupId = value; + } + +} 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 new file mode 100644 index 0000000000..bd210a5aca --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequest.java @@ -0,0 +1,179 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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 ref="{http://ecomp.att.com/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"/> + * </sequence> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestInfo", + "vnfInputs", + "vnfParams", + "vnfOutputs" +}) +@XmlRootElement(name = "vnf-request") +public class VnfRequest { + + @XmlElement(name = "request-info", required = true) + protected RequestInfo requestInfo; + @XmlElement(name = "vnf-inputs") + protected VnfInputs vnfInputs; + @XmlElement(name = "vnf-params") + protected Object vnfParams; + @XmlElement(name = "vnf-outputs") + protected VnfOutputs vnfOutputs; + + + /** + * Gets the value of the requestInfo property. + * + * @return + * possible object is + * {@link RequestInfo } + * + */ + public RequestInfo getRequestInfo() { + return requestInfo; + } + + /** + * Sets the value of the requestInfo property. + * + * @param value + * allowed object is + * {@link RequestInfo } + * + */ + public void setRequestInfo(RequestInfo value) { + this.requestInfo = value; + } + + /** + * Gets the value of the vnfInputs property. + * + * @return + * possible object is + * {@link VnfInputs } + * + */ + public VnfInputs getVnfInputs() { + return vnfInputs; + } + + /** + * Sets the value of the vnfInputs property. + * + * @param value + * allowed object is + * {@link VnfInputs } + * + */ + public void setVnfInputs(VnfInputs value) { + this.vnfInputs = value; + } + + /** + * Gets the value of the vnfParams property. + * + * @return + * possible object is + * {@link Object } + * + */ + public Object getVnfParams() { + return vnfParams; + } + + /** + * Sets the value of the vnfParams property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setVnfParams(Object value) { + this.vnfParams = value; + } + + /** + * Gets the value of the vnfOutputs property. + * + * @return + * possible object is + * {@link VnfOutputs } + * + */ + public VnfOutputs getVnfOutputs() { + return vnfOutputs; + } + + /** + * Sets the value of the vnfOutputs property. + * + * @param value + * allowed object is + * {@link VnfOutputs } + * + */ + public void setVnfOutputs(VnfOutputs value) { + this.vnfOutputs = value; + } + + } 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 new file mode 100644 index 0000000000..65aa9c1d99 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfRequests.java @@ -0,0 +1,99 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +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 ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vnf-request" maxOccurs="unbounded" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfRequest" +}) +@XmlRootElement(name = "vnf-requests") +public class VnfRequests { + + @XmlElement(name = "vnf-request") + protected List<VnfRequest> vnfRequest; + + /** + * Gets the value of the vnfRequest property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the vnfRequest property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getVnfRequest().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link VnfRequest } + * + * + */ + public List<VnfRequest> getVnfRequest() { + if (vnfRequest == null) { + vnfRequest = new ArrayList<VnfRequest>(); + } + return this.vnfRequest; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfType.java new file mode 100644 index 0000000000..9ddd4ca6db --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfType.java @@ -0,0 +1,148 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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="type" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="description" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "type", + "id", + "description" +}) +@XmlRootElement(name = "vnf-type") +public class VnfType { + + @XmlElement(required = true) + protected String type; + @XmlElement(required = true) + protected String id; + @XmlElement(required = true) + protected String description; + + /** + * Gets the value of the type property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Gets the value of the id property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getId() { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setId(String value) { + this.id = value; + } + + /** + * Gets the value of the description property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDescription() { + return description; + } + + /** + * Sets the value of the description property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDescription(String value) { + this.description = value; + } + +} 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 new file mode 100644 index 0000000000..473695c179 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/VnfTypes.java @@ -0,0 +1,99 @@ +/*- + * ============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========================================================= + */ + +// +// 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.vnfbeans; + + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +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 ref="{http://ecomp.att.com/mso/infra/vnf-request/v1}vnf-type" maxOccurs="unbounded" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfType" +}) +@XmlRootElement(name = "vnf-types") +public class VnfTypes { + + @XmlElement(name = "vnf-type") + protected List<VnfType> vnfType; + + /** + * Gets the value of the vnfType property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the vnfType property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getVnfType().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link VnfType } + * + * + */ + public List<VnfType> getVnfType() { + if (vnfType == null) { + vnfType = new ArrayList<VnfType>(); + } + return this.vnfType; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java new file mode 100644 index 0000000000..700d7a9064 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/vnfbeans/package-info.java @@ -0,0 +1,30 @@ +/*- + * ============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========================================================= + */ + +// +// 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 +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://ecomp.att.com/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/ActionType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ActionType.java new file mode 100644 index 0000000000..9e2c3ac525 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ActionType.java @@ -0,0 +1,76 @@ +/*- + * ============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========================================================= + */ + +// +// 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.volumebeans; + + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + + +/** + * <p>Java class for action-type. + * + * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * <pre> + * <simpleType name="action-type"> + * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> + * <enumeration value="CREATE"/> + * <enumeration value="UPDATE"/> + * <enumeration value="DELETE"/> + * <enumeration value="CREATE_VF_MODULE_VOL"/> + * <enumeration value="UPDATE_VF_MODULE_VOL"/> + * <enumeration value="DELETE_VF_MODULE_VOL"/> + * <enumeration value="NOT_PROVIDED"/> + * </restriction> + * </simpleType> + * </pre> + * + */ +@XmlType(name = "action-type") +@XmlEnum +public enum ActionType { + + CREATE, + UPDATE, + DELETE, + CREATE_VF_MODULE_VOL, + UPDATE_VF_MODULE_VOL, + DELETE_VF_MODULE_VOL, + NOT_PROVIDED; + + public String value() { + return name(); + } + + public static ActionType fromValue(String v) { + return valueOf(v); + } + +} 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 new file mode 100644 index 0000000000..24b620eb6b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/ObjectFactory.java @@ -0,0 +1,115 @@ +/*- + * ============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========================================================= + */ + +// +// 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.volumebeans; + + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.openecomp.mso.apihandlerinfra.vnfbeans1 package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _VolumeParams_QNAME = new QName("http://ecomp.att.com/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 + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link RequestInfo } + * + */ + public RequestInfo createRequestInfo() { + return new RequestInfo(); + } + + /** + * Create an instance of {@link VolumeRequest } + * + */ + public VolumeRequest createVolumeRequest() { + return new VolumeRequest(); + } + + /** + * Create an instance of {@link VolumeInputs } + * + */ + public VolumeInputs createVolumeInputs() { + return new VolumeInputs(); + } + + /** + * Create an instance of {@link VolumeOutputs } + * + */ + public VolumeOutputs createVolumeOutputs() { + return new VolumeOutputs(); + } + + /** + * Create an instance of {@link VolumeRequests } + * + */ + public VolumeRequests createVolumeRequests() { + return new VolumeRequests(); + } + + + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://ecomp.att.com/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 new file mode 100644 index 0000000000..40e809c9fa --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestInfo.java @@ -0,0 +1,286 @@ +/*- + * ============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========================================================= + */ + +// +// 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.volumebeans; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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="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"/> + * <element name="end-time" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestId", + "action", + "requestStatus", + "statusMessage", + "progress", + "startTime", + "endTime", + "source" +}) +@XmlRootElement(name = "request-info") +public class RequestInfo { + + @XmlElement(name = "request-id") + protected String requestId; + @XmlElement(required = true) + protected ActionType action; + @XmlElement(name = "request-status") + protected RequestStatusType requestStatus; + @XmlElement(name = "status-message") + protected String statusMessage; + protected Integer progress; + @XmlElement(name = "start-time") + protected String startTime; + @XmlElement(name = "end-time") + protected String endTime; + protected String source; + + /** + * Gets the value of the requestId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRequestId() { + return requestId; + } + + /** + * Sets the value of the requestId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRequestId(String value) { + this.requestId = value; + } + + /** + * Gets the value of the action property. + * + * @return + * possible object is + * {@link ActionType } + * + */ + public ActionType getAction() { + return action; + } + + /** + * Sets the value of the action property. + * + * @param value + * allowed object is + * {@link ActionType } + * + */ + public void setAction(ActionType value) { + this.action = value; + } + + /** + * Gets the value of the requestStatus property. + * + * @return + * possible object is + * {@link RequestStatusType } + * + */ + public RequestStatusType getRequestStatus() { + return requestStatus; + } + + /** + * Sets the value of the requestStatus property. + * + * @param value + * allowed object is + * {@link RequestStatusType } + * + */ + public void setRequestStatus(RequestStatusType value) { + this.requestStatus = value; + } + + /** + * Gets the value of the statusMessage property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStatusMessage() { + return statusMessage; + } + + /** + * Sets the value of the statusMessage property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStatusMessage(String value) { + this.statusMessage = value; + } + + /** + * Gets the value of the progress property. + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getProgress() { + return progress; + } + + /** + * Sets the value of the progress property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setProgress(Integer value) { + this.progress = value; + } + + /** + * Gets the value of the startTime property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStartTime() { + return startTime; + } + + /** + * Sets the value of the startTime property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStartTime(String value) { + this.startTime = value; + } + + /** + * Gets the value of the endTime property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getEndTime() { + return endTime; + } + + /** + * Sets the value of the endTime property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setEndTime(String value) { + this.endTime = value; + } + + /** + * Gets the value of the source property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSource() { + return source; + } + + /** + * Sets the value of the source property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSource(String value) { + this.source = value; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestStatusType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestStatusType.java new file mode 100644 index 0000000000..dfa36894a7 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/RequestStatusType.java @@ -0,0 +1,70 @@ +/*- + * ============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========================================================= + */ + +// +// 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.volumebeans; + + +import javax.xml.bind.annotation.XmlEnum; +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> + * <simpleType name="request-status-type"> + * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> + * <enumeration value="COMPLETE"/> + * <enumeration value="FAILED"/> + * <enumeration value="IN_PROGRESS"/> + * </restriction> + * </simpleType> + * </pre> + * + */ +@XmlType(name = "request-status-type") +@XmlEnum +public enum RequestStatusType { + + COMPLETE, + FAILED, + IN_PROGRESS, + PENDING, + TIMEOUT; + + public String value() { + return name(); + } + + public static RequestStatusType fromValue(String v) { + return valueOf(v); + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputs.java new file mode 100644 index 0000000000..55acf3270e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeInputs.java @@ -0,0 +1,435 @@ +/*- + * ============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========================================================= + */ + +// +// 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.volumebeans; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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="vnf-type" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vf-module-model-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="asdc-service-model-version" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vnf-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="vnf-type" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="service-instance-id" type="{http://www.w3.org/2001/XMLSchema}Boolean"/> + * <choice> + * <element name="service-type" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="service-id" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </choice> + * <choice> + * <element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="aic-cloud-region" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * </choice> + * <element name="tenant-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="volume-group-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="volume-group-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfType", + "vnfId", + "vfModuleModelName", + "asdcServiceModelVersion", + "serviceInstanceId", + "backoutOnFailure", + "serviceType", + "serviceId", + "aicNodeClli", + "aicCloudRegion", + "tenantId", + "volumeGroupName", + "volumeGroupId" +}) +@XmlRootElement(name = "volume-inputs") +public class VolumeInputs { + @XmlElement(name = "vnf-type", required = true) + protected String vnfType; + @XmlElement(name = "vnf-id") + protected String vnfId; + @XmlElement(name = "vf-module-model-name") + protected String vfModuleModelName; + @XmlElement(name = "asdc-service-model-version") + protected String asdcServiceModelVersion; + @XmlElement(name = "service-instance-id", required = true) + protected String serviceInstanceId; + @XmlElement(name = "backout-on-failure") + protected Boolean backoutOnFailure; + @XmlElement(name = "service-type") + protected String serviceType; + @XmlElement(name = "service-id") + protected String serviceId; + @XmlElement(name = "aic-node-clli", required = true) + protected String aicNodeClli; + @XmlElement(name = "aic-cloud-region") + protected String aicCloudRegion; + @XmlElement(name = "tenant-id", required = true) + protected String tenantId; + @XmlElement(name = "volume-group-name") + protected String volumeGroupName; + @XmlElement(name = "volume-group-id") + protected String volumeGroupId; + + /** + * Gets the value of the volumeGroupId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVolumeGroupId() { + return volumeGroupId; + } + + /** + * Sets the value of the volumeGroupId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVolumeGroupId(String value) { + this.volumeGroupId = value; + } + + /** + * Gets the value of the volumeGroupName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVolumeGroupName() { + return volumeGroupName; + } + + /** + * Sets the value of the volumeGroupName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVolumeGroupName(String value) { + this.volumeGroupName = value; + } + + /** + * Gets the value of the vnfType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfType() { + return vnfType; + } + + /** + * Sets the value of the vnfType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfType(String value) { + this.vnfType = value; + } + + /** + * Gets the value of the vnfId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfId() { + return vnfId; + } + + /** + * Sets the value of the vnfId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfId(String value) { + this.vnfId = value; + } + + /** + * Gets the value of the serviceInstanceId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceInstanceId() { + return serviceInstanceId; + } + + /** + * Sets the value of the serviceInstanceId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceInstanceId(String value) { + this.serviceInstanceId = value; + } + + /** + * Gets the value of the serviceType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceType() { + return serviceType; + } + + /** + * Sets the value of the serviceType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceType(String value) { + this.serviceType = value; + } + + /** + * Gets the value of the serviceId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceId() { + return serviceId; + } + + /** + * Sets the value of the serviceId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceId (String value) { + this.serviceId = value; + } + + + /** + * Gets the value of the aicNodeClli property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicNodeClli() { + return aicNodeClli; + } + + /** + * Sets the value of the aicNodeClli property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicNodeClli(String value) { + this.aicNodeClli = value; + } + + /** + * Gets the value of the aicCloudRegion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicCloudRegion() { + return aicCloudRegion; + } + + /** + * Sets the value of the aicCloudRegion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicCloudRegion(String value) { + this.aicCloudRegion = value; + } + + /** + * Gets the value of the tenantId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTenantId() { + return tenantId; + } + + /** + * Sets the value of the tenantId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTenantId(String value) { + this.tenantId = value; + } + + /** + * Gets the value of the vfModuleModelName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVfModuleModelName() { + return vfModuleModelName; + } + + /** + * Sets the value of the vfModuleModelName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVfModuleModelName(String value) { + this.vfModuleModelName = value; + } + + /** + * Gets the value of the asdcServiceModelVersion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAsdcServiceModelVersion() { + return asdcServiceModelVersion; + } + + /** + * Sets the value of the asdcServiceModelVersion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAsdcServiceModelVersion(String value) { + this.asdcServiceModelVersion = value; + } + + /** + * Gets the value of the backoutOnFailure property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean getBackoutOnFailure() { + return backoutOnFailure; + } + + /** + * Sets the value of the backoutOnFailure property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setBackoutOnFailure(Boolean value) { + this.backoutOnFailure = value; + } + + + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputs.java new file mode 100644 index 0000000000..be0d844d0a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeOutputs.java @@ -0,0 +1,233 @@ +/*- + * ============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========================================================= + */ + +// +// 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.volumebeans; + + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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="vnf-type" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="service-type" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="aic-node-clli" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="tenant-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="volume-group-name" type="{http://www.w3.org/2001/XMLSchema}string"/> + * <element name="volume-group-id" type="{http://www.w3.org/2001/XMLSchema}string"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfType", + "serviceType", + "aicNodeClli", + "tenantId", + "volumeGroupName", + "volumeGroupId" +}) +@XmlRootElement(name = "volume-outputs") +public class VolumeOutputs { + @XmlElement(name = "vnf-type", required = true) + protected String vnfType; + @XmlElement(name = "service-type") + protected String serviceType; + @XmlElement(name = "aic-node-clli", required = true) + protected String aicNodeClli; + @XmlElement(name = "tenant-id", required = true) + protected String tenantId; + @XmlElement(name = "volume-group-name") + protected String volumeGroupName; + @XmlElement(name = "volume-group-id") + protected String volumeGroupId; + + /** + * Gets the value of the volumeId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVolumeGroupId() { + return volumeGroupId; + } + + /** + * Sets the value of the volumeGroupId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVolumeGroupId(String value) { + this.volumeGroupId = value; + } + + /** + * Gets the value of the volumeGroupName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVolumeGroupName() { + return volumeGroupName; + } + + /** + * Sets the value of the volumeGroupName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVolumeGroupName(String value) { + this.volumeGroupName = value; + } + + /** + * Gets the value of the vnfType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfType() { + return vnfType; + } + + /** + * Sets the value of the vnfType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfType(String value) { + this.vnfType = value; + } + + /** + * Gets the value of the serviceType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getServiceType() { + return serviceType; + } + + /** + * Sets the value of the serviceType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setServiceType(String value) { + this.serviceType = value; + } + + /** + * Gets the value of the aicNodeClli property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAicNodeClli() { + return aicNodeClli; + } + + /** + * Sets the value of the aicNodeClli property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAicNodeClli(String value) { + this.aicNodeClli = value; + } + + /** + * Gets the value of the tenantId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTenantId() { + return tenantId; + } + + /** + * Sets the value of the tenantId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTenantId(String value) { + this.tenantId = 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 new file mode 100644 index 0000000000..9ec3d7e4d5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequest.java @@ -0,0 +1,179 @@ +/*- + * ============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========================================================= + */ + +// +// 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.volumebeans; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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 ref="{http://ecomp.att.com/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"/> + * </sequence> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "requestInfo", + "volumeInputs", + "volumeParams", + "volumeOutputs" +}) +@XmlRootElement(name = "volume-request") +public class VolumeRequest { + + @XmlElement(name = "request-info", required = true) + protected RequestInfo requestInfo; + @XmlElement(name = "volume-inputs") + protected VolumeInputs volumeInputs; + @XmlElement(name = "volume-params") + protected Object volumeParams; + @XmlElement(name = "volume-outputs") + protected VolumeOutputs volumeOutputs; + + /** + * Gets the value of the requestInfo property. + * + * @return + * possible object is + * {@link RequestInfo } + * + */ + public RequestInfo getRequestInfo() { + return requestInfo; + } + + /** + * Sets the value of the requestInfo property. + * + * @param value + * allowed object is + * {@link RequestInfo } + * + */ + public void setRequestInfo(RequestInfo value) { + this.requestInfo = value; + } + + + /** + * Gets the value of the volumeInputs property. + * + * @return + * possible object is + * {@link VolumeInputs } + * + */ + public VolumeInputs getVolumeInputs() { + return volumeInputs; + } + + /** + * Sets the value of the volumeInputs property. + * + * @param value + * allowed object is + * {@link VolumeInputs } + * + */ + public void setVolumeInputs(VolumeInputs value) { + this.volumeInputs = value; + } + + /** + * Gets the value of the volumeParams property. + * + * @return + * possible object is + * {@link Object } + * + */ + public Object getVolumeParams() { + return volumeParams; + } + + /** + * Sets the value of the volumeParams property. + * + * @param value + * allowed object is + * {@link Object } + * + */ + public void setVolumeParams(Object value) { + this.volumeParams = value; + } + + /** + * Gets the value of the volumeOutputs property. + * + * @return + * possible object is + * {@link VolumeOutputs } + * + */ + public VolumeOutputs getVolumeOutputs() { + return volumeOutputs; + } + + /** + * Sets the value of the volumeOutputs property. + * + * @param value + * allowed object is + * {@link VolumeOutputs } + * + */ + public void setVolumeOutputs(VolumeOutputs value) { + this.volumeOutputs = value; + } + +} 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 new file mode 100644 index 0000000000..04fc16e822 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/VolumeRequests.java @@ -0,0 +1,99 @@ +/*- + * ============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========================================================= + */ + +// +// 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.volumebeans; + + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + * <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 ref="{http://ecomp.att.com/mso/infra/volume-request/v1}volume-request" maxOccurs="unbounded" minOccurs="0"/> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "volumeRequest" +}) +@XmlRootElement(name = "volume-requests") +public class VolumeRequests { + + @XmlElement(name = "volume-request") + protected List<VolumeRequest> volumeRequest; + + /** + * Gets the value of the volumeRequest property. + * + * <p> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the vnfRequest property. + * + * <p> + * For example, to add a new item, do as follows: + * <pre> + * getVolumeRequest().add(newItem); + * </pre> + * + * + * <p> + * Objects of the following type(s) are allowed in the list + * {@link VolumeRequest } + * + * + */ + public List<VolumeRequest> getVolumeRequest() { + if (volumeRequest == null) { + volumeRequest = new ArrayList<VolumeRequest>(); + } + return this.volumeRequest; + } + +} 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 new file mode 100644 index 0000000000..3678024b75 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/volumebeans/package-info.java @@ -0,0 +1,30 @@ +/*- + * ============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========================================================= + */ + +// +// 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 +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://ecomp.att.com/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/java/resources/application.properties b/mso-api-handlers/mso-api-handler-infra/src/main/java/resources/application.properties new file mode 100644 index 0000000000..96c9e6fa18 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/resources/application.properties @@ -0,0 +1,27 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# -- welcome -- +welcomeTitle=JSF Blank Application + +welcomeHeading=Welcome! + +welcomeMessage=This is a JSF blank application. \ + You can find the application.properties file with this message in the src/resources folder. 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 new file mode 100644 index 0000000000..aacab0bcce --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-feature-request.xml @@ -0,0 +1,43 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<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"> + <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:order-number>5051560</msoservtypes:order-number> + <msoservtypes:order-version>1</msoservtypes:order-version> + </msoservtypes:request-information> + <msoservtypes:service-information> + <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> + <msoservtypes:service-instance-id>HI/VLXM/003717//SW_INTERNET</msoservtypes:service-instance-id> + <msoservtypes:subscriber-name>ST E2E Test50565_13000050565</msoservtypes:subscriber-name> + </msoservtypes:service-information> + <msoservtypes:feature-information> + <msoservtypes:feature-type>FIREWALL-LITE</msoservtypes:feature-type> + <msoservtypes:feature-instance-id>HI/VLXM/003717//SW_INTERNET</msoservtypes:feature-instance-id> + <msoservtypes:feature-yang-model>ST E2E Test50565_13000050565</msoservtypes:feature-yang-model> + </msoservtypes:feature-information> + </feature-request> 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 new file mode 100644 index 0000000000..1e495838b7 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/adv-service-request.xml @@ -0,0 +1,132 @@ +<!-- + ============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========================================================= + ECOMP and OpenECOMP are trademarks + and service marks of AT&T Intellectual Property. + + --> + +<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: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 +ification.jws</tns1:notification-url> + <tns1:order-number>051815-1005</tns1:order-number> + <tns1:order-version>2</tns1:order-version> + </tns1:request-information> + <tns1:service-information> + <tns1:service-type>SDN-ETHERNET-INTERNET</tns1:service-type> + <tns1:service-instance-id>TL/VLXM/003717//SW_INTERNET</tns1:service-instance-id> + <tns1:subscriber-name>Gamma Gamma E2E Test_051815_50</tns1:subscriber-name> + </tns1:service-information> + <tns:service-parameters> + <msolayer3:internet-service-information> + <msolayer3:internet-evc-access-information> + <msolayer3:internet-evc-speed-value>20</msolayer3:internet-evc-speed-value> + <msolayer3:internet-evc-speed-units>Mbps</msolayer3:internet-evc-speed-units> + <msolayer3:ip-version>ds</msolayer3:ip-version> + </msolayer3:internet-evc-access-information> + <msolayer3:vr-lan> + <msolayer3:routing-protocol>none</msolayer3:routing-protocol> + <msolayer3:vr-lan-interface> + <msolayer3:vr-designation>primary</msolayer3:vr-designation> + <msolayer3:v4-vr-lan-prefix>10.192.70.254</msolayer3:v4-vr-lan-prefix> + <msolayer3:v4-vr-lan-prefix-length>24</msolayer3:v4-vr-lan-prefix-length> + <msolayer3:v6-vr-lan-prefix>2620:0:10d0:0:ffff:ffff:ffff:fffe</msolayer3:v6-vr-lan-prefix> + <msolayer3:v6-vr-lan-prefix-length>64</msolayer3:v6-vr-lan-prefix-length> + <msolayer3:v4-vce-loopback-address>10.189.96.168</msolayer3:v4-vce-loopback-address> + <msolayer3:v6-vce-wan-address>2001:1890:12e3:2cb::</msolayer3:v6-vce-wan-address> + <msolayer3:v4-public-lan-prefixes> + <msolayer3:t-provided-v4-lan-public-prefixes> + <msolayer3:request-index>1</msolayer3:request-index> + <msolayer3:v4-next-hop-address>10.192.70.252</msolayer3:v4-next-hop-address> + <msolayer3:v4-lan-public-prefix>223.233.247.1</msolayer3:v4-lan-public-prefix> + <msolayer3:v4-lan-public-prefix-length>32</msolayer3:v4-lan-public-prefix-length> + </msolayer3:t-provided-v4-lan-public-prefixes> + </msolayer3:v4-public-lan-prefixes> + <msolayer3:v6-public-lan-prefixes> + <msolayer3:t-provided-v6-lan-public-prefixes> + <msolayer3:request-index>1</msolayer3:request-index> + <msolayer3:v6-next-hop-address>2620:0:10d0:0:ffff:ffff:ffff:fffc</msolayer3:v6-next-hop-address> + <msolayer3:v6-lan-public-prefix>2057:0eb4:85a5:0047:1002:8a8e:0371:7331</msolayer3:v6-lan-public-prefix> + <msolayer3:v6-lan-public-prefix-length>48</msolayer3:v6-lan-public-prefix-length> + </msolayer3:t-provided-v6-lan-public-prefixes> + </msolayer3:v6-public-lan-prefixes> + + <msolayer3:dhcp> + <msolayer3:v4-dhcp-server-enabled>Y</msolayer3:v4-dhcp-server-enabled> + <msolayer3:v6-dhcp-server-enabled>Y</msolayer3:v6-dhcp-server-enabled> + <msolayer3:use-v4-default-pool>Y</msolayer3:use-v4-default-pool> + <msolayer3:v4-dhcp-default-pool-prefix>10.192.70.254</msolayer3:v4-dhcp-default-pool-prefix> + <msolayer3:v4-dhcp-default-pool-prefix-length>24</msolayer3:v4-dhcp-default-pool-prefix-length> + <msolayer3:excluded-v4-dhcp-addresses-from-default-pool> + <msolayer3:excluded-v4-address>10.192.70.252</msolayer3:excluded-v4-address> + </msolayer3:excluded-v4-dhcp-addresses-from-default-pool> + + <msolayer3:use-v6-default-pool>Y</msolayer3:use-v6-default-pool> + <msolayer3:v6-dhcp-default-pool-prefix>2620:0:10d0:0:ffff:ffff:ffff:fffe</msolayer3:v6-dhcp-default-pool-prefix> + <msolayer3:v6-dhcp-default-pool-prefix-length>64</msolayer3:v6-dhcp-default-pool-prefix-length> + <msolayer3:excluded-v6-dhcp-addresses-from-default-pool> + <msolayer3:excluded-v6-address>2620:0:10d0:0:ffff:ffff:ffff:fffd</msolayer3:excluded-v6-address> + </msolayer3:excluded-v6-dhcp-addresses-from-default-pool> + + </msolayer3:dhcp> + <msolayer3:pat> + <msolayer3:v4-pat-enabled>Y</msolayer3:v4-pat-enabled> + <msolayer3:use-v4-default-pool>N</msolayer3:use-v4-default-pool> + </msolayer3:pat> + <msolayer3:firewall-lite> + <msolayer3:stateful-firewall-lite-v4-enabled>Y</msolayer3:stateful-firewall-lite-v4-enabled> + <msolayer3:stateful-firewall-lite-v6-enabled>Y</msolayer3:stateful-firewall-lite-v6-enabled> + </msolayer3:firewall-lite> + <msolayer3:static-routes> + <msolayer3:v4-static-routes> + <msolayer3:v4-static-route-prefix>223.233.247.1</msolayer3:v4-static-route-prefix> + <msolayer3:v4-static-route-prefix-length>32</msolayer3:v4-static-route-prefix-length> + <msolayer3:v4-next-hop-address>10.192.70.252</msolayer3:v4-next-hop-address> + </msolayer3:v4-static-routes> + <msolayer3:v4-static-routes> + <msolayer3:v4-static-route-prefix>223.234.242.1</msolayer3:v4-static-route-prefix> + <msolayer3:v4-static-route-prefix-length>32</msolayer3:v4-static-route-prefix-length> + <msolayer3:v4-next-hop-address>10.192.70.253</msolayer3:v4-next-hop-address> + </msolayer3:v4-static-routes> + <msolayer3:v6-static-routes> + <msolayer3:v6-static-route-prefix>2057:0eb4:85a5:0047:1002:8a8e:0371:7331</msolayer3:v6-static-route-prefix> + <msolayer3:v6-static-route-prefix-length>48</msolayer3:v6-static-route-prefix-length> + <msolayer3:v6-next-hop-address>2620:0:10d0:0:ffff:ffff:ffff:fffc</msolayer3:v6-next-hop-address> + </msolayer3:v6-static-routes> + <msolayer3:v6-static-routes> + <msolayer3:v6-static-route-prefix>2057:0eb4:85a5:0047:1002:8a8e:0371:7332</msolayer3:v6-static-route-prefix> + <msolayer3:v6-static-route-prefix-length>48</msolayer3:v6-static-route-prefix-length> + <msolayer3:v6-next-hop-address>2620:0:10d0:0:ffff:ffff:ffff:fffd</msolayer3:v6-next-hop-address> + </msolayer3:v6-static-routes> + </msolayer3:static-routes> + </msolayer3:vr-lan-interface> + </msolayer3:vr-lan> + </msolayer3:internet-service-information> + </tns:service-parameters> +</tns:service-request> + 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 new file mode 100644 index 0000000000..b652a62064 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/feature-request.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<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"> + <tns1:request-information> + <tns1:request-id>tns1:request-id</tns1:request-id> + <tns1:request-action>Layer3ServiceActivateRequest</tns1:request-action> + <tns1:request-sub-action>CANCEL</tns1:request-sub-action> + <tns1:source>tns1:source</tns1:source> + <tns1:notification-url>tns1:notification-url</tns1:notification-url> + <tns1:order-number>tns1:order-number</tns1:order-number> + <tns1:order-version>tns1:order-version</tns1:order-version> + </tns1:request-information> + <tns1:service-information> + <tns1:service-type>SDN-ETHERNET-INTERNET</tns1:service-type> + <tns1:service-instance-id>tns1:service-instance-id</tns1:service-instance-id> + <tns1:subscriber-name>tns1:subscriber-name</tns1:subscriber-name> + </tns1:service-information> + <tns1:feature-information> + <tns1:feature-type>FIREWALL-LITE</tns1:feature-type> + <tns1:feature-instance-id>tns1:feature-instance-id</tns1:feature-instance-id> + <tns1:feature-yang-model>tns1:feature-yang-model</tns1:feature-yang-model> + </tns1:feature-information> + <tns:feature-parameters xsi:type="anyType"/> +</tns:feature-request> 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 new file mode 100644 index 0000000000..b9f70a0e53 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/test/resources/service-request.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<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 "> + <tns1:request-information> + <tns1:request-id>tns1:request-id</tns1:request-id> + <tns1:request-action>Layer3ServiceActivateRequest</tns1:request-action> + <tns1:request-sub-action>CANCEL</tns1:request-sub-action> + <tns1:source>tns1:source</tns1:source> + <tns1:notification-url>tns1:notification-url</tns1:notification-url> + <tns1:order-number>tns1:order-number</tns1:order-number> + <tns1:order-version>tns1:order-version</tns1:order-version> + </tns1:request-information> + <tns1:service-information> + <tns1:service-type>SDN-ETHERNET-INTERNET</tns1:service-type> + <tns1:service-instance-id>tns1:service-instance-id</tns1:service-instance-id> + <tns1:subscriber-name>tns1:subscriber-name</tns1:subscriber-name> + </tns1:service-information> + <tns:service-parameters xsi:type="anyType"/> +</tns:service-request> diff --git a/mso-api-handlers/mso-requests-db/hibernate.properties b/mso-api-handlers/mso-requests-db/hibernate.properties new file mode 100644 index 0000000000..c7803eab12 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/hibernate.properties @@ -0,0 +1,2 @@ +hibernate.show_sql=true
+hibernate.format_sql=true
diff --git a/mso-api-handlers/mso-requests-db/hibernate.reveng.xml b/mso-api-handlers/mso-requests-db/hibernate.reveng.xml new file mode 100644 index 0000000000..dfbf9ed4c4 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/hibernate.reveng.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-reverse-engineering-3.0.dtd" >
+
+<hibernate-reverse-engineering>
+
+ <schema-selection match-schema="MSO"/>
+ <type-mapping>
+ <sql-type jdbc-type="OTHER" hibernate-type="java.sql.Timestamp" />
+ </type-mapping>
+ <table-filter match-schema="MSO" match-name=".*"/>
+</hibernate-reverse-engineering>
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/pom.xml b/mso-api-handlers/mso-requests-db/pom.xml new file mode 100644 index 0000000000..fc09305ea9 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/pom.xml @@ -0,0 +1,207 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-api-handlers</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + + <artifactId>mso-requests-db</artifactId> + + <name>mso-requests-db</name> + <description>MSO Requests Database definition and Hibernate objects</description> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>4.3.6.Final</version> + <exclusions> + <!-- Avoid hibernate inclusion as provided in Jboss --> + <exclusion> + <groupId>org.jboss</groupId> + <artifactId>jandex</artifactId> + </exclusion> + <exclusion> + <groupId>org.javassist</groupId> + <artifactId>javassist</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.spec.javax.transaction</groupId> + <artifactId>jboss-transaction-api_1.2_spec</artifactId> + </exclusion> + <exclusion> + <groupId>antlr</groupId> + <artifactId>antlr</artifactId> + </exclusion> + <exclusion> + <groupId>dom4j</groupId> + <artifactId>dom4j</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-entitymanager</artifactId> + <version>4.3.6.Final</version> + <exclusions> + <!-- Avoid hibernate inclusion as provided in Jboss --> + <exclusion> + <groupId>org.jboss</groupId> + <artifactId>jandex</artifactId> + </exclusion> + <exclusion> + <groupId>org.javassist</groupId> + <artifactId>javassist</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>org.jboss.spec.javax.transaction</groupId> + <artifactId>jboss-transaction-api_1.2_spec</artifactId> + </exclusion> + <exclusion> + <groupId>antlr</groupId> + <artifactId>antlr</artifactId> + </exclusion> + <exclusion> + <groupId>dom4j</groupId> + <artifactId>dom4j</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.hibernate.javax.persistence</groupId> + <artifactId>hibernate-jpa-2.1-api</artifactId> + <version>1.0.0.Final</version> + </dependency> + + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <packaging>jar</packaging> + <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> + <groupId>de.juplo</groupId> + <artifactId>hibernate4-maven-plugin</artifactId> + <version>1.1.0</version> + <executions> + <!-- MySQL --> + <execution> + <id>MySQL</id> + <goals> + <goal>export</goal> + </goals> + <configuration> + <hibernateDialect>org.hibernate.dialect.MySQL5Dialect</hibernateDialect> + <hibernateMapping>${project.basedir}/src/main/resources/InfraActiveRequests.hbm.xml,${project.basedir}/src/main/resources/SiteStatus.hbm.xml</hibernateMapping> + <target>SCRIPT</target> + <skip>false</skip> + <force>true</force> + <outputFile>${project.build.directory}/MySQL-Requests-schema.sql</outputFile> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>3.0.1</version> + <executions> + + <execution> + <id>copy-sql-file</id> + <phase>install</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <overwrite>true</overwrite> + + <outputDirectory>${project.basedir}/../../packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/main-schemas</outputDirectory> + + <resources> + <resource> + <directory>${project.build.directory}</directory> + <filtering>false</filtering> + <includes> + <include>*.sql</include> + </includes> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>de.juplo</groupId> + <artifactId> + hibernate4-maven-plugin + </artifactId> + <versionRange> + [1.0.3,) + </versionRange> + <goals> + <goal>export</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore></ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + +</project>
\ No newline at end of file diff --git a/mso-api-handlers/mso-requests-db/src/hibernate.reveng.xml b/mso-api-handlers/mso-requests-db/src/hibernate.reveng.xml new file mode 100644 index 0000000000..b9ac472778 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/hibernate.reveng.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://www.hibernate.org/dtd//hibernate-reverse-engineering-3.0.dtd" > + +<hibernate-reverse-engineering> + + <schema-selection match-schema="MSO"/> + <table-filter match-schema="MSO" match-name=".*"/> + <type-mapping> + <sql-type jdbc-type="OTHER" hibernate-type="java.sql.Timestamp" /> + </type-mapping> +</hibernate-reverse-engineering> diff --git a/mso-api-handlers/mso-requests-db/src/main/java/META-INF/MANIFEST.MF b/mso-api-handlers/mso-requests-db/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5e9495128c --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0
+Class-Path:
+
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 new file mode 100644 index 0000000000..21bece9b10 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/HibernateUtil.java @@ -0,0 +1,59 @@ +/*- + * ============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/InfraActiveRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraActiveRequests.java new file mode 100644 index 0000000000..992cf6afc1 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraActiveRequests.java @@ -0,0 +1,41 @@ +/*- + * ============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; + + +/** + * InfraActiveRequests + */ +public class InfraActiveRequests extends InfraRequests { + + /** + * Serialization id. + */ + private static final long serialVersionUID = 5003555140088137254L; + + public InfraActiveRequests() { + super (); + } + + public InfraActiveRequests(String requestId, String action) { + super (requestId, action); + } +} 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 new file mode 100644 index 0000000000..43128192d9 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java @@ -0,0 +1,405 @@ +/*- + * ============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; + +// Generated Jul 27, 2015 3:05:00 PM by Hibernate Tools 3.4.0.CR1 + +import java.sql.Timestamp; + +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + +import org.openecomp.mso.requestsdb.adapter.TimestampXMLAdapter; + +/** + * InfraActiveRequests generated by hbm2java + */ +public class InfraRequests implements java.io.Serializable { + + /** + * Serialization id. + */ + private static final long serialVersionUID = -661307666798018192L; + + private String requestId; + private String clientRequestId; + private String action; + private String requestStatus; + private String statusMessage; + private Long progress; + private Timestamp startTime; + private Timestamp endTime; + private String source; + private String vnfId; + private String vnfName; + private String vnfType; + private String serviceType; + private String aicNodeClli; + private String tenantId; + private String provStatus; + private String vnfParams; + private String vnfOutputs; + private String requestBody; + private String responseBody; + private String lastModifiedBy; + private Timestamp modifyTime; + private String requestType; + private String volumeGroupId; + private String volumeGroupName; + private String vfModuleId; + private String vfModuleName; + private String vfModuleModelName; + private String aaiServiceId; + private String aicCloudRegion; + private String callBackUrl; + private String correlator; + private String serviceInstanceId; + private String serviceInstanceName; + private String requestScope; + private String requestAction; + private String networkId; + private String networkName; + private String networkType; + + + public InfraRequests() { + } + + public InfraRequests(String requestId, String action) { + this.requestId = requestId; + this.action = action; + } + + public String getRequestId() { + return this.requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getClientRequestId() { + return clientRequestId; + } + + public void setClientRequestId(String clientRequestId) { + this.clientRequestId = clientRequestId; + } + + public String getAction() { + return this.action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getRequestStatus() { + return this.requestStatus; + } + + public void setRequestStatus(String requestStatus) { + this.requestStatus = requestStatus; + } + + public String getStatusMessage() { + return this.statusMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + public Long getProgress() { + return this.progress; + } + + public void setProgress(Long progress) { + this.progress = progress; + } + + @XmlJavaTypeAdapter(TimestampXMLAdapter.class) + public Timestamp getStartTime() { + return this.startTime; + } + + public void setStartTime(Timestamp startTime) { + this.startTime = startTime; + } + + @XmlJavaTypeAdapter(TimestampXMLAdapter.class) + public Timestamp getEndTime() { + return this.endTime; + } + + public void setEndTime(Timestamp endTime) { + this.endTime = endTime; + } + + public String getSource() { + return this.source; + } + + public void setSource(String source) { + this.source = source; + } + + public String getVnfId() { + return this.vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfName() { + return this.vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getVnfType() { + return this.vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public String getServiceType() { + return this.serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getAicNodeClli() { + return this.aicNodeClli; + } + + public void setAicNodeClli(String aicNodeClli) { + this.aicNodeClli = aicNodeClli; + } + + public String getTenantId() { + return this.tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getProvStatus() { + return this.provStatus; + } + + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + + public String getVnfParams() { + return this.vnfParams; + } + + public void setVnfParams(String vnfParams) { + this.vnfParams = vnfParams; + } + + public String getVnfOutputs() { + return this.vnfOutputs; + } + + public void setVnfOutputs(String vnfOutputs) { + this.vnfOutputs = vnfOutputs; + } + + public String getRequestBody() { + return this.requestBody; + } + + public void setRequestBody(String requestBody) { + this.requestBody = requestBody; + } + + public String getResponseBody() { + return this.responseBody; + } + + public void setResponseBody(String responseBody) { + this.responseBody = responseBody; + } + + public String getLastModifiedBy() { + return this.lastModifiedBy; + } + + public void setLastModifiedBy(String lastModifiedBy) { + this.lastModifiedBy = lastModifiedBy; + } + + @XmlJavaTypeAdapter(TimestampXMLAdapter.class) + public Timestamp getModifyTime() { + return this.modifyTime; + } + + public void setModifyTime(Timestamp modifyTime) { + this.modifyTime = modifyTime; + } + + public String getRequestType() { + return this.requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public String getVolumeGroupId() { + return this.volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVolumeGroupName() { + return this.volumeGroupName; + } + + public void setVolumeGroupName(String volumeGroupName) { + this.volumeGroupName = volumeGroupName; + } + + public String getVfModuleId() { + return this.vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVfModuleName() { + return this.vfModuleName; + } + + public void setVfModuleName(String vfModuleName) { + this.vfModuleName = vfModuleName; + } + + public String getVfModuleModelName() { + return this.vfModuleModelName; + } + + public void setVfModuleModelName(String vfModuleModelName) { + this.vfModuleModelName = vfModuleModelName; + } + + public String getAaiServiceId() { + return this.aaiServiceId; + } + + public void setAaiServiceId(String aaiServiceId) { + this.aaiServiceId = aaiServiceId; + } + + public String getAicCloudRegion() { + return this.aicCloudRegion; + } + + public void setAicCloudRegion(String aicCloudRegion) { + this.aicCloudRegion = aicCloudRegion; + } + + public String getCallBackUrl() { + return callBackUrl; + } + + public void setCallBackUrl(String callBackUrl) { + this.callBackUrl = callBackUrl; + } + + public String getCorrelator() { + return correlator; + } + + public void setCorrelator(String correlator) { + this.correlator = correlator; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public void setServiceInstanceName(String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + + public String getRequestScope() { + return requestScope; + } + + public void setRequestScope(String requestScope) { + this.requestScope = requestScope; + } + + public String getRequestAction() { + return requestAction; + } + + public void setRequestAction(String requestAction) { + this.requestAction = requestAction; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getNetworkName() { + return networkName; + } + + public void setNetworkName(String networkName) { + this.networkName = networkName; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java new file mode 100644 index 0000000000..22179e95f8 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java @@ -0,0 +1,72 @@ +/*- + * ============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 java.util.HashMap; +import java.util.Map; + +public class MockRequestsDatabase { + + private Map<String, InfraActiveRequests> activeRequests; + + public MockRequestsDatabase() { + activeRequests = new HashMap<String, InfraActiveRequests>(); + } + + public void addRecord(InfraActiveRequests record) { + String serviceType = record.getServiceType(); + String serviceInstanceId = record.getServiceInstanceId(); + String key = serviceType + "::" + serviceInstanceId; + activeRequests.put(key, record); + } + + public void deleteRecord(String serviceType, String serviceInstanceId) { + String key = serviceType + "::" + serviceInstanceId; + activeRequests.remove(key); + } + + public InfraActiveRequests getRecord(String serviceType, String serviceInstanceId) { + String key = serviceType + "::" + serviceInstanceId; + InfraActiveRequests record = activeRequests.get(key); + return record; + } + + public InfraActiveRequests checkDuplicate(String serviceType, String serviceInstanceId) { + return getRecord(serviceType, serviceInstanceId); + } + + public InfraActiveRequests checkRetry(String serviceType, String serviceInstanceId) { + InfraActiveRequests record = getRecord(serviceType, serviceInstanceId); + InfraActiveRequests returnRecord = null; + if (record != null) { + String requestAction = record.getRequestAction(); + if (requestAction == null || !requestAction.equals("GetLayer3ServiceDetailsRequest")) { + String status = record.getRequestStatus(); + if (status != null && status.equals("COMPLETED")) { + return returnRecord = record; + } + } + } + return returnRecord; + } +} 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 new file mode 100644 index 0000000000..8961b26a80 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java @@ -0,0 +1,494 @@ +/*- + * ============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 java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.apache.http.HttpStatus; +import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.Session; +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.logger.MsoLogger; + +public final class RequestsDatabase { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL); + + private static final String SOURCE = "source"; + private static final String START_TIME = "startTime"; + private static final String REQUEST_TYPE = "requestType"; + private static final String SERVICE_INSTANCE_ID = "serviceInstanceId"; + private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName"; + private static final String VNF_INSTANCE_NAME = "vnfName"; + private static final String VNF_INSTANCE_ID = "vnfId"; + private static final String VOLUME_GROUP_INSTANCE_NAME = "volumeGroupName"; + private static final String VOLUME_GROUP_INSTANCE_ID = "volumeGroupId"; + private static final String VFMODULE_INSTANCE_NAME = "vfModuleName"; + private static final String VFMODULE_INSTANCE_ID = "vfModuleId"; + private static final String NETWORK_INSTANCE_NAME = "networkName"; + private static final String NETWORK_INSTANCE_ID = "networkId"; + private static final String GLOBAL_SUBSCRIBER_ID = "globalSubscriberId"; + private static final String SERVICE_NAME_VERSION_ID = "serviceNameVersionId"; + private static final String SERVICE_ID = "serviceId"; + private static final String SERVICE_VERSION = "serviceVersion"; + private static final String SERVICE_TYPE = "serviceType"; + private static final String REQUEST_ID = "requestId"; + private static MockRequestsDatabase mockDB = null; + + /** + * Avoids creating an instance of this utility class. + */ + private RequestsDatabase () { + } + + public static boolean healthCheck () { + Session session = HibernateUtil.getSessionFactory ().openSession (); + try { + Query query = session.createSQLQuery (" show tables "); + + List<?> list = query.list(); + + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + } + return true; + } + + + 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 (); + + int result = 0; + try { + session.beginTransaction (); + Query query = session.createQuery ("update InfraActiveRequests set requestStatus = :requestStatus, modifyTime = :modifyTime, lastModifiedBy = :lastModifiedBy where requestId = :requestId "); + query.setParameter ("requestStatus", requestStatus); + query.setParameter (REQUEST_ID, requestId); + query.setParameter ("lastModifiedBy", lastModifiedBy); + Calendar modifyTime = Calendar.getInstance (); + Timestamp modifyTimeStamp = new Timestamp (modifyTime.getTimeInMillis ()); + query.setParameter ("modifyTime", modifyTimeStamp); + result = query.executeUpdate (); + session.getTransaction ().commit (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateInfraStatus", null); + } + return result; + } + + 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 (); + + int result = 0; + try { + session.beginTransaction (); + Query query = session.createQuery ("update InfraActiveRequests set requestStatus = :requestStatus, modifyTime = :modifyTime, progress = :progress, lastModifiedBy = :lastModifiedBy where requestId = :requestId "); + query.setParameter ("requestStatus", requestStatus); + query.setParameter (REQUEST_ID, requestId); + query.setParameter ("progress", progress); + query.setParameter ("lastModifiedBy", lastModifiedBy); + Calendar modifyTime = Calendar.getInstance (); + Timestamp modifyTimeStamp = new Timestamp (modifyTime.getTimeInMillis ()); + query.setParameter ("modifyTime", modifyTimeStamp); + result = query.executeUpdate (); + session.getTransaction ().commit (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateInfraStatus", null); + } + return result; + } + + 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 (); + + int result = 0; + try { + session.beginTransaction (); + Query query = session.createQuery ("update InfraActiveRequests set requestStatus = :requestStatus, statusMessage = :statusMessage, progress = :progress, endTime = :endTime, responseBody = :responseBody, lastModifiedBy = :lastModifiedBy where id.requestId = :requestId "); + query.setParameter ("requestStatus", requestStatus); + query.setParameter ("requestId", requestId); + Calendar endTime = Calendar.getInstance (); + Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ()); + query.setParameter ("endTime", endTimeStamp); + query.setParameter ("statusMessage", statusMessage); + query.setParameter ("progress", progress); + query.setParameter ("responseBody", responseBody); + query.setParameter ("lastModifiedBy", lastModifiedBy); + result = query.executeUpdate (); + session.getTransaction ().commit (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateInfraFinalStatus", null); + } + return result; + } + + + private static List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) { + + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Execute query on infra active request table"); + + List <InfraActiveRequests> results = new ArrayList<InfraActiveRequests>(); + + Session session = HibernateUtil.getSessionFactory ().openSession (); + try { + session.beginTransaction (); + Criteria crit = session.createCriteria (InfraActiveRequests.class); + for (Criterion criterion : criteria) { + crit.add (criterion); + } + crit.addOrder (order); + + // @SuppressWarnings("unchecked") + results = crit.list (); + + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getInfraActiveRequest", null); + } + return results; + } + + public static InfraActiveRequests getRequestFromInfraActive (String requestId) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get request " + requestId + " from InfraActiveRequests DB"); + + Session session = HibernateUtil.getSessionFactory ().openSession (); + InfraActiveRequests ar = null; + try { + session.beginTransaction (); + Query query = session.createQuery ("from InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId"); + query.setParameter (REQUEST_ID, requestId); + ar = (InfraActiveRequests) query.uniqueResult (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "InfraRequestDB", "getRequestFromInfraActive", null); + } + return ar; + } + + public static InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) { + + List <Criterion> criteria = new LinkedList <> (); + + if(instanceName != null && !instanceName.equals("")) { + + if(requestScope.equals("service")){ + criteria.add (Restrictions.eq (SERVICE_INSTANCE_NAME, instanceName)); + } else if(requestScope.equals("vnf")){ + criteria.add (Restrictions.eq (VNF_INSTANCE_NAME, instanceName)); + } else if(requestScope.equals("volumeGroup")){ + criteria.add (Restrictions.eq (VOLUME_GROUP_INSTANCE_NAME, instanceName)); + } else if(requestScope.equals("vfModule")){ + criteria.add (Restrictions.eq (VFMODULE_INSTANCE_NAME, instanceName)); + } else if(requestScope.equals("network")){ + criteria.add (Restrictions.eq (NETWORK_INSTANCE_NAME, instanceName)); + } + + } else { + if(instanceIdMap != null){ + if(requestScope.equals("service") && instanceIdMap.get("serviceInstanceId") != null){ + criteria.add (Restrictions.eq (SERVICE_INSTANCE_ID, instanceIdMap.get("serviceInstanceId"))); + } + + if(requestScope.equals("vnf") && instanceIdMap.get("vnfInstanceId") != null){ + criteria.add (Restrictions.eq (VNF_INSTANCE_ID, instanceIdMap.get("vnfInstanceId"))); + } + + if(requestScope.equals("vfModule") && instanceIdMap.get("vfModuleInstanceId") != null){ + criteria.add (Restrictions.eq (VFMODULE_INSTANCE_ID, instanceIdMap.get("vfModuleInstanceId"))); + } + + if(requestScope.equals("volumeGroup") && instanceIdMap.get("volumeGroupInstanceId") != null){ + criteria.add (Restrictions.eq (VOLUME_GROUP_INSTANCE_ID, instanceIdMap.get("volumeGroupInstanceId"))); + } + + if(requestScope.equals("network") && instanceIdMap.get("networkInstanceId") != null){ + criteria.add (Restrictions.eq (NETWORK_INSTANCE_ID, instanceIdMap.get("networkInstanceId"))); + } + } + } + + criteria.add (Restrictions.in ("requestStatus", new String[] { "PENDING", "IN_PROGRESS", "TIMEOUT" })); + + Order order = Order.desc (START_TIME); + + List<InfraActiveRequests> dupList = executeInfraQuery(criteria, order); + + InfraActiveRequests infraActiveRequests = null; + + if(dupList != null && dupList.size() > 0){ + infraActiveRequests = dupList.get(0); + } + + return infraActiveRequests; + } + + public static List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive (Map<String, List<String>> orchestrationMap) { + + + List <Criterion> criteria = new LinkedList <> (); + for (Map.Entry<String, List<String>> entry : orchestrationMap.entrySet()) + { + String mapKey = entry.getKey(); + + if(mapKey.equalsIgnoreCase("vnfInstanceId")){ + mapKey = "vnfId"; + } else if(mapKey.equalsIgnoreCase("vnfInstanceName")) { + mapKey = "vnfName"; + } else if(mapKey.equalsIgnoreCase("vfModuleInstanceId")) { + mapKey = "vfModuleId"; + } else if(mapKey.equalsIgnoreCase("vfModuleInstanceName")) { + mapKey = "vfModuleName"; + } else if(mapKey.equalsIgnoreCase("volumeGroupInstanceId")) { + mapKey = "volumeGroupId"; + } else if(mapKey.equalsIgnoreCase("volumeGroupInstanceName")) { + mapKey = "volumeGroupName"; + } else if(mapKey.equalsIgnoreCase("networkInstanceId")) { + mapKey = "networkId"; + } else if(mapKey.equalsIgnoreCase("networkInstanceName")) { + mapKey = "networkName"; + } else if(mapKey.equalsIgnoreCase("lcpCloudRegionId")) { + mapKey = "aicCloudRegion"; + } + + criteria.add(Restrictions.eq(mapKey, entry.getValue().get(1))); + + } + + Order order = Order.asc (START_TIME); + + return executeInfraQuery (criteria, order); + } + + + public static List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName, + String queryValue, + String requestType) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get list of infra requests from DB with " + queryAttributeName + " = " + queryValue); + + Session session = HibernateUtil.getSessionFactory ().openSession (); + try { + session.beginTransaction (); + Criteria crit = session.createCriteria (InfraActiveRequests.class) + .add (Restrictions.eq (queryAttributeName, queryValue)); + crit.add (Restrictions.eqOrIsNull (REQUEST_TYPE, requestType)); + crit.addOrder (Order.desc (START_TIME)); + crit.addOrder (Order.asc (SOURCE)); + + @SuppressWarnings("unchecked") + List <InfraActiveRequests> arList = crit.list (); + if (arList != null && !arList.isEmpty ()) { + return arList; + } + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + // msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getRequestListFromInfraActive", null); + } + return null; + } + + + public static InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) { + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get infra request from DB with id " + requestId); + + Session session = HibernateUtil.getSessionFactory ().openSession (); + InfraActiveRequests ar = null; + try { + session.beginTransaction (); + Query query = session.createQuery ("from InfraActiveRequests where (requestId = :requestId OR clientRequestId = :requestId) and requestType = :requestType"); + query.setParameter (REQUEST_ID, requestId); + query.setParameter (REQUEST_TYPE, requestType); + ar = (InfraActiveRequests) query.uniqueResult (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getRequestFromInfraActive", null); + } + return ar; + } + + + public static InfraActiveRequests checkDuplicateByVnfName (String vnfName, String action, String requestType) { + + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get infra request from DB for VNF " + vnfName + " and action " + action + " and requestType " + requestType); + + InfraActiveRequests ar = null; + Session session = HibernateUtil.getSessionFactory ().openSession (); + + try { + session.beginTransaction (); + Query query = session.createQuery ("from InfraActiveRequests where vnfName = :vnfName and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT') and requestType = :requestType ORDER BY startTime DESC"); + query.setParameter ("vnfName", vnfName); + query.setParameter ("action", action); + query.setParameter (REQUEST_TYPE, requestType); + @SuppressWarnings("unchecked") + List <InfraActiveRequests> results = query.list (); + if (!results.isEmpty ()) { + ar = results.get (0); + } + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "checkDuplicateByVnfName", null); + } + + return ar; + } + + public static InfraActiveRequests checkDuplicateByVnfId (String vnfId, String action, String requestType) { + + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Get list of infra requests from DB for VNF " + vnfId + " and action " + action); + + InfraActiveRequests ar = null; + Session session = HibernateUtil.getSessionFactory ().openSession (); + + try { + session.beginTransaction (); + Query query = session.createQuery ("from InfraActiveRequests where vnfId = :vnfId and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT') and requestType = :requestType ORDER BY startTime DESC"); + query.setParameter ("vnfId", vnfId); + query.setParameter ("action", action); + query.setParameter (REQUEST_TYPE, requestType); + @SuppressWarnings("unchecked") + List <InfraActiveRequests> results = query.list (); + if (!results.isEmpty ()) { + ar = results.get (0); + } + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "checkDuplicateByVnfId", null); + } + + return ar; + } + + public static void setMockDB(MockRequestsDatabase mockDB) { + RequestsDatabase.mockDB = mockDB; + } + + /** + * Fetch a specific SiteStatus by SiteName. + * + * @param siteName The unique name of the site + * @return SiteStatus object or null if none found + */ + public static SiteStatus getSiteStatus (String siteName) { + Session session = HibernateUtil.getSessionFactory ().openSession (); + + long startTime = System.currentTimeMillis (); + SiteStatus siteStatus = null; + msoLogger.debug ("Request database - get Site Status with Site name:" + siteName); + try { + String hql = "FROM SiteStatus WHERE siteName = :site_name"; + Query query = session.createQuery (hql); + query.setParameter ("site_name", siteName); + + siteStatus = (SiteStatus) query.uniqueResult (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.debug ("getSiteStatus - Successfully: " + siteStatus); + } + return siteStatus; + } + + /** + * Fetch a specific SiteStatus by SiteName. + * + * @param siteName The unique name of the site + * @param status The updated status of the Site + */ + public static void updateSiteStatus (String siteName, boolean status) { + Session session = HibernateUtil.getSessionFactory ().openSession (); + session.beginTransaction (); + + long startTime = System.currentTimeMillis (); + msoLogger.debug ("Request database - save Site Status with Site name:" + siteName); + try { + String hql = "FROM SiteStatus WHERE siteName = :site_name"; + Query query = session.createQuery (hql); + query.setParameter ("site_name", siteName); + + SiteStatus siteStatus = (SiteStatus) query.uniqueResult (); + if (siteStatus == null) { + siteStatus = new SiteStatus (); + siteStatus.setSiteName (siteName); + siteStatus.setStatus (status); + //siteStatus.setCreated(new Timestamp(new Date().getTime())); + session.save (siteStatus); + } else { + siteStatus.setStatus(status); + //siteStatus.setCreated(new Timestamp(new Date().getTime())); + session.merge (siteStatus); + } + session.getTransaction ().commit (); + } finally { + if (session != null && session.isOpen ()) { + session.close (); + } + msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateSiteStatus", null); + } + } + +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java new file mode 100644 index 0000000000..421809612c --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java @@ -0,0 +1,72 @@ +/*- + * ============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.logger.MsoLogger; + +import java.sql.Timestamp; + + +public class SiteStatus { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); + + private boolean status; + private String siteName; + private Timestamp created; + + public SiteStatus() { + } + + public Timestamp getCreated() { + return created; + } + + public void setCreated(Timestamp created) { + this.created = created; + } + + public String getSiteName() { + return siteName; + } + + public void setSiteName(String siteName) { + this.siteName = siteName; + } + + public void setStatus(boolean status) { + this.status = status; + } + + public boolean getStatus() { + return status; + } + + @Override + public String toString() { + return "SiteStatus{" + + "status=" + status + + ", siteName='" + siteName + '\'' + + ", created=" + created + + '}'; + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapter.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapter.java new file mode 100644 index 0000000000..1e3f46db4b --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapter.java @@ -0,0 +1,42 @@ +/*- + * ============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.adapter; + + +import java.sql.Timestamp; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +public class TimestampXMLAdapter extends XmlAdapter <Long, Timestamp> { + + @Override + public Long marshal (Timestamp v) throws Exception { + return v.getTime (); + } + + @Override + public Timestamp unmarshal (Long v) throws Exception { + if (v == null) { + return new Timestamp(0); + } + return new Timestamp (v); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/package-info.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/package-info.java new file mode 100644 index 0000000000..542d711ab1 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/package-info.java @@ -0,0 +1,26 @@ +/*- + * ============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========================================================= + */ + +/** + * XML adapters. + */ + +package org.openecomp.mso.requestsdb.adapter; + 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 new file mode 100644 index 0000000000..b98177ae83 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/resources/InfraActiveRequests.hbm.xml @@ -0,0 +1,146 @@ +<?xml version="1.0"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!-- Generated Jul 27, 2015 3:05:00 PM by Hibernate Tools 3.4.0.CR1 --> +<hibernate-mapping> + <class name="org.openecomp.mso.requestsdb.InfraActiveRequests" table="INFRA_ACTIVE_REQUESTS"> + <id name="requestId" type="string"> + <column name="REQUEST_ID" length="45"/> + <generator class="assigned"/> + </id> + <property name="clientRequestId" type="string" unique="true"> + <column name="CLIENT_REQUEST_ID" length="45" unique="true"/> + </property> + <property name="action" type="string"> + <column name="ACTION" length="45" not-null="true"/> + </property> + <property name="requestStatus" type="string"> + <column name="REQUEST_STATUS" length="20"/> + </property> + <property name="statusMessage" type="string"> + <column name="STATUS_MESSAGE" length="2000"/> + </property> + <property name="progress" type="java.lang.Long"> + <column name="PROGRESS" precision="11" scale="0"/> + </property> + <property name="startTime" type="timestamp"> + <column name="START_TIME"/> + </property> + <property name="endTime" type="timestamp"> + <column name="END_TIME"/> + </property> + <property name="source" type="string"> + <column name="SOURCE" length="45"/> + </property> + <property name="vnfId" type="string"> + <column name="VNF_ID" length="45"/> + </property> + <property name="vnfName" type="string"> + <column name="VNF_NAME" length="80"/> + </property> + <property name="vnfType" type="string"> + <column name="VNF_TYPE" length="200"/> + </property> + <property name="serviceType" type="string"> + <column name="SERVICE_TYPE" length="45"/> + </property> + <property name="aicNodeClli" type="string"> + <column name="AIC_NODE_CLLI" length="11"/> + </property> + <property name="tenantId" type="string"> + <column name="TENANT_ID" length="45"/> + </property> + <property name="provStatus" type="string"> + <column name="PROV_STATUS" length="20"/> + </property> + <property name="vnfParams" type="text"> + <column name="VNF_PARAMS"/> + </property> + <property name="vnfOutputs" type="text"> + <column name="VNF_OUTPUTS"/> + </property> + <property name="requestBody" type="text"> + <column name="REQUEST_BODY"/> + </property> + <property name="responseBody" type="text"> + <column name="RESPONSE_BODY"/> + </property> + <property name="lastModifiedBy" type="string"> + <column name="LAST_MODIFIED_BY" length="50"/> + </property> + <property name="modifyTime" type="timestamp"> + <column name="MODIFY_TIME"/> + </property> + <property name="requestType" type="string"> + <column name="REQUEST_TYPE" length="20"/> + </property> + <property name="volumeGroupId" type="string"> + <column name="VOLUME_GROUP_ID" length="45"/> + </property> + <property name="volumeGroupName" type="string"> + <column name="VOLUME_GROUP_NAME" length="45"/> + </property> + <property name="vfModuleId" type="string"> + <column name="VF_MODULE_ID" length="45"/> + </property> + <property name="vfModuleName" type="string"> + <column name="VF_MODULE_NAME" length="200"/> + </property> + <property name="vfModuleModelName" type="string"> + <column name="VF_MODULE_MODEL_NAME" length="200"/> + </property> + <property name="aaiServiceId" type="string"> + <column name="AAI_SERVICE_ID" length="50"/> + </property> + <property name="aicCloudRegion" type="string"> + <column name="AIC_CLOUD_REGION" length="11"/> + </property> + <property name="callBackUrl" type="string"> + <column name="CALLBACK_URL" length="200"/> + </property> + <property name="correlator" type="string"> + <column name="CORRELATOR" length="80"/> + </property> + <property name="serviceInstanceId" type="string"> + <column name="SERVICE_INSTANCE_ID" length="45"/> + </property> + <property name="serviceInstanceName" type="string"> + <column name="SERVICE_INSTANCE_NAME" length="80"/> + </property> + <property name="requestScope" type="string"> + <column name="REQUEST_SCOPE" length="20"/> + </property> + <property name="requestAction" type="string"> + <column name="REQUEST_ACTION" length="45" not-null="true"/> + </property> + <property name="networkId" type="string"> + <column name="NETWORK_ID" length="45"/> + </property> + <property name="networkName" type="string"> + <column name="NETWORK_NAME" length="80"/> + </property> + <property name="networkType" type="string"> + <column name="NETWORK_TYPE" length="80"/> + </property> + </class> +</hibernate-mapping> diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/SiteStatus.hbm.xml b/mso-api-handlers/mso-requests-db/src/main/resources/SiteStatus.hbm.xml new file mode 100644 index 0000000000..95ccfda5fe --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/resources/SiteStatus.hbm.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> + +<hibernate-mapping package="org.openecomp.mso.requestsdb"> + <class name="SiteStatus" table="SITE_STATUS"> + <meta attribute="class-description"> + This class describes a Site Status + </meta> + + <id name="siteName" type="string" column="SITE_NAME"/> + + <property name="status" column="STATUS" type="boolean" length="256"/> + <property name="created" column="CREATION_TIMESTAMP" type="timestamp" generated="insert" insert="false" update="false"/> + </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-mysql.cfg.xml new file mode 100644 index 0000000000..531b77196c --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-mysql.cfg.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> +<hibernate-configuration> + <session-factory> + <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> + <property name="hibernate.show_sql">false</property> + <property name="hibernate.format_sql">true</property> + <property name="connection.datasource">java:jboss/datasources/mso-requests</property> + +<!-- <property name="hibernate.hbm2ddl.auto">create</property> --> + + <mapping resource="InfraActiveRequests.hbm.xml"></mapping> + <mapping resource="SiteStatus.hbm.xml"></mapping> + </session-factory> +</hibernate-configuration> diff --git a/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-requests-ajsc.cfg.xml b/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-requests-ajsc.cfg.xml new file mode 100644 index 0000000000..14bd7b5e69 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/main/resources/hibernate-requests-ajsc.cfg.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> +<hibernate-configuration> + <session-factory> + <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> + <property name="hibernate.show_sql">false</property> + <property name="hibernate.format_sql">true</property> + + <mapping resource="InfraActiveRequests.hbm.xml"></mapping> + <mapping resource="SiteStatus.hbm.xml"></mapping> + </session-factory> + <!-- <session-factory name="MSORequestsFactory"> + <property name="connection.url">${REQUESTS_CONNECTION_URL}</property> + <property name="connection.username">${REQUESTS_USERNAME}</property> + <property name="connection.password">${REQUESTS_PASSWORD}</property> + <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> + <property name="hibernate.default_schema">mso_requests</property> + <property name="connection.driver_class">org.mariadb.jdbc.Driver</property> + <property name="hibernate.current_session_context_class">thread</property> + <property name="hibernate.show_sql">false</property> + <property name="hibernate.format_sql">true</property> + + + <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> + <property name="hibernate.c3p0.min_size">${REQUESTS_MIN_POOL_SIZE}</property> + <property name="hibernate.c3p0.max_size">${REQUESTS_MAX_POOL_SIZE}</property> + <property name="hibernate.c3p0.timeout">${REQUESTS_TIMEOUT}</property> + <property name="hibernate.c3p0.max_statements">50</property> + <property name="hibernate.c3p0.idle_test_period">1000</property> + <property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property> + + + + <mapping resource="InfraActiveRequests.hbm.xml"></mapping> + + </session-factory> --> +</hibernate-configuration> 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 new file mode 100644 index 0000000000..6ae0a641c8 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/HibernateUtilESTest.java @@ -0,0 +1,24 @@ +/* + * 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 new file mode 100644 index 0000000000..e2e9b60026 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/HibernateUtilESTestscaffolding.java @@ -0,0 +1,107 @@ +/** + * 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/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraActiveRequestsESTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraActiveRequestsESTest.java new file mode 100644 index 0000000000..96ed0bea83 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraActiveRequestsESTest.java @@ -0,0 +1,29 @@ +/* + * This file was automatically generated by EvoSuite + * Wed Dec 14 15:13:40 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.junit.runner.RunWith; +import org.openecomp.mso.requestsdb.InfraActiveRequests; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class InfraActiveRequestsESTest extends InfraActiveRequestsESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + InfraActiveRequests infraActiveRequests0 = new InfraActiveRequests(); + assertNull(infraActiveRequests0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + InfraActiveRequests infraActiveRequests0 = new InfraActiveRequests("#)r", "#)r"); + assertNull(infraActiveRequests0.getNetworkName()); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraActiveRequestsESTestscaffolding.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraActiveRequestsESTestscaffolding.java new file mode 100644 index 0000000000..012b17a4d0 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraActiveRequestsESTestscaffolding.java @@ -0,0 +1,84 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Wed Dec 14 15:13:40 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 InfraActiveRequestsESTestscaffolding { + + @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.InfraActiveRequests"; + 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(InfraActiveRequestsESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.requestsdb.InfraActiveRequests", + "org.openecomp.mso.requestsdb.InfraRequests" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(InfraActiveRequestsESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.requestsdb.InfraRequests", + "org.openecomp.mso.requestsdb.InfraActiveRequests" + ); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsESTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsESTest.java new file mode 100644 index 0000000000..e3f5710833 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsESTest.java @@ -0,0 +1,2029 @@ +/* + * This file was automatically generated by EvoSuite + * Wed Dec 14 15:15:48 GMT 2016 + */ + +package org.openecomp.mso.requestsdb; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; +import java.sql.Timestamp; +import java.time.Clock; +import java.time.DateTimeException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalUnit; +import java.time.temporal.UnsupportedTemporalTypeException; +import java.util.Date; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.System; +import org.evosuite.runtime.mock.java.net.MockURI; +import org.evosuite.runtime.mock.java.time.MockClock; +import org.evosuite.runtime.mock.java.time.MockInstant; +import org.evosuite.runtime.mock.java.time.MockLocalDateTime; +import org.evosuite.runtime.mock.java.util.MockDate; +import org.junit.runner.RunWith; +import org.openecomp.mso.requestsdb.InfraRequests; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class InfraRequestsESTest extends InfraRequestsESTestscaffolding { + + @Test(timeout = 4000) + public void test000() throws Throwable { + System.setCurrentTimeMillis(0L); + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setRequestStatus("org.openecomp.mso.requestsdb.InfraRequests"); + Instant instant0 = MockInstant.ofEpochSecond((-1L)); + Timestamp timestamp0 = Timestamp.from(instant0); + infraRequests0.setModifyTime(timestamp0); + infraRequests0.setTenantId("7z3rvWw}>"); + infraRequests0.setVnfParams("7z3rvWw}>"); + infraRequests0.setVfModuleModelName("H(+:J_^eh02J"); + InfraRequests infraRequests1 = new InfraRequests("", "zCyMQj^e"); + infraRequests1.setProvStatus("7z3rvWw}>"); + infraRequests1.getProgress(); + infraRequests0.setProgress((Long) null); + infraRequests0.setRequestId(""); + infraRequests0.getStartTime(); + Timestamp timestamp1 = infraRequests0.getModifyTime(); + infraRequests0.getEndTime(); + Timestamp timestamp2 = infraRequests0.getModifyTime(); + assertSame(timestamp2, timestamp1); + } + + @Test(timeout = 4000) + public void test001() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("&^pJug .NI><P", "&^pJug .NI><P"); + infraRequests0.setNetworkType("jxNkugb+TFTHEb"); + infraRequests0.setVfModuleName("&^pJug .NI><P"); + Timestamp timestamp0 = new Timestamp(0L); + timestamp0.toLocalDateTime(); + timestamp0.clone(); + infraRequests0.setStartTime(timestamp0); + infraRequests0.setVolumeGroupName("&^pJug .NI><P"); + infraRequests0.setRequestAction(" g)]V!'`TH5O"); + infraRequests0.setServiceInstanceId("DfLF%$Jbfi.Q31<"); + infraRequests0.getStartTime(); + infraRequests0.getStartTime(); + infraRequests0.setAicCloudRegion("sz.!~p3obl/"); + infraRequests0.setClientRequestId("sz.!~p3obl/"); + infraRequests0.setVnfParams((String) null); + infraRequests0.getEndTime(); + infraRequests0.getStartTime(); + infraRequests0.getStartTime(); + infraRequests0.getEndTime(); + infraRequests0.getModifyTime(); + infraRequests0.getModifyTime(); + Timestamp timestamp1 = infraRequests0.getEndTime(); + assertNull(timestamp1); + } + + @Test(timeout = 4000) + public void test002() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + Timestamp timestamp0 = new Timestamp(153L); + Instant instant0 = timestamp0.toInstant(); + Timestamp timestamp1 = Timestamp.from(instant0); + infraRequests0.setStartTime(timestamp1); + Timestamp timestamp2 = infraRequests0.getStartTime(); + assertNotSame(timestamp2, timestamp0); + } + + @Test(timeout = 4000) + public void test003() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + Timestamp timestamp0 = new Timestamp((-1852L)); + infraRequests0.setEndTime(timestamp0); + Timestamp timestamp1 = infraRequests0.getEndTime(); + assertEquals(148000000, timestamp1.getNanos()); + } + + @Test(timeout = 4000) + public void test004() throws Throwable { + System.setCurrentTimeMillis(0L); + InfraRequests infraRequests0 = new InfraRequests((String) null, (String) null); + infraRequests0.setAction(""); + infraRequests0.setLastModifiedBy("et'?MxG"); + infraRequests0.setSource((String) null); + infraRequests0.setRequestStatus("i>Ckz=#\"! &-"); + infraRequests0.setVnfName((String) null); + infraRequests0.setRequestBody(""); + infraRequests0.setProvStatus(""); + infraRequests0.setRequestBody((String) null); + infraRequests0.setAicCloudRegion("m&WTLl(Z@56C"); + infraRequests0.getNetworkId(); + infraRequests0.setNetworkId("zcYzTK3rhfL`Cw"); + infraRequests0.getStartTime(); + System.setCurrentTimeMillis(2579L); + infraRequests0.getModifyTime(); + infraRequests0.getStartTime(); + infraRequests0.setAicCloudRegion("=o7|rLO^"); + infraRequests0.getEndTime(); + infraRequests0.getEndTime(); + infraRequests0.getNetworkId(); + System.setCurrentTimeMillis(0L); + System.setCurrentTimeMillis(0L); + infraRequests0.getStartTime(); + infraRequests0.getSource(); + String string0 = infraRequests0.getNetworkId(); + assertEquals("zcYzTK3rhfL`Cw", string0); + } + + @Test(timeout = 4000) + public void test005() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + Long long0 = new Long(1283L); + infraRequests0.setProvStatus("'4~OJS*DL/lP"); + Long.sum((-978L), 1283L); + infraRequests0.setProgress(long0); + infraRequests0.setServiceInstanceName("'4~OJS*DL/lP"); + infraRequests0.getSource(); + infraRequests0.setRequestId(""); + infraRequests0.getSource(); + infraRequests0.setVnfParams((String) null); + infraRequests0.getNetworkId(); + infraRequests0.getEndTime(); + infraRequests0.getNetworkId(); + infraRequests0.getModifyTime(); + infraRequests0.getProgress(); + infraRequests0.getSource(); + infraRequests0.getModifyTime(); + infraRequests0.getNetworkId(); + infraRequests0.getSource(); + infraRequests0.getModifyTime(); + infraRequests0.getEndTime(); + infraRequests0.getEndTime(); + infraRequests0.getModifyTime(); + infraRequests0.getProgress(); + infraRequests0.getProgress(); + Timestamp timestamp0 = infraRequests0.getStartTime(); + assertNull(timestamp0); + } + + @Test(timeout = 4000) + public void test006() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getEndTime(); + infraRequests0.setVfModuleModelName(""); + infraRequests0.setVfModuleId(""); + infraRequests0.getStartTime(); + infraRequests0.getVfModuleModelName(); + infraRequests0.getSource(); + infraRequests0.setVfModuleModelName(""); + infraRequests0.setAction(""); + infraRequests0.setVnfType("32ex<U{"); + infraRequests0.setVfModuleId("~!_Y!cPw*c_>H$"); + infraRequests0.getModifyTime(); + System.setCurrentTimeMillis(0L); + infraRequests0.getEndTime(); + infraRequests0.setRequestStatus(""); + infraRequests0.setServiceInstanceName(""); + infraRequests0.getStartTime(); + infraRequests0.getVfModuleModelName(); + infraRequests0.setVolumeGroupName(""); + infraRequests0.getProgress(); + infraRequests0.setProvStatus(""); + System.setCurrentTimeMillis(0L); + infraRequests0.getStartTime(); + System.setCurrentTimeMillis(0L); + infraRequests0.getVfModuleModelName(); + infraRequests0.getNetworkId(); + infraRequests0.getNetworkId(); + infraRequests0.getVfModuleModelName(); + System.setCurrentTimeMillis(0L); + infraRequests0.getProgress(); + Timestamp timestamp0 = infraRequests0.getStartTime(); + assertNull(timestamp0); + } + + @Test(timeout = 4000) + public void test007() throws Throwable { + System.setCurrentTimeMillis((-2047L)); + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVolumeGroupName("k*}2I)_;C'i,[i>aRNU"); + infraRequests0.setSource("%az="); + infraRequests0.getModifyTime(); + infraRequests0.setRequestAction(""); + infraRequests0.setClientRequestId(""); + infraRequests0.setAicNodeClli(""); + infraRequests0.setCallBackUrl(""); + infraRequests0.setAction(""); + infraRequests0.getNetworkId(); + infraRequests0.getNetworkId(); + infraRequests0.getProgress(); + infraRequests0.getProgress(); + infraRequests0.getNetworkId(); + infraRequests0.getProgress(); + infraRequests0.getModifyTime(); + infraRequests0.setRequestScope("URuw\"b-"); + infraRequests0.setNetworkName(""); + infraRequests0.getStartTime(); + infraRequests0.getAicNodeClli(); + infraRequests0.getProgress(); + infraRequests0.setCallBackUrl(""); + infraRequests0.getEndTime(); + infraRequests0.setVnfId(""); + infraRequests0.getProgress(); + infraRequests0.getNetworkId(); + Long long0 = infraRequests0.getProgress(); + assertNull(long0); + } + + @Test(timeout = 4000) + public void test008() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests((String) null, (String) null); + infraRequests0.setClientRequestId((String) null); + infraRequests0.setVfModuleModelName((String) null); + Long long0 = new Long((-43L)); + Long.compare((-1L), 0L); + Long.compare(819L, (-43L)); + infraRequests0.setProgress(long0); + infraRequests0.getModifyTime(); + infraRequests0.getStartTime(); + infraRequests0.setAction(""); + infraRequests0.getSource(); + infraRequests0.getSource(); + infraRequests0.getStartTime(); + infraRequests0.setNetworkId((String) null); + infraRequests0.getNetworkId(); + Long long1 = infraRequests0.getProgress(); + assertEquals((-43L), (long)long1); + } + + @Test(timeout = 4000) + public void test009() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getStartTime(); + infraRequests0.setRequestScope(""); + System.setCurrentTimeMillis(0L); + infraRequests0.setVnfType(""); + infraRequests0.setProvStatus(""); + infraRequests0.setRequestScope("LB1xoi:3Wz.5'5uxZ"); + infraRequests0.setVfModuleId("+x66Ol"); + infraRequests0.setVfModuleModelName("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setVnfOutputs("LB1xoi:3Wz.5'5uxZ"); + infraRequests0.setCorrelator("{%N>'KCKdC"); + infraRequests0.getEndTime(); + infraRequests0.getVfModuleModelName(); + infraRequests0.getSource(); + infraRequests0.getStartTime(); + infraRequests0.getNetworkId(); + infraRequests0.setRequestBody("jBcy6j^"); + infraRequests0.setAaiServiceId("m,{Gy9PQsY5J/aU!uX"); + infraRequests0.setVolumeGroupId(""); + infraRequests0.getEndTime(); + infraRequests0.getEndTime(); + infraRequests0.getVfModuleId(); + infraRequests0.getModifyTime(); + infraRequests0.getEndTime(); + infraRequests0.getModifyTime(); + String string0 = infraRequests0.getSource(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test010() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getVfModuleId(); + infraRequests0.getEndTime(); + infraRequests0.setVfModuleId((String) null); + infraRequests0.setServiceType(""); + infraRequests0.getModifyTime(); + infraRequests0.getAicNodeClli(); + infraRequests0.setAaiServiceId((String) null); + infraRequests0.getVfModuleModelName(); + infraRequests0.getVfModuleId(); + infraRequests0.getEndTime(); + infraRequests0.setVfModuleModelName((String) null); + infraRequests0.getModifyTime(); + infraRequests0.getVfModuleModelName(); + infraRequests0.getEndTime(); + infraRequests0.setVnfName((String) null); + infraRequests0.getVfModuleId(); + infraRequests0.getAicNodeClli(); + infraRequests0.getAicNodeClli(); + infraRequests0.getNetworkId(); + infraRequests0.getVfModuleId(); + infraRequests0.getSource(); + infraRequests0.getAicNodeClli(); + infraRequests0.getSource(); + infraRequests0.getServiceType(); + infraRequests0.getModifyTime(); + String string0 = infraRequests0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test011() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVnfName("s4 -bpK"); + infraRequests0.setLastModifiedBy(""); + infraRequests0.getProgress(); + infraRequests0.getServiceType(); + infraRequests0.setVfModuleName((String) null); + infraRequests0.setVnfName(""); + infraRequests0.setVnfType(""); + infraRequests0.getVfModuleId(); + infraRequests0.setResponseBody(""); + infraRequests0.getStartTime(); + infraRequests0.setStartTime((Timestamp) null); + infraRequests0.setCorrelator(""); + infraRequests0.getVnfType(); + infraRequests0.getNetworkId(); + infraRequests0.setServiceInstanceId(""); + infraRequests0.getProgress(); + infraRequests0.getAicNodeClli(); + infraRequests0.getNetworkId(); + infraRequests0.setCorrelator((String) null); + infraRequests0.getNetworkId(); + infraRequests0.getVnfType(); + infraRequests0.getVfModuleModelName(); + infraRequests0.getAicNodeClli(); + infraRequests0.setVnfName(""); + System.setCurrentTimeMillis((-1L)); + infraRequests0.setProvStatus(""); + infraRequests0.getVfModuleId(); + infraRequests0.getSource(); + infraRequests0.getAicNodeClli(); + String string0 = infraRequests0.getServiceType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test012() throws Throwable { + System.setCurrentTimeMillis(1L); + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setEndTime((Timestamp) null); + infraRequests0.setTenantId(""); + infraRequests0.setRequestStatus(""); + infraRequests0.setClientRequestId(""); + infraRequests0.setAction(""); + infraRequests0.setCorrelator(""); + infraRequests0.setAicNodeClli(""); + infraRequests0.getVnfParams(); + System.setCurrentTimeMillis(1L); + infraRequests0.setVolumeGroupName(""); + infraRequests0.setVfModuleId((String) null); + infraRequests0.setVnfParams(""); + infraRequests0.getSource(); + infraRequests0.getVfModuleModelName(); + infraRequests0.getSource(); + infraRequests0.getVnfParams(); + infraRequests0.getServiceType(); + infraRequests0.setAaiServiceId("i`q1kSghF"); + infraRequests0.setStatusMessage((String) null); + infraRequests0.getProgress(); + infraRequests0.getModifyTime(); + infraRequests0.getVnfType(); + infraRequests0.getProgress(); + infraRequests0.getServiceType(); + String string0 = infraRequests0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test013() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setRequestScope(""); + infraRequests0.setAaiServiceId(")9?S*`\"0>k"); + infraRequests0.getEndTime(); + infraRequests0.setVolumeGroupName(""); + infraRequests0.setServiceInstanceId(""); + infraRequests0.getProgress(); + infraRequests0.getRequestScope(); + Long long0 = infraRequests0.getProgress(); + assertNull(long0); + } + + @Test(timeout = 4000) + public void test014() throws Throwable { + System.setCurrentTimeMillis(3986L); + InfraRequests infraRequests0 = new InfraRequests("", (String) null); + infraRequests0.setVnfName((String) null); + infraRequests0.getResponseBody(); + infraRequests0.setAction((String) null); + infraRequests0.setCallBackUrl("(tW~,tC"); + infraRequests0.setClientRequestId("$Y$nNqJ`e'KL#@v>:"); + infraRequests0.setVolumeGroupId("mSK_k$P)79N/:l"); + infraRequests0.setResponseBody(""); + infraRequests0.setSource("(tW~,tC"); + infraRequests0.setProvStatus((String) null); + infraRequests0.setVfModuleName("9"); + infraRequests0.getServiceType(); + infraRequests0.getVnfParams(); + infraRequests0.getVnfType(); + infraRequests0.getVnfParams(); + infraRequests0.getStartTime(); + infraRequests0.getVnfType(); + infraRequests0.getStartTime(); + infraRequests0.getSource(); + infraRequests0.getVfModuleModelName(); + infraRequests0.getStartTime(); + infraRequests0.getAicNodeClli(); + System.setCurrentTimeMillis((-1622L)); + infraRequests0.getVfModuleModelName(); + String string0 = infraRequests0.getResponseBody(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test015() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("wkT`'", "kMn9?"); + infraRequests0.setVfModuleName(""); + infraRequests0.setNetworkType(""); + infraRequests0.getVfModuleModelName(); + infraRequests0.setProvStatus("kMn9?"); + infraRequests0.getRequestScope(); + infraRequests0.setVfModuleModelName((String) null); + infraRequests0.setAicCloudRegion("wkT`'"); + infraRequests0.setServiceInstanceName("7Stei0W{<@QDoE9~"); + infraRequests0.setRequestAction(""); + infraRequests0.getServiceType(); + infraRequests0.getVnfParams(); + infraRequests0.getAicNodeClli(); + infraRequests0.getRequestScope(); + infraRequests0.getNetworkType(); + infraRequests0.getStartTime(); + infraRequests0.getNetworkType(); + infraRequests0.getStartTime(); + infraRequests0.getRequestAction(); + infraRequests0.setCorrelator("!5"); + infraRequests0.getSource(); + infraRequests0.getServiceType(); + infraRequests0.getVfModuleModelName(); + infraRequests0.getVnfParams(); + infraRequests0.getModifyTime(); + infraRequests0.getVnfParams(); + infraRequests0.getProvStatus(); + infraRequests0.getAicNodeClli(); + infraRequests0.getVfModuleModelName(); + assertEquals("wkT`'", infraRequests0.getRequestId()); + assertEquals("kMn9?", infraRequests0.getAction()); + } + + @Test(timeout = 4000) + public void test016() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", (String) null); + infraRequests0.setRequestId(""); + infraRequests0.setVfModuleId(""); + infraRequests0.setRequestScope(""); + infraRequests0.setVfModuleId(""); + infraRequests0.setSource((String) null); + infraRequests0.setClientRequestId(""); + infraRequests0.setVnfName("3?/m3##"); + infraRequests0.setVfModuleName(""); + infraRequests0.setSource("y [b8^A,yt|auh|y"); + infraRequests0.setRequestScope("y [b8^A,yt|auh|y"); + infraRequests0.setClientRequestId(""); + infraRequests0.getEndTime(); + infraRequests0.setVolumeGroupName("r7szQIK?~Q"); + infraRequests0.getRequestAction(); + infraRequests0.getVfModuleModelName(); + infraRequests0.setServiceInstanceId("y [b8^A,yt|auh|y"); + infraRequests0.getServiceType(); + infraRequests0.getNetworkType(); + System.setCurrentTimeMillis(3509L); + infraRequests0.getClientRequestId(); + infraRequests0.setTenantId((String) null); + infraRequests0.getVfModuleModelName(); + infraRequests0.getVnfType(); + infraRequests0.getVnfParams(); + infraRequests0.getServiceType(); + infraRequests0.getVnfParams(); + String string0 = infraRequests0.getVfModuleModelName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test017() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + LocalDateTime localDateTime0 = MockLocalDateTime.of(264, 1, 1, 0, 1, 0); + Timestamp timestamp0 = Timestamp.valueOf(localDateTime0); + infraRequests0.setEndTime(timestamp0); + infraRequests0.setServiceInstanceId("TmMT"); + infraRequests0.setServiceInstanceName(""); + infraRequests0.setAicNodeClli(";"); + infraRequests0.setAicCloudRegion(""); + infraRequests0.setAction(""); + infraRequests0.setServiceInstanceId(""); + infraRequests0.setAaiServiceId(""); + infraRequests0.getVnfType(); + infraRequests0.getSource(); + infraRequests0.getVnfParams(); + infraRequests0.getVfModuleId(); + infraRequests0.getStartTime(); + infraRequests0.getProvStatus(); + infraRequests0.getServiceType(); + infraRequests0.getProvStatus(); + infraRequests0.getServiceType(); + System.setCurrentTimeMillis(1); + infraRequests0.setVnfParams((String) null); + infraRequests0.getServiceInstanceName(); + infraRequests0.getEndTime(); + infraRequests0.setAicNodeClli((String) null); + infraRequests0.getNetworkType(); + infraRequests0.getEndTime(); + infraRequests0.getRequestScope(); + System.setCurrentTimeMillis(0); + } + + @Test(timeout = 4000) + public void test018() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setCorrelator("nBvp})-N}"); + infraRequests0.setSource("dOe#{Gx#~I(,F)0("); + infraRequests0.setVnfId(""); + infraRequests0.getVolumeGroupName(); + infraRequests0.getCorrelator(); + infraRequests0.getModifyTime(); + infraRequests0.getRequestScope(); + infraRequests0.getVfModuleModelName(); + String string0 = infraRequests0.getProvStatus(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test019() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("HY7\"yA%CG", ""); + infraRequests0.setVnfType(""); + infraRequests0.setAicNodeClli(""); + infraRequests0.setNetworkId("HY7\"yA%CG"); + infraRequests0.setAicNodeClli(""); + infraRequests0.getProgress(); + infraRequests0.setProgress((Long) null); + infraRequests0.setServiceType(""); + infraRequests0.setLastModifiedBy(""); + infraRequests0.getRequestScope(); + infraRequests0.getProvStatus(); + infraRequests0.setVolumeGroupName((String) null); + infraRequests0.getLastModifiedBy(); + infraRequests0.getProvStatus(); + infraRequests0.setAicCloudRegion(""); + infraRequests0.getRequestScope(); + infraRequests0.getProvStatus(); + assertEquals("HY7\"yA%CG", infraRequests0.getRequestId()); + assertEquals("", infraRequests0.getAction()); + } + + @Test(timeout = 4000) + public void test020() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setRequestBody(""); + infraRequests0.setTenantId(""); + infraRequests0.setRequestType(""); + infraRequests0.setCallBackUrl(""); + infraRequests0.setRequestAction(">Q'MsuT`)ThP6"); + infraRequests0.setVfModuleId(""); + infraRequests0.setResponseBody(""); + infraRequests0.getVnfName(); + infraRequests0.getProgress(); + infraRequests0.setVnfName(""); + infraRequests0.getVfModuleModelName(); + infraRequests0.setClientRequestId((String) null); + infraRequests0.getServiceType(); + infraRequests0.getVfModuleId(); + infraRequests0.getVnfName(); + infraRequests0.getVfModuleModelName(); + infraRequests0.getNetworkId(); + infraRequests0.getRequestAction(); + infraRequests0.getNetworkType(); + infraRequests0.getCorrelator(); + infraRequests0.setLastModifiedBy((String) null); + infraRequests0.getCorrelator(); + infraRequests0.getNetworkId(); + infraRequests0.getTenantId(); + infraRequests0.getVolumeGroupName(); + String string0 = infraRequests0.getVolumeGroupName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test021() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getNetworkId(); + infraRequests0.setRequestAction((String) null); + Long long0 = new Long((-965L)); + infraRequests0.setProgress(long0); + infraRequests0.getSource(); + infraRequests0.setNetworkType("5K\u0002}.V3dm%yU_&r"); + infraRequests0.setVnfOutputs("5K\u0002}.V3dm%yU_&r"); + String string0 = infraRequests0.getVnfOutputs(); + assertEquals("5K\u0002}.V3dm%yU_&r", string0); + } + + @Test(timeout = 4000) + public void test022() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setRequestBody(""); + infraRequests0.setNetworkName("K|it"); + infraRequests0.setAction("hcA}j,"); + infraRequests0.setLastModifiedBy(""); + infraRequests0.getCallBackUrl(); + infraRequests0.getVfModuleId(); + infraRequests0.getRequestScope(); + String string0 = infraRequests0.getRequestBody(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test023() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("0", "0"); + infraRequests0.setNetworkType("0"); + infraRequests0.getStatusMessage(); + infraRequests0.getProvStatus(); + infraRequests0.getVnfParams(); + infraRequests0.getStatusMessage(); + infraRequests0.setVfModuleName((String) null); + infraRequests0.getResponseBody(); + infraRequests0.setStatusMessage("[3aRfG;XuP"); + infraRequests0.setVolumeGroupId((String) null); + infraRequests0.setAction(""); + infraRequests0.getEndTime(); + infraRequests0.getStartTime(); + infraRequests0.getServiceType(); + infraRequests0.getResponseBody(); + infraRequests0.getVfModuleId(); + infraRequests0.getServiceInstanceName(); + infraRequests0.getEndTime(); + infraRequests0.getNetworkType(); + infraRequests0.getVnfOutputs(); + infraRequests0.getVnfType(); + infraRequests0.getRequestScope(); + infraRequests0.getStartTime(); + infraRequests0.getRequestAction(); + infraRequests0.getProgress(); + infraRequests0.getLastModifiedBy(); + infraRequests0.getStatusMessage(); + infraRequests0.getVolumeGroupName(); + infraRequests0.getVnfName(); + System.setCurrentTimeMillis(1480L); + String string0 = infraRequests0.getVnfName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test024() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setRequestType("2AfD]In8p;DK-]O`8}s"); + infraRequests0.getClientRequestId(); + infraRequests0.setClientRequestId((String) null); + infraRequests0.setResponseBody("2AfD]In8p;DK-]O`8}s"); + infraRequests0.setAaiServiceId("2AfD]In8p;DK-]O`8}s"); + infraRequests0.setRequestBody((String) null); + infraRequests0.setVfModuleId(""); + Timestamp timestamp0 = new Timestamp(0L); + infraRequests0.setEndTime(timestamp0); + infraRequests0.setVfModuleModelName((String) null); + infraRequests0.getAicNodeClli(); + infraRequests0.getAicNodeClli(); + infraRequests0.setVnfName("}}xiNsZQ:D73z4dha"); + Clock clock0 = MockClock.systemDefaultZone(); + Timestamp timestamp1 = infraRequests0.getEndTime(); + timestamp0.before(timestamp1); + Instant instant0 = MockInstant.now(clock0); + Instant instant1 = MockInstant.minusNanos(instant0, (-290L)); + ChronoUnit chronoUnit0 = ChronoUnit.DECADES; + // Undeclared exception! + try { + MockInstant.plus(instant1, 0L, (TemporalUnit) chronoUnit0); + fail("Expecting exception: UnsupportedTemporalTypeException"); + + } catch(UnsupportedTemporalTypeException e) { + // + // Unsupported unit: Decades + // + verifyException("java.time.Instant", e); + } + } + + @Test(timeout = 4000) + public void test025() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getTenantId(); + infraRequests0.setServiceType(""); + infraRequests0.getModifyTime(); + infraRequests0.setModifyTime((Timestamp) null); + infraRequests0.getClientRequestId(); + infraRequests0.setVolumeGroupId((String) null); + infraRequests0.getRequestId(); + infraRequests0.getVfModuleName(); + infraRequests0.getServiceInstanceName(); + infraRequests0.setNetworkId(""); + infraRequests0.setNetworkName((String) null); + infraRequests0.getResponseBody(); + infraRequests0.getNetworkId(); + Timestamp timestamp0 = infraRequests0.getModifyTime(); + assertNull(timestamp0); + } + + @Test(timeout = 4000) + public void test026() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getVolumeGroupName(); + infraRequests0.setResponseBody(")Y?y`MhJSG>i"); + infraRequests0.setVfModuleId((String) null); + infraRequests0.setRequestStatus((String) null); + infraRequests0.getResponseBody(); + infraRequests0.setVnfOutputs("q+6_~:+S5N.3.Lge\""); + infraRequests0.setVfModuleModelName("q+6_~:+S5N.3.Lge\""); + infraRequests0.setSource("q+6_~:+S5N.3.Lge\""); + infraRequests0.setServiceInstanceName(")Y?y`MhJSG>i"); + infraRequests0.getServiceType(); + infraRequests0.getModifyTime(); + infraRequests0.setNetworkName("YUNs`H&7xu@i2P/1_"); + InfraRequests infraRequests1 = new InfraRequests(); + infraRequests1.setVfModuleModelName(""); + infraRequests1.setRequestStatus("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setRequestId("6A'N2)N@dyHD|PV"); + infraRequests1.getNetworkType(); + infraRequests0.getNetworkName(); + infraRequests1.getLastModifiedBy(); + infraRequests0.getRequestBody(); + infraRequests1.setServiceInstanceId(""); + infraRequests0.setServiceInstanceName(":fK$0REpUY"); + assertEquals(")Y?y`MhJSG>i", infraRequests0.getResponseBody()); + } + + @Test(timeout = 4000) + public void test027() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setServiceType("i3b%q%2jvX"); + infraRequests0.getServiceType(); + infraRequests0.setClientRequestId("i3b%q%2jvX"); + infraRequests0.setVnfId(""); + infraRequests0.getSource(); + ChronoUnit chronoUnit0 = ChronoUnit.NANOS; + // Undeclared exception! + try { + MockInstant.plus((Instant) null, (-1L), (TemporalUnit) chronoUnit0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.evosuite.runtime.mock.java.time.MockInstant", e); + } + } + + @Test(timeout = 4000) + public void test028() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("org.openecomp.mso.requestsdb.InfraRequests", ""); + infraRequests0.setRequestType(""); + infraRequests0.setRequestBody("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setAction(""); + infraRequests0.getVnfParams(); + InfraRequests infraRequests1 = new InfraRequests(); + infraRequests0.setVfModuleName((String) null); + infraRequests0.getVfModuleName(); + infraRequests1.setVfModuleName("?ynVFwCW]h"); + infraRequests0.setVnfParams(""); + infraRequests1.setResponseBody((String) null); + infraRequests1.setLastModifiedBy((String) null); + infraRequests1.setClientRequestId("oCb )W1D3x;e}QaJ"); + infraRequests0.setServiceInstanceName(""); + infraRequests0.getVfModuleId(); + infraRequests1.getClientRequestId(); + infraRequests1.getModifyTime(); + infraRequests0.setSource("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests1.setVfModuleName("org.openecomp.mso.requestsdb.InfraRequests"); + String string0 = infraRequests1.getAaiServiceId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test029() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setServiceType(""); + infraRequests0.setVfModuleModelName("QE|"); + infraRequests0.setStatusMessage("/`_aGH,(,:O9e'"); + infraRequests0.setStatusMessage("/`_aGH,(,:O9e'"); + infraRequests0.setLastModifiedBy((String) null); + infraRequests0.setServiceInstanceName("QE|"); + infraRequests0.setCallBackUrl("QE|"); + infraRequests0.setCallBackUrl("QE|"); + Long long0 = new Long(0L); + Long.getLong("/`_aGH,(,:O9e'", 0L); + Long.getLong("QE|", (Long) null); + infraRequests0.setProgress(long0); + infraRequests0.setVfModuleName("QE|"); + infraRequests0.setSource(""); + infraRequests0.setVfModuleId("QE|"); + infraRequests0.setVolumeGroupId(""); + infraRequests0.getTenantId(); + infraRequests0.getClientRequestId(); + String string0 = infraRequests0.getServiceInstanceName(); + assertEquals("QE|", string0); + } + + @Test(timeout = 4000) + public void test030() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getResponseBody(); + infraRequests0.setServiceInstanceName((String) null); + InfraRequests infraRequests1 = new InfraRequests((String) null, ";*MXO3Cx^<r~)I#t"); + infraRequests1.setSource("H>f%;>>.T7]h8?L]*"); + infraRequests1.setRequestScope((String) null); + infraRequests1.setNetworkName(""); + infraRequests0.setRequestAction("FLknU%"); + infraRequests1.setCallBackUrl(""); + InfraRequests infraRequests2 = new InfraRequests(";*MXO3Cx^<r~)I#t", ";*MXO3Cx^<r~)I#t"); + infraRequests2.setCorrelator(""); + infraRequests1.getNetworkName(); + infraRequests0.setRequestBody((String) null); + assertNull(infraRequests0.getRequestScope()); + } + + @Test(timeout = 4000) + public void test031() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getNetworkId(); + infraRequests0.setVfModuleModelName((String) null); + infraRequests0.setNetworkType((String) null); + infraRequests0.setAction((String) null); + infraRequests0.setVfModuleModelName("d@?@e`uVahW|y"); + infraRequests0.setVolumeGroupName("$1"); + infraRequests0.getResponseBody(); + infraRequests0.getVnfParams(); + infraRequests0.getRequestAction(); + infraRequests0.setClientRequestId("N] J}ueWB9R)u"); + infraRequests0.getVfModuleId(); + infraRequests0.getNetworkType(); + infraRequests0.getModifyTime(); + infraRequests0.getNetworkId(); + infraRequests0.getModifyTime(); + infraRequests0.getVolumeGroupName(); + infraRequests0.getAicNodeClli(); + infraRequests0.setVnfOutputs("d@?@e`uVahW|y"); + infraRequests0.getVfModuleModelName(); + infraRequests0.getRequestAction(); + infraRequests0.getRequestAction(); + infraRequests0.setVnfId("2dCOj."); + System.setCurrentTimeMillis(509L); + infraRequests0.getNetworkId(); + infraRequests0.getProgress(); + infraRequests0.getVfModuleId(); + infraRequests0.getVfModuleId(); + infraRequests0.getProgress(); + String string0 = infraRequests0.getAicNodeClli(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test032() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVfModuleName(""); + infraRequests0.setVfModuleModelName("1Hr"); + infraRequests0.setNetworkType(""); + infraRequests0.setCallBackUrl(""); + infraRequests0.setSource("[@Z"); + infraRequests0.setRequestBody(">!b;YwVyr(8"); + infraRequests0.setRequestBody("[@Z"); + infraRequests0.setServiceInstanceId("1Hr"); + infraRequests0.setClientRequestId((String) null); + infraRequests0.setRequestAction(">!b;YwVyr(8"); + infraRequests0.setVnfName(">!b;YwVyr(8"); + infraRequests0.setAicCloudRegion("[@Z"); + infraRequests0.setNetworkId("OU%$T'av6Ca'8.%"); + infraRequests0.setCallBackUrl("1Hr"); + infraRequests0.setServiceInstanceId(""); + infraRequests0.setNetworkName("OU%$T'av6Ca'8.%"); + infraRequests0.setNetworkName("gB~~7^R}E0VY*jjv"); + infraRequests0.getSource(); + infraRequests0.getLastModifiedBy(); + infraRequests0.getVfModuleName(); + String string0 = infraRequests0.getRequestStatus(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test033() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", "c~]g[*"); + infraRequests0.setServiceType(""); + infraRequests0.setAaiServiceId("c~]g[*"); + infraRequests0.setVnfType("8u=!kEh2}E<wR-=T3Eu"); + infraRequests0.setAicNodeClli("c~]g[*"); + infraRequests0.getVnfType(); + infraRequests0.setVnfName("~x"); + infraRequests0.setVnfOutputs("8u=!kEh2}E<wR-=T3Eu"); + infraRequests0.setServiceType(""); + infraRequests0.setVnfOutputs("CxZIOx,v-"); + infraRequests0.getVfModuleModelName(); + infraRequests0.getAicNodeClli(); + assertEquals("c~]g[*", infraRequests0.getAction()); + + infraRequests0.setAction("Z+$8\"UD&O@G"); + assertEquals("", infraRequests0.getRequestId()); + } + + @Test(timeout = 4000) + public void test034() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + Timestamp timestamp0 = new Timestamp((-2655L)); + infraRequests0.setModifyTime(timestamp0); + Timestamp timestamp1 = infraRequests0.getModifyTime(); + timestamp1.after(timestamp0); + infraRequests0.setStartTime(timestamp1); + infraRequests0.getAaiServiceId(); + infraRequests0.getRequestStatus(); + infraRequests0.setRequestStatus("I1e1@rWiu`h-"); + infraRequests0.setVolumeGroupName("I1e1@rWiu`h-"); + infraRequests0.setAicNodeClli("H/;N:1&TC[5,}"); + String string0 = infraRequests0.getClientRequestId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test035() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setNetworkType("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.getVnfOutputs(); + infraRequests0.getProgress(); + infraRequests0.setClientRequestId((String) null); + infraRequests0.setRequestAction("YN8"); + infraRequests0.setProvStatus(""); + infraRequests0.getServiceInstanceId(); + infraRequests0.getProvStatus(); + infraRequests0.setRequestScope((String) null); + infraRequests0.getAicNodeClli(); + infraRequests0.getRequestScope(); + infraRequests0.getServiceInstanceName(); + infraRequests0.setVnfName((String) null); + infraRequests0.getVolumeGroupName(); + infraRequests0.getTenantId(); + infraRequests0.getNetworkId(); + infraRequests0.setStatusMessage((String) null); + infraRequests0.setTenantId("org.openecomp.mso.requestsdb.InfraRequests"); + // Undeclared exception! + try { + Timestamp.valueOf((String) null); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // null string + // + verifyException("java.sql.Timestamp", e); + } + } + + @Test(timeout = 4000) + public void test036() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getVolumeGroupId(); + infraRequests0.setVnfParams("xeM>h;aPCLLMO/"); + infraRequests0.setAaiServiceId("xeM>h;aPCLLMO/"); + infraRequests0.setProvStatus(""); + infraRequests0.setVfModuleId("xeM>h;aPCLLMO/"); + infraRequests0.setVnfOutputs(""); + infraRequests0.setAaiServiceId((String) null); + infraRequests0.setClientRequestId("S|%I {=}otjRfuQa8Ab"); + infraRequests0.setRequestBody("S|%I {=}otjRfuQa8Ab"); + infraRequests0.setModifyTime((Timestamp) null); + infraRequests0.getRequestBody(); + infraRequests0.setAaiServiceId(""); + infraRequests0.setRequestId("4_X\":Ety|S,O-RObu"); + infraRequests0.getCorrelator(); + infraRequests0.setVnfOutputs("%~+Mc"); + infraRequests0.getVolumeGroupId(); + infraRequests0.setVnfId(""); + assertNull(infraRequests0.getStatusMessage()); + } + + @Test(timeout = 4000) + public void test037() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("org.openecomp.mso.requestsdb.InfraRequests", "YpJ&"); + infraRequests0.setRequestType(""); + infraRequests0.setSource("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.getNetworkId(); + infraRequests0.getSource(); + infraRequests0.setVfModuleName("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setRequestType((String) null); + infraRequests0.getStatusMessage(); + infraRequests0.getVolumeGroupName(); + infraRequests0.getVnfName(); + infraRequests0.getModifyTime(); + MockDate mockDate0 = new MockDate((-1949L)); + Instant instant0 = mockDate0.toInstant(); + Instant instant1 = MockInstant.plusSeconds(instant0, (-1949L)); + Date.from(instant1); + infraRequests0.getRequestBody(); + infraRequests0.getNetworkId(); + infraRequests0.setModifyTime((Timestamp) null); + infraRequests0.getEndTime(); + infraRequests0.getProvStatus(); + infraRequests0.getRequestAction(); + infraRequests0.getVfModuleName(); + infraRequests0.getRequestAction(); + assertEquals("YpJ&", infraRequests0.getAction()); + assertEquals("org.openecomp.mso.requestsdb.InfraRequests", infraRequests0.getRequestId()); + } + + @Test(timeout = 4000) + public void test038() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setAicCloudRegion((String) null); + infraRequests0.setRequestType("_P-9"); + infraRequests0.getRequestBody(); + infraRequests0.setRequestStatus(""); + infraRequests0.setCorrelator(".3!"); + infraRequests0.setRequestId((String) null); + String string0 = infraRequests0.getRequestType(); + assertEquals("_P-9", string0); + } + + @Test(timeout = 4000) + public void test039() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setAaiServiceId(""); + infraRequests0.setCallBackUrl(""); + infraRequests0.setVnfOutputs("]8N<"); + infraRequests0.setVfModuleId(""); + infraRequests0.setCorrelator("]8N<"); + infraRequests0.setResponseBody(""); + infraRequests0.setNetworkType("]8N<"); + infraRequests0.getProgress(); + infraRequests0.setCallBackUrl(""); + infraRequests0.getCallBackUrl(); + infraRequests0.setServiceType("]8N<"); + infraRequests0.getVnfId(); + infraRequests0.setRequestAction(""); + infraRequests0.setVnfName(""); + infraRequests0.setVnfName("x'+i.S`"); + infraRequests0.getTenantId(); + infraRequests0.getAicCloudRegion(); + infraRequests0.getTenantId(); + infraRequests0.setStartTime((Timestamp) null); + infraRequests0.setRequestId("c"); + infraRequests0.getRequestType(); + infraRequests0.getEndTime(); + infraRequests0.setModifyTime((Timestamp) null); + String string0 = infraRequests0.getVnfName(); + assertEquals("x'+i.S`", string0); + } + + @Test(timeout = 4000) + public void test040() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setNetworkId("8FcIWeVboHbH"); + infraRequests0.setVnfId(""); + infraRequests0.setStatusMessage(""); + infraRequests0.getClientRequestId(); + infraRequests0.setNetworkName((String) null); + infraRequests0.setVnfName((String) null); + infraRequests0.setCallBackUrl("sK9}!C'50J,"); + infraRequests0.setVolumeGroupId("oC"); + infraRequests0.getVnfOutputs(); + infraRequests0.setVnfName("sK9}!C'50J,"); + infraRequests0.setRequestScope("sK9}!C'50J,"); + infraRequests0.getRequestAction(); + infraRequests0.setVnfParams("oC"); + infraRequests0.getVolumeGroupName(); + infraRequests0.setResponseBody((String) null); + infraRequests0.setNetworkId((String) null); + infraRequests0.setProvStatus(""); + infraRequests0.setAicNodeClli(""); + infraRequests0.getAaiServiceId(); + infraRequests0.getCallBackUrl(); + infraRequests0.getResponseBody(); + infraRequests0.setAaiServiceId((String) null); + infraRequests0.getResponseBody(); + infraRequests0.getEndTime(); + infraRequests0.setModifyTime((Timestamp) null); + infraRequests0.getServiceType(); + infraRequests0.setResponseBody(""); + infraRequests0.getServiceInstanceId(); + infraRequests0.setRequestBody("J2E*wkiH'm}"); + assertEquals("sK9}!C'50J,", infraRequests0.getCallBackUrl()); + } + + @Test(timeout = 4000) + public void test041() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setRequestStatus("gUu8 g"); + infraRequests0.setClientRequestId("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setVnfOutputs(""); + infraRequests0.setResponseBody(""); + infraRequests0.setVnfId(""); + infraRequests0.setAaiServiceId("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setAicNodeClli("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setVnfParams("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setResponseBody(""); + infraRequests0.getModifyTime(); + infraRequests0.getVnfOutputs(); + infraRequests0.getRequestStatus(); + infraRequests0.setVfModuleId("GrYS{|<Q&Zg22qy+qi"); + infraRequests0.setStartTime((Timestamp) null); + infraRequests0.getVnfOutputs(); + String string0 = infraRequests0.getRequestAction(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test042() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setServiceInstanceId((String) null); + infraRequests0.setAction("niZk9/S^^Ok_H^a{"); + infraRequests0.setVfModuleId("niZk9/S^^Ok_H^a{"); + infraRequests0.setVolumeGroupId(""); + infraRequests0.setNetworkId(""); + infraRequests0.setVnfId(""); + infraRequests0.setRequestType("?_I%o"); + infraRequests0.setProvStatus("niZk9/S^^Ok_H^a{"); + infraRequests0.setCallBackUrl(""); + infraRequests0.setServiceInstanceName("XA&Ybqzx!ro6hEU"); + infraRequests0.setLastModifiedBy(""); + infraRequests0.setRequestId(""); + infraRequests0.getRequestScope(); + infraRequests0.getNetworkName(); + infraRequests0.getVnfId(); + infraRequests0.setAaiServiceId(""); + infraRequests0.setTenantId("XA&Ybqzx!ro6hEU"); + infraRequests0.setVolumeGroupId("{O)c"); + infraRequests0.getAction(); + infraRequests0.getVolumeGroupName(); + infraRequests0.getTenantId(); + infraRequests0.setServiceInstanceId(""); + assertNull(infraRequests0.getNetworkType()); + } + + @Test(timeout = 4000) + public void test043() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setTenantId(""); + infraRequests0.setNetworkName(""); + infraRequests0.setAction(""); + Long long0 = new Long(210L); + Long.compare(1164L, 210L); + infraRequests0.setProgress(long0); + infraRequests0.setVfModuleName(""); + Timestamp timestamp0 = new Timestamp(0L); + timestamp0.toInstant(); + timestamp0.setTime(210L); + Instant instant0 = MockInstant.ofEpochMilli(210L); + timestamp0.toLocalDateTime(); + Date.from(instant0); + infraRequests0.setModifyTime(timestamp0); + infraRequests0.setAicCloudRegion("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setRequestAction("qa^[z3j"); + infraRequests0.setVnfType(""); + infraRequests0.getEndTime(); + infraRequests0.setVnfId("wI"); + infraRequests0.getAicCloudRegion(); + infraRequests0.setServiceType(""); + infraRequests0.getAction(); + Timestamp timestamp1 = infraRequests0.getStartTime(); + assertNull(timestamp1); + } + + @Test(timeout = 4000) + public void test044() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("y_J8g=Q8E|gns?USs", "~6yl5nFR7N_I'Tv@."); + infraRequests0.setCallBackUrl("_w^p*-dH4_6v"); + infraRequests0.setVolumeGroupName("y_J8g=Q8E|gns?USs"); + String string0 = infraRequests0.getAction(); + assertEquals("~6yl5nFR7N_I'Tv@.", string0); + + InfraRequests infraRequests1 = new InfraRequests("S?cD1SU", ""); + assertEquals("S?cD1SU", infraRequests1.getRequestId()); + } + + @Test(timeout = 4000) + public void test045() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVolumeGroupName(""); + infraRequests0.setServiceInstanceName(""); + infraRequests0.setVfModuleName(""); + infraRequests0.setStatusMessage(""); + infraRequests0.setVnfName("GG-<o?t l"); + infraRequests0.setVnfName(""); + infraRequests0.setRequestBody(""); + infraRequests0.setCallBackUrl(""); + infraRequests0.setRequestAction(""); + infraRequests0.setVnfType(""); + infraRequests0.setVnfId(""); + infraRequests0.setServiceInstanceId("{CyVx7 >*vO|"); + infraRequests0.setVnfId(""); + infraRequests0.getProvStatus(); + infraRequests0.setProvStatus("{CyVx7 >*vO|"); + infraRequests0.setAicNodeClli("?g9!S#sMQWI4rg"); + infraRequests0.setVnfParams(""); + infraRequests0.setRequestAction("GG-<o?t l"); + infraRequests0.getRequestType(); + infraRequests0.getVolumeGroupName(); + infraRequests0.getRequestAction(); + infraRequests0.getRequestStatus(); + InfraRequests infraRequests1 = new InfraRequests(); + String string0 = infraRequests1.getServiceInstanceId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test046() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setVnfName(""); + infraRequests0.setServiceInstanceId(""); + infraRequests0.setVolumeGroupId(""); + infraRequests0.setNetworkId("?"); + infraRequests0.setVnfName(""); + infraRequests0.setServiceType(""); + infraRequests0.setSource(""); + infraRequests0.getRequestType(); + InfraRequests infraRequests1 = new InfraRequests(); + infraRequests1.setVolumeGroupName(")Na<;z"); + infraRequests1.setRequestAction(""); + infraRequests1.getAicNodeClli(); + infraRequests1.setResponseBody((String) null); + infraRequests1.setVnfType((String) null); + infraRequests1.getVnfName(); + infraRequests1.getVnfType(); + infraRequests0.getServiceInstanceId(); + infraRequests0.setRequestType(""); + infraRequests1.getVnfName(); + infraRequests0.getRequestBody(); + infraRequests1.getVnfType(); + infraRequests1.setRequestAction("Yy"); + infraRequests0.setVnfParams("DnrZ78}s"); + infraRequests0.setServiceInstanceId("]V55Aq\u0003(z<Ct92L`F"); + infraRequests1.setVfModuleName((String) null); + assertNull(infraRequests1.getNetworkId()); + } + + @Test(timeout = 4000) + public void test047() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.getAction(); + infraRequests0.setVnfName(""); + infraRequests0.getNetworkType(); + infraRequests0.getVnfParams(); + infraRequests0.setLastModifiedBy((String) null); + String string0 = infraRequests0.getAaiServiceId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test048() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setNetworkType(""); + infraRequests0.setStatusMessage(""); + infraRequests0.setRequestAction(""); + infraRequests0.setSource(""); + infraRequests0.setVnfId((String) null); + infraRequests0.setLastModifiedBy((String) null); + infraRequests0.setVolumeGroupId((String) null); + infraRequests0.setRequestScope(""); + infraRequests0.getServiceType(); + infraRequests0.setRequestBody((String) null); + infraRequests0.getProgress(); + infraRequests0.setVnfType((String) null); + infraRequests0.setSource((String) null); + infraRequests0.getVfModuleModelName(); + infraRequests0.getStatusMessage(); + infraRequests0.setResponseBody(""); + infraRequests0.setRequestStatus((String) null); + infraRequests0.getAicCloudRegion(); + Timestamp timestamp0 = new Timestamp(2519L); + infraRequests0.setEndTime(timestamp0); + String string0 = infraRequests0.getRequestBody(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test049() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("$V/<$XAp+o>Im\"*", "$V/<$XAp+o>Im\"*"); + infraRequests0.setNetworkName("$V/<$XAp+o>Im\"*"); + infraRequests0.setVnfName((String) null); + infraRequests0.setVfModuleId(""); + infraRequests0.getServiceInstanceName(); + infraRequests0.setAaiServiceId(""); + infraRequests0.setRequestScope(""); + infraRequests0.getAaiServiceId(); + infraRequests0.getModifyTime(); + infraRequests0.setNetworkName((String) null); + infraRequests0.setSource(""); + infraRequests0.getRequestBody(); + infraRequests0.setVnfType(""); + infraRequests0.setStatusMessage(""); + assertNull(infraRequests0.getVolumeGroupId()); + } + + @Test(timeout = 4000) + public void test050() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setRequestStatus(""); + infraRequests0.getServiceInstanceName(); + infraRequests0.setRequestBody((String) null); + infraRequests0.getAction(); + infraRequests0.setVnfParams(""); + infraRequests0.setAction((String) null); + infraRequests0.getSource(); + infraRequests0.getAicCloudRegion(); + infraRequests0.getRequestType(); + infraRequests0.getClientRequestId(); + infraRequests0.getServiceInstanceId(); + infraRequests0.setResponseBody(""); + infraRequests0.getVolumeGroupId(); + infraRequests0.getRequestStatus(); + infraRequests0.getRequestScope(); + infraRequests0.setAicCloudRegion(""); + Long long0 = new Long(0L); + Long.getLong("TQRm 6Q}I>x7UHTd!cH"); + // Undeclared exception! + try { + Long.remainderUnsigned((-1L), 0L); + fail("Expecting exception: ArithmeticException"); + + } catch(ArithmeticException e) { + // + // BigInteger divide by zero + // + verifyException("java.math.MutableBigInteger", e); + } + } + + @Test(timeout = 4000) + public void test051() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setProvStatus(""); + infraRequests0.setClientRequestId(""); + infraRequests0.setVnfType("BJ@B"); + infraRequests0.setProvStatus(""); + infraRequests0.setRequestType(""); + infraRequests0.setAaiServiceId("k^;d!:UH+Z"); + infraRequests0.setRequestType(""); + infraRequests0.setTenantId(""); + infraRequests0.getCallBackUrl(); + InfraRequests infraRequests1 = new InfraRequests(); + infraRequests1.setVnfName("C,,\"N"); + infraRequests0.setVnfParams((String) null); + InfraRequests infraRequests2 = new InfraRequests("", ""); + infraRequests1.setVolumeGroupId(""); + infraRequests2.setTenantId("k^;d!:UH+Z"); + infraRequests1.setVfModuleName(""); + infraRequests2.setVnfType("eDfR<b$HYx"); + infraRequests2.setStatusMessage((String) null); + infraRequests2.setVnfId(""); + infraRequests1.getVolumeGroupId(); + infraRequests0.setAicCloudRegion("BJ@B"); + infraRequests1.setNetworkType(""); + String string0 = infraRequests2.getRequestBody(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test052() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setRequestStatus(""); + infraRequests0.getAicNodeClli(); + infraRequests0.setVolumeGroupName("=xQ^U6%j?LcGU"); + infraRequests0.setVolumeGroupId("~L$J"); + infraRequests0.setVnfOutputs("C"); + infraRequests0.setVnfId("YU GUY+c}[>6+QI83q"); + infraRequests0.setVfModuleName(""); + infraRequests0.getRequestId(); + infraRequests0.setVfModuleModelName("S9h|[hF*h/aEBZ--"); + infraRequests0.setCallBackUrl(""); + infraRequests0.getVnfId(); + infraRequests0.setVnfParams(""); + infraRequests0.getSource(); + infraRequests0.getVnfType(); + InfraRequests infraRequests1 = new InfraRequests("", ""); + infraRequests0.setAaiServiceId("S9h|[hF*h/aEBZ--"); + infraRequests0.setVnfParams(""); + infraRequests1.getRequestBody(); + Month month0 = Month.MARCH; + // Undeclared exception! + try { + MockLocalDateTime.of(1, month0, 1, 1, 0, (-1068)); + fail("Expecting exception: DateTimeException"); + + } catch(DateTimeException e) { + // + // Invalid value for SecondOfMinute (valid values 0 - 59): -1068 + // + verifyException("java.time.temporal.ValueRange", e); + } + } + + @Test(timeout = 4000) + public void test053() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setLastModifiedBy("M+YL/d"); + infraRequests0.setCorrelator("M+YL/d"); + infraRequests0.getLastModifiedBy(); + Month month0 = Month.MAY; + // Undeclared exception! + try { + MockLocalDateTime.of((-574), month0, (-574), (-574), 0); + fail("Expecting exception: DateTimeException"); + + } catch(DateTimeException e) { + // + // Invalid value for DayOfMonth (valid values 1 - 28/31): -574 + // + verifyException("java.time.temporal.ValueRange", e); + } + } + + @Test(timeout = 4000) + public void test054() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setRequestType(""); + infraRequests0.setEndTime((Timestamp) null); + Long long0 = new Long(0L); + Long.compare(0L, 0L); + Long.min(0L, 0L); + infraRequests0.setProvStatus(""); + Long.compare(0L, 0L); + Long.max(0, 0L); + Long.divideUnsigned((-1239L), 561L); + Long.divideUnsigned(0, 31L); + Long.sum(0, 31L); + Long.getLong("}'{?rnxwE~m.*b/<", (-2588L)); + infraRequests0.setProgress(long0); + infraRequests0.setProvStatus(""); + infraRequests0.setVnfParams(""); + infraRequests0.setRequestScope("Gz0xF^~M`"); + infraRequests0.setRequestType(""); + infraRequests0.getAaiServiceId(); + infraRequests0.setCallBackUrl(""); + infraRequests0.setNetworkName(""); + infraRequests0.setRequestStatus("No<5t"); + infraRequests0.setVolumeGroupId(""); + infraRequests0.getEndTime(); + infraRequests0.getProgress(); + String string0 = infraRequests0.getRequestScope(); + assertEquals("Gz0xF^~M`", string0); + } + + @Test(timeout = 4000) + public void test055() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("K66EFm]%0}Hi", "K66EFm]%0}Hi"); + infraRequests0.setVnfName("K66EFm]%0}Hi"); + infraRequests0.getVfModuleModelName(); + infraRequests0.getProgress(); + infraRequests0.setStatusMessage("K66EFm]%0}Hi"); + infraRequests0.setVolumeGroupId((String) null); + infraRequests0.setVolumeGroupName("K66EFm]%0}Hi"); + infraRequests0.setRequestBody("J1UB"); + assertNull(infraRequests0.getResponseBody()); + } + + @Test(timeout = 4000) + public void test056() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", "UwUvkc"); + infraRequests0.setVolumeGroupName("UwUvkc"); + infraRequests0.getVfModuleId(); + ZoneOffset zoneOffset0 = ZoneOffset.MIN; + ZoneOffset zoneOffset1 = (ZoneOffset)ZoneId.ofOffset("", zoneOffset0); + LocalDateTime localDateTime0 = MockLocalDateTime.now((ZoneId) zoneOffset1); + Timestamp timestamp0 = Timestamp.valueOf(localDateTime0); + infraRequests0.setModifyTime(timestamp0); + String string0 = infraRequests0.getRequestId(); + assertEquals("", string0); + + infraRequests0.getCorrelator(); + assertEquals("UwUvkc", infraRequests0.getAction()); + } + + @Test(timeout = 4000) + public void test057() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getVnfName(); + infraRequests0.setAction((String) null); + infraRequests0.getVfModuleName(); + infraRequests0.getNetworkId(); + infraRequests0.getVnfId(); + infraRequests0.setRequestId((String) null); + infraRequests0.setNetworkId((String) null); + infraRequests0.setRequestStatus((String) null); + infraRequests0.setAaiServiceId("wL6o_:EmO)#"); + infraRequests0.setSource((String) null); + infraRequests0.setVnfType("yMKDqB`W?]q"); + infraRequests0.setRequestType((String) null); + infraRequests0.setRequestType(""); + infraRequests0.setRequestScope((String) null); + infraRequests0.getVfModuleName(); + infraRequests0.getVolumeGroupName(); + infraRequests0.getSource(); + infraRequests0.setAicCloudRegion((String) null); + infraRequests0.getSource(); + infraRequests0.getRequestBody(); + infraRequests0.getAaiServiceId(); + infraRequests0.setVnfType((String) null); + String string0 = infraRequests0.getClientRequestId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test058() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setSource("c"); + infraRequests0.setRequestType("*Q}l.yW`VI`i_Q8YL]"); + infraRequests0.setRequestId(""); + infraRequests0.setCorrelator("Y;5!~N0v@x"); + infraRequests0.setNetworkType(""); + infraRequests0.setRequestAction("Y;5!~N0v@x"); + infraRequests0.setLastModifiedBy(""); + infraRequests0.setSource(""); + infraRequests0.setAction(""); + infraRequests0.setTenantId(""); + infraRequests0.setAicCloudRegion(""); + infraRequests0.getRequestScope(); + infraRequests0.setAicNodeClli("Y;5!~N0v@x"); + infraRequests0.getAicCloudRegion(); + infraRequests0.setVnfId("qn|b,'x[1 h*z\"#h"); + assertNull(infraRequests0.getRequestScope()); + } + + @Test(timeout = 4000) + public void test059() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setVnfType("SRPBs.zeX&dK@&XRQj"); + infraRequests0.setCallBackUrl(""); + infraRequests0.setVnfType("%a26GFoFhBEe"); + infraRequests0.setServiceInstanceName((String) null); + infraRequests0.setVfModuleName((String) null); + infraRequests0.getLastModifiedBy(); + infraRequests0.getVnfType(); + String string0 = infraRequests0.getServiceInstanceName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test060() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getEndTime(); + MockDate mockDate0 = new MockDate(965L); + Instant instant0 = mockDate0.toInstant(); + Date.from(instant0); + infraRequests0.setEndTime((Timestamp) null); + infraRequests0.getEndTime(); + infraRequests0.getCorrelator(); + Long long0 = new Long(965L); + infraRequests0.setProgress(long0); + String string0 = infraRequests0.getTenantId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test061() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("qx?)", "qx?)"); + Timestamp timestamp0 = new Timestamp(1390L); + infraRequests0.setStartTime(timestamp0); + infraRequests0.getRequestScope(); + infraRequests0.setVolumeGroupId("qx?)"); + infraRequests0.getVolumeGroupId(); + infraRequests0.setProvStatus((String) null); + timestamp0.setNanos(0); + infraRequests0.setCorrelator(""); + infraRequests0.setVnfOutputs(""); + infraRequests0.setModifyTime(timestamp0); + infraRequests0.getServiceType(); + infraRequests0.setVolumeGroupName("5#&B!D"); + infraRequests0.setVfModuleId("a"); + infraRequests0.setNetworkName("a"); + infraRequests0.getClientRequestId(); + infraRequests0.setRequestScope("qx?)"); + infraRequests0.setVolumeGroupName((String) null); + infraRequests0.getRequestId(); + infraRequests0.setRequestScope("-W#aB<Km<U("); + infraRequests0.getVnfParams(); + infraRequests0.getServiceInstanceName(); + infraRequests0.getCorrelator(); + infraRequests0.setAicNodeClli(""); + infraRequests0.setAction(""); + infraRequests0.setStartTime(timestamp0); + assertNull(infraRequests0.getServiceInstanceName()); + } + + @Test(timeout = 4000) + public void test062() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("N.Z5|phE", ""); + infraRequests0.getClientRequestId(); + assertEquals("N.Z5|phE", infraRequests0.getRequestId()); + assertEquals("", infraRequests0.getAction()); + } + + @Test(timeout = 4000) + public void test063() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", "h."); + infraRequests0.setRequestStatus(""); + infraRequests0.getVnfParams(); + infraRequests0.setNetworkType(""); + assertEquals("h.", infraRequests0.getAction()); + assertEquals("", infraRequests0.getRequestId()); + } + + @Test(timeout = 4000) + public void test064() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setRequestType(""); + infraRequests0.getServiceInstanceId(); + infraRequests0.setVnfParams("`jECciBa[T7M"); + infraRequests0.setRequestBody("4ap}Bu0R,P"); + String string0 = infraRequests0.getRequestType(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test065() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + String string0 = infraRequests0.getAicCloudRegion(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test066() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("org.openecomp.mso.requestsdb.InfraRequests", "org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setRequestStatus(""); + infraRequests0.getResponseBody(); + String string0 = infraRequests0.getRequestAction(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test067() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", (String) null); + infraRequests0.setNetworkId("x^qIF~ru"); + infraRequests0.setServiceInstanceId("IL'5l;^7N^;>0"); + infraRequests0.setLastModifiedBy("h dET"); + infraRequests0.setVfModuleModelName("h dET"); + infraRequests0.setVnfType(""); + infraRequests0.setVfModuleId(""); + infraRequests0.setVfModuleName(""); + infraRequests0.setClientRequestId(""); + infraRequests0.setVnfId("W1Vd+"); + infraRequests0.getVnfName(); + infraRequests0.getNetworkType(); + infraRequests0.getServiceInstanceId(); + infraRequests0.setNetworkName("o-"); + assertNull(infraRequests0.getServiceType()); + } + + @Test(timeout = 4000) + public void test068() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("4E!AHGB", ""); + infraRequests0.getRequestStatus(); + String string0 = infraRequests0.getRequestId(); + assertEquals("4E!AHGB", string0); + + infraRequests0.setRequestScope("F"); + infraRequests0.getVfModuleId(); + infraRequests0.setAicNodeClli("zM4bS"); + infraRequests0.setServiceInstanceName("4E!AHGB"); + infraRequests0.setServiceType(""); + infraRequests0.getVnfType(); + infraRequests0.setAicNodeClli((String) null); + assertEquals("", infraRequests0.getAction()); + } + + @Test(timeout = 4000) + public void test069() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setServiceInstanceName("}<+55QA6'/xzr"); + infraRequests0.getModifyTime(); + infraRequests0.getProvStatus(); + infraRequests0.setVnfOutputs(""); + infraRequests0.getAction(); + infraRequests0.setAicCloudRegion("~W -^JP41(-Dg'.+|p$"); + assertNull(infraRequests0.getServiceType()); + } + + @Test(timeout = 4000) + public void test070() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setAaiServiceId("PJ60cl#^59FDR_>aLqF"); + infraRequests0.setLastModifiedBy("PJ60cl#^59FDR_>aLqF"); + infraRequests0.setCorrelator(""); + infraRequests0.getNetworkType(); + infraRequests0.setAaiServiceId("PJ60cl#^59FDR_>aLqF"); + infraRequests0.getAicNodeClli(); + String string0 = infraRequests0.getVnfType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test071() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(" ?)Ec.r]zDe6pa).i", "LZP&!xPsP /f"); + infraRequests0.setVnfType("5YWNFYfj=3.[9u?N"); + infraRequests0.setSource("LZP&!xPsP /f"); + infraRequests0.setVfModuleName("9"); + infraRequests0.getVnfId(); + Timestamp timestamp0 = new Timestamp(2083L); + LocalDateTime localDateTime0 = timestamp0.toLocalDateTime(); + Timestamp timestamp1 = Timestamp.valueOf(localDateTime0); + infraRequests0.setModifyTime(timestamp1); + infraRequests0.getCorrelator(); + infraRequests0.getEndTime(); + assertEquals(" ?)Ec.r]zDe6pa).i", infraRequests0.getRequestId()); + assertEquals("LZP&!xPsP /f", infraRequests0.getAction()); + } + + @Test(timeout = 4000) + public void test072() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVnfId(""); + String string0 = infraRequests0.getVnfId(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test073() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setAaiServiceId(""); + String string0 = infraRequests0.getServiceType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test074() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVolumeGroupName(""); + String string0 = infraRequests0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test075() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVnfOutputs(""); + infraRequests0.setNetworkId("RU^6`fci#/"); + infraRequests0.getVolumeGroupId(); + infraRequests0.getModifyTime(); + infraRequests0.setVnfType((String) null); + String string0 = infraRequests0.getNetworkName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test076() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + Long long0 = new Long((-1725L)); + infraRequests0.setProgress(long0); + Long long1 = infraRequests0.getProgress(); + assertEquals((-1725L), (long)long1); + } + + @Test(timeout = 4000) + public void test077() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("\"}G", ""); + Timestamp timestamp0 = new Timestamp((-231L)); + infraRequests0.setModifyTime(timestamp0); + infraRequests0.getServiceInstanceId(); + infraRequests0.getVnfName(); + infraRequests0.setVfModuleName("org.openecomp.mso.requestsdb.InfraRequests"); + assertEquals("\"}G", infraRequests0.getRequestId()); + assertEquals("", infraRequests0.getAction()); + } + + @Test(timeout = 4000) + public void test078() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getAicNodeClli(); + infraRequests0.getAicNodeClli(); + String string0 = infraRequests0.getVnfOutputs(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test079() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + InfraRequests infraRequests1 = new InfraRequests(); + infraRequests1.getEndTime(); + infraRequests0.setStartTime((Timestamp) null); + infraRequests0.setTenantId("#X=o2!~:^_LF!mu%"); + assertNull(infraRequests0.getVfModuleModelName()); + } + + @Test(timeout = 4000) + public void test080() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getNetworkId(); + infraRequests0.setRequestAction((String) null); + infraRequests0.getSource(); + infraRequests0.setVnfOutputs("5K\u0002}.V3dm%yU_&r"); + assertNull(infraRequests0.getRequestScope()); + } + + @Test(timeout = 4000) + public void test081() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests((String) null, "org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.setVfModuleName((String) null); + infraRequests0.setServiceType("org.openecomp.mso.requestsdb.InfraRequests"); + infraRequests0.getServiceInstanceId(); + infraRequests0.getRequestId(); + infraRequests0.getVolumeGroupId(); + String string0 = infraRequests0.getNetworkType(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test082() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVolumeGroupId("<LXzO"); + assertNull(infraRequests0.getRequestType()); + } + + @Test(timeout = 4000) + public void test083() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setRequestAction(""); + infraRequests0.setServiceInstanceId(""); + infraRequests0.setAicNodeClli(""); + assertNull(infraRequests0.getServiceType()); + } + + @Test(timeout = 4000) + public void test084() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", "Z={83xlme_b)?zb8"); + infraRequests0.setSource(""); + infraRequests0.getStartTime(); + infraRequests0.getSource(); + infraRequests0.getModifyTime(); + assertEquals("Z={83xlme_b)?zb8", infraRequests0.getAction()); + assertEquals("", infraRequests0.getRequestId()); + } + + @Test(timeout = 4000) + public void test085() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVnfName("d(8}Oc 4|@w8hBNICH"); + infraRequests0.setRequestScope("d(8}Oc 4|@w8hBNICH"); + String string0 = infraRequests0.getAaiServiceId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test086() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setVfModuleId("bS&'!@{LdL0&"); + infraRequests0.setRequestStatus("bS&'!@{LdL0&"); + infraRequests0.setRequestAction((String) null); + infraRequests0.setVfModuleModelName("z"); + infraRequests0.getSource(); + infraRequests0.getServiceInstanceName(); + infraRequests0.getVnfName(); + String string0 = infraRequests0.getAction(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test087() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getRequestType(); + infraRequests0.setVnfOutputs((String) null); + infraRequests0.getCorrelator(); + infraRequests0.setCallBackUrl((String) null); + infraRequests0.setVnfParams(">'n"); + assertNull(infraRequests0.getVfModuleModelName()); + } + + @Test(timeout = 4000) + public void test088() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("I\"as", (String) null); + infraRequests0.getVolumeGroupName(); + infraRequests0.getRequestBody(); + infraRequests0.setTenantId((String) null); + infraRequests0.getResponseBody(); + // Undeclared exception! + try { + MockURI.create((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URI$Parser", e); + } + } + + @Test(timeout = 4000) + public void test089() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", ""); + infraRequests0.setResponseBody(""); + infraRequests0.setRequestId(""); + infraRequests0.setNetworkId(""); + infraRequests0.getEndTime(); + infraRequests0.getVolumeGroupId(); + String string0 = infraRequests0.getStatusMessage(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test090() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests((String) null, "&6KF"); + infraRequests0.setRequestBody("&6KF"); + assertNull(infraRequests0.getRequestScope()); + } + + @Test(timeout = 4000) + public void test091() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("/WcV", "/WcV"); + infraRequests0.setVnfParams("\"w"); + String string0 = infraRequests0.getVnfParams(); + assertEquals("\"w", string0); + } + + @Test(timeout = 4000) + public void test092() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(">?ozK", ">?ozK"); + infraRequests0.setVnfOutputs(">?ozK"); + infraRequests0.setVnfId(""); + infraRequests0.getLastModifiedBy(); + infraRequests0.setAicCloudRegion((String) null); + infraRequests0.setProvStatus(">?ozK"); + infraRequests0.setStatusMessage((String) null); + String string0 = infraRequests0.getRequestScope(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test093() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setEndTime((Timestamp) null); + infraRequests0.setRequestType(""); + assertNull(infraRequests0.getProvStatus()); + } + + @Test(timeout = 4000) + public void test094() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", "Z={83xlme_b)?zb8"); + infraRequests0.getStartTime(); + } + + @Test(timeout = 4000) + public void test095() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + String string0 = infraRequests0.getRequestStatus(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test096() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("gpXsJ>b/G", "gpXsJ>b/G"); + infraRequests0.setClientRequestId("gpXsJ>b/G"); + infraRequests0.setCallBackUrl(""); + infraRequests0.setNetworkType("TF3Cf[F..K"); + assertNull(infraRequests0.getAicNodeClli()); + } + + @Test(timeout = 4000) + public void test097() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getVfModuleName(); + infraRequests0.setAicCloudRegion((String) null); + String string0 = infraRequests0.getVnfName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test098() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.setNetworkName("K|it"); + infraRequests0.setAction("hc}j,"); + infraRequests0.getServiceInstanceId(); + infraRequests0.getCallBackUrl(); + String string0 = infraRequests0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test099() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + String string0 = infraRequests0.getServiceInstanceId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test100() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + infraRequests0.getProvStatus(); + String string0 = infraRequests0.getVfModuleId(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test101() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests(); + String string0 = infraRequests0.getCallBackUrl(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test102() throws Throwable { + InfraRequests infraRequests0 = new InfraRequests("", "j28UDln3go*x"); + assertEquals("j28UDln3go*x", infraRequests0.getAction()); + + infraRequests0.setAction("X;{A n=y"); + infraRequests0.setTenantId(""); + assertEquals("", infraRequests0.getRequestId()); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsESTestscaffolding.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsESTestscaffolding.java new file mode 100644 index 0000000000..9ab77f5ad2 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/InfraRequestsESTestscaffolding.java @@ -0,0 +1,82 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Wed Dec 14 15:15:48 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 InfraRequestsESTestscaffolding { + + @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.InfraRequests"; + 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(InfraRequestsESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.requestsdb.InfraRequests" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(InfraRequestsESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.requestsdb.InfraRequests" + ); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseESTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseESTest.java new file mode 100644 index 0000000000..7c1b39979a --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseESTest.java @@ -0,0 +1,24 @@ +/* + * This file was automatically generated by EvoSuite + * Wed Dec 14 15:15:27 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.RequestsDatabase; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RequestsDatabaseESTest extends RequestsDatabaseESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RequestsDatabase requestsDatabase0 = (RequestsDatabase)PrivateAccess.callDefaultConstructorOfTheClassUnderTest(); + assertNotNull(requestsDatabase0); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseESTestscaffolding.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseESTestscaffolding.java new file mode 100644 index 0000000000..6d5c31ff57 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/RequestsDatabaseESTestscaffolding.java @@ -0,0 +1,120 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Wed Dec 14 15:15:27 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 RequestsDatabaseESTestscaffolding { + + @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.RequestsDatabase"; + 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(RequestsDatabaseESTestscaffolding.class.getClassLoader() , + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFLogger", + "org.hibernate.engine.spi.Mapping", + "org.hibernate.criterion.Order", + "org.openecomp.mso.requestsdb.InfraRequests", + "org.openecomp.mso.requestsdb.HibernateUtil", + "com.att.eelf.configuration.SLF4jWrapper", + "org.hibernate.Query", + "com.att.eelf.i18n.EELFResourceManager", + "org.openecomp.mso.requestsdb.RequestsDatabase", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "org.hibernate.criterion.Criterion", + "org.openecomp.mso.requestsdb.InfraActiveRequests", + "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.configuration.EELFManager", + "com.att.eelf.i18n.EELFMsgs", + "org.openecomp.mso.entity.MsoRequest", + "com.att.eelf.configuration.EELFLogger$Level", + "org.hibernate.BasicQueryContract", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.openecomp.mso.requestsdb.MockRequestsDatabase", + "org.openecomp.mso.requestsdb.SiteStatus", + "org.openecomp.mso.logger.MsoLogger" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RequestsDatabaseESTestscaffolding.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", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.openecomp.mso.requestsdb.RequestsDatabase" + ); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusESTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusESTest.java new file mode 100644 index 0000000000..75d7b19c33 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusESTest.java @@ -0,0 +1,91 @@ +/* + * This file was automatically generated by EvoSuite + * Wed Dec 14 15:16:15 GMT 2016 + */ + +package org.openecomp.mso.requestsdb; + +import org.junit.Test; +import static org.junit.Assert.*; +import java.sql.Timestamp; +import java.time.Instant; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.mock.java.time.MockInstant; +import org.junit.runner.RunWith; +import org.openecomp.mso.requestsdb.SiteStatus; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class SiteStatusESTest extends SiteStatusESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + SiteStatus siteStatus0 = new SiteStatus(); + siteStatus0.setSiteName("h8w;`)o;(SRi+0Q-"); + String string0 = siteStatus0.getSiteName(); + assertEquals("h8w;`)o;(SRi+0Q-", string0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + SiteStatus siteStatus0 = new SiteStatus(); + siteStatus0.setSiteName(""); + String string0 = siteStatus0.getSiteName(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + SiteStatus siteStatus0 = new SiteStatus(); + Timestamp timestamp0 = new Timestamp((-1L)); + siteStatus0.setCreated(timestamp0); + Timestamp timestamp1 = siteStatus0.getCreated(); + assertSame(timestamp1, timestamp0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + SiteStatus siteStatus0 = new SiteStatus(); + Instant instant0 = MockInstant.ofEpochSecond(5121L); + Timestamp timestamp0 = Timestamp.from(instant0); + siteStatus0.setCreated(timestamp0); + Timestamp timestamp1 = siteStatus0.getCreated(); + assertEquals(0, timestamp1.getNanos()); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + SiteStatus siteStatus0 = new SiteStatus(); + boolean boolean0 = siteStatus0.getStatus(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + SiteStatus siteStatus0 = new SiteStatus(); + String string0 = siteStatus0.getSiteName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + SiteStatus siteStatus0 = new SiteStatus(); + siteStatus0.setStatus(true); + boolean boolean0 = siteStatus0.getStatus(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test7() throws Throwable { + SiteStatus siteStatus0 = new SiteStatus(); + String string0 = siteStatus0.toString(); + assertEquals("SiteStatus{status=false, siteName='null', created=null}", string0); + } + + @Test(timeout = 4000) + public void test8() throws Throwable { + SiteStatus siteStatus0 = new SiteStatus(); + Timestamp timestamp0 = siteStatus0.getCreated(); + assertNull(timestamp0); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusESTestscaffolding.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusESTestscaffolding.java new file mode 100644 index 0000000000..2d50450c60 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/SiteStatusESTestscaffolding.java @@ -0,0 +1,105 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Wed Dec 14 15:16:15 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 SiteStatusESTestscaffolding { + + @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.SiteStatus"; + 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(SiteStatusESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.logger.MessageEnum", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "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.logger.MsoLogger$ResponseCode", + "com.att.eelf.configuration.SLF4jWrapper", + "com.att.eelf.i18n.EELFResourceManager", + "org.openecomp.mso.requestsdb.SiteStatus", + "org.openecomp.mso.logger.MsoLogger", + "org.openecomp.mso.logger.MsoLogger$ErrorCode" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(SiteStatusESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFResourceManager", + "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.MessageEnum", + "org.openecomp.mso.requestsdb.SiteStatus" + ); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapterESTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapterESTest.java new file mode 100644 index 0000000000..ea3238916e --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapterESTest.java @@ -0,0 +1,69 @@ +/* + * This file was automatically generated by EvoSuite + * Wed Dec 14 15:14:31 GMT 2016 + */ + +package org.openecomp.mso.requestsdb.adapter; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; +import java.sql.Timestamp; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; +import org.openecomp.mso.requestsdb.adapter.TimestampXMLAdapter; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class TimestampXMLAdapterESTest extends TimestampXMLAdapterESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + TimestampXMLAdapter timestampXMLAdapter0 = new TimestampXMLAdapter(); + Long long0 = new Long((-3027L)); + Timestamp timestamp0 = timestampXMLAdapter0.unmarshal(long0); + Long long1 = timestampXMLAdapter0.marshal(timestamp0); + assertTrue(long1.equals((Object)long0)); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + TimestampXMLAdapter timestampXMLAdapter0 = new TimestampXMLAdapter(); + Long long0 = new Long(861L); + Timestamp timestamp0 = timestampXMLAdapter0.unmarshal(long0); + Long long1 = timestampXMLAdapter0.marshal(timestamp0); + assertEquals(861L, (long)long1); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + TimestampXMLAdapter timestampXMLAdapter0 = new TimestampXMLAdapter(); + try { + timestampXMLAdapter0.marshal((Timestamp) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.requestsdb.adapter.TimestampXMLAdapter", e); + } + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + TimestampXMLAdapter timestampXMLAdapter0 = new TimestampXMLAdapter(); + Timestamp timestamp0 = timestampXMLAdapter0.unmarshal((Long) null); + Long long0 = timestampXMLAdapter0.marshal(timestamp0); + assertEquals(0L, (long)long0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + TimestampXMLAdapter timestampXMLAdapter0 = new TimestampXMLAdapter(); + Long long0 = new Long(497L); + Timestamp timestamp0 = timestampXMLAdapter0.unmarshal(long0); + Long long1 = timestampXMLAdapter0.marshal(timestamp0); + assertEquals(497L, (long)long1); + } +} diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapterESTestscaffolding.java b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapterESTestscaffolding.java new file mode 100644 index 0000000000..0fdfcd2c07 --- /dev/null +++ b/mso-api-handlers/mso-requests-db/src/test/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapterESTestscaffolding.java @@ -0,0 +1,77 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Wed Dec 14 15:14:31 GMT 2016 + */ + +package org.openecomp.mso.requestsdb.adapter; + +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 TimestampXMLAdapterESTestscaffolding { + + @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.adapter.TimestampXMLAdapter"; + 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(TimestampXMLAdapterESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.requestsdb.adapter.TimestampXMLAdapter" + ); + } + + private static void resetClasses() { + } +} diff --git a/mso-api-handlers/pom.xml b/mso-api-handlers/pom.xml new file mode 100644 index 0000000000..87d6453fb7 --- /dev/null +++ b/mso-api-handlers/pom.xml @@ -0,0 +1,32 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp</groupId> + <artifactId>mso</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-api-handlers</artifactId> + <name>API Handler</name> + <description>API Handler for MSO</description> + <packaging>pom</packaging> + + <modules> + <module>mso-requests-db</module> + <module>mso-api-handler-common</module> + <module>mso-api-handler-infra</module> + </modules> + + <dependencies> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + </dependency> + </dependencies> +</project>
\ No newline at end of file |