diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java/org/onap')
135 files changed, 14756 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java new file mode 100644 index 0000000000..d3ddc60d3e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload; + +import java.util.Optional; + +import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersHealthCheck; +import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersQuiesce; +import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersResumeTraffic; +import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersUpgrade; +import org.onap.so.bpmn.appc.payload.beans.HealthCheckAction; +import org.onap.so.bpmn.appc.payload.beans.QuiesceTrafficAction; +import org.onap.so.bpmn.appc.payload.beans.RequestParametersHealthCheck; +import org.onap.so.bpmn.appc.payload.beans.ResumeTrafficAction; +import org.onap.so.bpmn.appc.payload.beans.SnapshotAction; +import org.onap.so.bpmn.appc.payload.beans.StartStopAction; +import org.onap.so.bpmn.appc.payload.beans.UpgradeAction; +import org.onap.so.bpmn.core.json.JsonUtils; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class PayloadClient { + + protected static ObjectMapper mapper = new ObjectMapper(); + + private PayloadClient() {} + + public static Optional<String> upgradeFormat(Optional<String> payload, String vnfName) throws JsonProcessingException{ + UpgradeAction payloadResult = new UpgradeAction(); + ConfigurationParametersUpgrade configParams = new ConfigurationParametersUpgrade(); + String payloadString = payload.isPresent() ? payload.get() : ""; + String existingSoftware = JsonUtils.getJsonValue(payloadString, "existing-software-version"); + String newSoftware = JsonUtils.getJsonValue(payloadString, "new-software-version"); + configParams.setExistingSoftwareVersion(existingSoftware); + configParams.setNewSoftwareVersion(newSoftware); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional<String> resumeTrafficFormat(String vnfName) throws JsonProcessingException{ + ResumeTrafficAction payloadResult = new ResumeTrafficAction(); + ConfigurationParametersResumeTraffic configParams = new ConfigurationParametersResumeTraffic(); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional<String> quiesceTrafficFormat(Optional<String> payload, String vnfName) throws JsonProcessingException{ + QuiesceTrafficAction payloadResult = new QuiesceTrafficAction(); + ConfigurationParametersQuiesce configParams = new ConfigurationParametersQuiesce(); + String payloadString = payload.isPresent() ? payload.get() : ""; + String operationsTimeout = JsonUtils.getJsonValue(payloadString, "operations-timeout"); + configParams.setOperationsTimeout(operationsTimeout); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional<String> startStopFormat(String aicIdentity) throws JsonProcessingException{ + StartStopAction payloadResult = new StartStopAction(); + payloadResult.setAicIdentity(aicIdentity); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional<String> healthCheckFormat(String vnfName, String vnfHostIpAddress) throws JsonProcessingException{ + HealthCheckAction payloadResult = new HealthCheckAction(); + RequestParametersHealthCheck requestParams = new RequestParametersHealthCheck(); + ConfigurationParametersHealthCheck configParams = new ConfigurationParametersHealthCheck(); + requestParams.setVnfName(vnfName); + configParams.setVnfName(vnfName); + payloadResult.setConfigurationParameters(configParams); + payloadResult.setRequestParameters(requestParams); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + + public static Optional<String> snapshotFormat(String vmId, String identityUrl)throws JsonProcessingException{ + SnapshotAction payloadResult = new SnapshotAction(); + payloadResult.setVmId(vmId); + payloadResult.setIdentityUrl(identityUrl); + return Optional.of(mapper.writeValueAsString(payloadResult)); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigModifyAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigModifyAction.java new file mode 100644 index 0000000000..3c39a8d66c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigModifyAction.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"request-parameters", +"configuration-parameters" +}) +public class ConfigModifyAction { + +@JsonProperty("request-parameters") +private RequestParametersConfigModify requestParameters; +@JsonProperty("configuration-parameters") +private ConfigurationParametersConfigModify configurationParameters; + +@JsonProperty("request-parameters") +public RequestParametersConfigModify getRequestParameters() { +return requestParameters; +} + +@JsonProperty("request-parameters") +public void setRequestParameters(RequestParametersConfigModify requestParameters) { +this.requestParameters = requestParameters; +} + +@JsonProperty("configuration-parameters") +public ConfigurationParametersConfigModify getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersConfigModify configurationParameters) { +this.configurationParameters = configurationParameters; +} + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersConfigModify.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersConfigModify.java new file mode 100644 index 0000000000..c88169bb80 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersConfigModify.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"node0_hostname", +"node0_backup_router_address" +}) +public class ConfigurationParametersConfigModify { + +@JsonProperty("node0_hostname") +private String node0Hostname; +@JsonProperty("node0_backup_router_address") +private String node0BackupRouterAddress; + +@JsonProperty("node0_hostname") +public String getNode0Hostname() { +return node0Hostname; +} + +@JsonProperty("node0_hostname") +public void setNode0Hostname(String node0Hostname) { +this.node0Hostname = node0Hostname; +} + +@JsonProperty("node0_backup_router_address") +public String getNode0BackupRouterAddress() { +return node0BackupRouterAddress; +} + +@JsonProperty("node0_backup_router_address") +public void setNode0BackupRouterAddress(String node0BackupRouterAddress) { +this.node0BackupRouterAddress = node0BackupRouterAddress; +} +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersHealthCheck.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersHealthCheck.java new file mode 100644 index 0000000000..a8964f3bc5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersHealthCheck.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf_name" +}) +public class ConfigurationParametersHealthCheck { + +@JsonProperty("vnf_name") +private String vnfName; + +@JsonProperty("vnf_name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf_name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersQuiesce.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersQuiesce.java new file mode 100644 index 0000000000..878a136962 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersQuiesce.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf_name", +"operations_timeout" +}) +public class ConfigurationParametersQuiesce { + +@JsonProperty("vnf_name") +private String vnfName; +@JsonProperty("operations_timeout") +private String operationsTimeout; + +@JsonProperty("vnf_name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf_name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} + +@JsonProperty("operations_timeout") +public String getOperationsTimeout() { +return operationsTimeout; +} + +@JsonProperty("operations_timeout") +public void setOperationsTimeout(String operationsTimeout) { +this.operationsTimeout = operationsTimeout; +} + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersResumeTraffic.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersResumeTraffic.java new file mode 100644 index 0000000000..6b5e59f2e0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersResumeTraffic.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf_name" +}) +public class ConfigurationParametersResumeTraffic { + +@JsonProperty("vnf_name") +private String vnfName; + +@JsonProperty("vnf_name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf_name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersUpgrade.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersUpgrade.java new file mode 100644 index 0000000000..ff51b06dbe --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ConfigurationParametersUpgrade.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf_name", +"existing-software-version", +"new-software-version" +}) +public class ConfigurationParametersUpgrade { +@JsonProperty("vnf_name") +private String vnfName; +@JsonProperty("existing-software-version") +private String existingSoftwareVersion; +@JsonProperty("new-software-version") +private String newSoftwareVersion; + +@JsonProperty("vnf_name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf_name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} + +@JsonProperty("existing-software-version") +public String getExistingSoftwareVersion() { +return existingSoftwareVersion; +} + +@JsonProperty("existing-software-version") +public void setExistingSoftwareVersion(String existingSoftwareVersion) { +this.existingSoftwareVersion = existingSoftwareVersion; +} + +@JsonProperty("new-software-version") +public String getNewSoftwareVersion() { +return newSoftwareVersion; +} + +@JsonProperty("new-software-version") +public void setNewSoftwareVersion(String newSoftwareVersion) { +this.newSoftwareVersion = newSoftwareVersion; +} + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/HealthCheckAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/HealthCheckAction.java new file mode 100644 index 0000000000..4d194650c4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/HealthCheckAction.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"request-parameters", +"configuration-parameters" +}) +public class HealthCheckAction { + +@JsonProperty("request-parameters") +private RequestParametersHealthCheck requestParameters; +@JsonProperty("configuration-parameters") +private ConfigurationParametersHealthCheck configurationParameters; + +@JsonProperty("request-parameters") +public RequestParametersHealthCheck getRequestParameters() { +return requestParameters; +} + +@JsonProperty("request-parameters") +public void setRequestParameters(RequestParametersHealthCheck requestParameters) { +this.requestParameters = requestParameters; +} + +@JsonProperty("configuration-parameters") +public ConfigurationParametersHealthCheck getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersHealthCheck configurationParameters) { +this.configurationParameters = configurationParameters; +} +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/QuiesceTrafficAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/QuiesceTrafficAction.java new file mode 100644 index 0000000000..0b16c6ca90 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/QuiesceTrafficAction.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"configuration-parameters" +}) +public class QuiesceTrafficAction { + +@JsonProperty("configuration-parameters") +private ConfigurationParametersQuiesce configurationParameters; + +@JsonProperty("configuration-parameters") +public ConfigurationParametersQuiesce getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersQuiesce configurationParameters) { +this.configurationParameters = configurationParameters; +} +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersConfigModify.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersConfigModify.java new file mode 100644 index 0000000000..58c9234d60 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersConfigModify.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf-host-ip-address" +}) +public class RequestParametersConfigModify { + +@JsonProperty("vnf-host-ip-address") +private String vnfHostIpAddress; + +@JsonProperty("vnf-host-ip-address") +public String getVnfHostIpAddress() { +return vnfHostIpAddress; +} + +@JsonProperty("vnf-host-ip-address") +public void setVnfHostIpAddress(String vnfHostIpAddress) { +this.vnfHostIpAddress = vnfHostIpAddress; +} + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java new file mode 100644 index 0000000000..ca87ad6d15 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/RequestParametersHealthCheck.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vnf-name" +}) +public class RequestParametersHealthCheck { + +@JsonProperty("vnf-name") +private String vnfName; + + +@JsonProperty("vnf-name") +public String getVnfName() { +return vnfName; +} + +@JsonProperty("vnf-name") +public void setVnfName(String vnfName) { +this.vnfName = vnfName; +} + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ResumeTrafficAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ResumeTrafficAction.java new file mode 100644 index 0000000000..b642a376fe --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/ResumeTrafficAction.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"configuration-parameters" +}) +public class ResumeTrafficAction { + +@JsonProperty("configuration-parameters") +private ConfigurationParametersResumeTraffic configurationParameters; + +@JsonProperty("configuration-parameters") +public ConfigurationParametersResumeTraffic getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersResumeTraffic configurationParameters) { +this.configurationParameters = configurationParameters; +} +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/SnapshotAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/SnapshotAction.java new file mode 100644 index 0000000000..0499e5d6c0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/SnapshotAction.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"vm-id", +"identity-url" +}) +public class SnapshotAction { + +@JsonProperty("vm-id") +private String vmId; +@JsonProperty("identity-url") +private String identityUrl; + +@JsonProperty("vm-id") +public String getVmId() { +return vmId; +} + +@JsonProperty("vm-id") +public void setVmId(String vmId) { +this.vmId = vmId; +} + +@JsonProperty("identity-url") +public String getIdentityUrl() { +return identityUrl; +} + +@JsonProperty("identity-url") +public void setIdentityUrl(String identityUrl) { +this.identityUrl = identityUrl; +} + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/StartStopAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/StartStopAction.java new file mode 100644 index 0000000000..f2b5b905a5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/StartStopAction.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + " AICIdentity " +}) +public class StartStopAction { + + @JsonProperty(" AICIdentity ") + private String aicIdentity; + + @JsonProperty(" AICIdentity ") + public String getAicIdentity() { + return aicIdentity; + } + + @JsonProperty(" AICIdentity ") + public void setAicIdentity(String aicIdentity) { + this.aicIdentity = aicIdentity; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/UpgradeAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/UpgradeAction.java new file mode 100644 index 0000000000..3e07f328ce --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/beans/UpgradeAction.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.appc.payload.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ +"configuration-parameters" +}) +public class UpgradeAction { + +@JsonProperty("configuration-parameters") +private ConfigurationParametersUpgrade configurationParameters; + +@JsonProperty("configuration-parameters") +public ConfigurationParametersUpgrade getConfigurationParameters() { +return configurationParameters; +} + +@JsonProperty("configuration-parameters") +public void setConfigurationParameters(ConfigurationParametersUpgrade configurationParameters) { +this.configurationParameters = configurationParameters; +} +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/ActionPreProcessor.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/ActionPreProcessor.java new file mode 100644 index 0000000000..19ab520c6c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/ActionPreProcessor.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common; + + +import org.camunda.bpm.engine.delegate.DelegateExecution; + +/** + * interface to be extended by the classes, where pre processing is required + */ +public interface ActionPreProcessor { + + /** + * method to bind and return the action + * + * @return + */ + String getAction(); + + /** + * method to preform certain pre processing task before BB execution + * + * @param execution + * @return + */ + boolean process(DelegateExecution execution); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java new file mode 100644 index 0000000000..a2f6637b5b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common; + +import java.io.Serializable; +import java.util.Map; + +import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; + +public interface BuildingBlockExecution { + + public GeneralBuildingBlock getGeneralBuildingBlock(); + public <T> T getVariable(String key); + public <T> T getRequiredVariable(String key) throws RequiredExecutionVariableExeception; + public void setVariable(String key, Serializable value); + public Map<ResourceKey, String> getLookupMap(); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DefaultToShortClassNameBeanNameGenerator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DefaultToShortClassNameBeanNameGenerator.java new file mode 100644 index 0000000000..5a126ffe7d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DefaultToShortClassNameBeanNameGenerator.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common; + +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.AnnotationBeanNameGenerator; +import org.springframework.util.ClassUtils; + +public class DefaultToShortClassNameBeanNameGenerator extends AnnotationBeanNameGenerator { + + @Override + protected String buildDefaultBeanName(BeanDefinition definition) { + return ClassUtils.getShortName(definition.getBeanClassName()); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java new file mode 100644 index 0000000000..ef564c6af4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java @@ -0,0 +1,118 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.exceptions.MalformedBuildingBlockInputException; +import org.onap.so.bpmn.common.exceptions.MissingBuildingBlockInputException; +import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; + +public class DelegateExecutionImpl implements BuildingBlockExecution, Serializable { + + private final Map<String, Serializable> seedMap; + private transient DelegateExecution execution; + private static final String INVALID_INPUT_MISSING = "Expected variable of \"%s\" not found in execution"; + private static final String INVALID_INPUT_CLASS_CAST = "Expected variable of \"%s\" was the wrong object type in the execution"; + + private static final String MISSING_MSG = "Execution variable \"gBBInput\" cannot be null when executing building blocks"; + private static final String MALFORMED_MSG = "Execution variable \"gBBInput\" must contain an element of type GeneralBuildingBlock"; + + public DelegateExecutionImpl(Map<String, Serializable> seedMap) { + this.seedMap = seedMap; + } + + public DelegateExecutionImpl(DelegateExecution execution) { + this.seedMap = new HashMap<>(); + execution.getVariables().forEach((key, value) -> { + if (value instanceof Serializable) { + seedMap.put(key, (Serializable)value); + } + }); + /* must occur for junit tests to work */ + this.execution = execution; + } + @Override + public GeneralBuildingBlock getGeneralBuildingBlock() { + try { + GeneralBuildingBlock generalBuildingBlock = (GeneralBuildingBlock) execution.getVariable("gBBInput"); + + if (generalBuildingBlock == null) { + throw new MissingBuildingBlockInputException(MISSING_MSG); + } + + return generalBuildingBlock; + } catch (ClassCastException e) { + throw new MalformedBuildingBlockInputException(MALFORMED_MSG, e); + } + } + + @Override + public <T> T getVariable(String key) { + return this.get(key); + } + + @Override + public <T> T getRequiredVariable(String key) throws RequiredExecutionVariableExeception { + final T result; + + result = this.get(key); + if (result == null) { + throw new RequiredExecutionVariableExeception(String.format(INVALID_INPUT_MISSING, key)); + + } + return result; + } + + @Override + public void setVariable(String key, Serializable value) { + this.execution.setVariable(key, value); + } + + @Override + public Map<ResourceKey, String> getLookupMap() { + return this.get("lookupKeyMap"); + } + + public DelegateExecution getDelegateExecution() { + return this.execution; + } + + public void setDelegateExecution(DelegateExecution execution) { + this.execution = execution; + this.seedMap.forEach((key, value) -> { + if (!execution.hasVariable(key)) { + execution.setVariable(key, value); + } + }); + } + + protected <T> T get(String key) { + final Object value = this.execution.getVariable(key); + + return (T)value; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectExecution.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectExecution.java new file mode 100644 index 0000000000..56b059ec16 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectExecution.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.springframework.stereotype.Component; + +@Component +public class InjectExecution { + + public DelegateExecutionImpl execute (DelegateExecution execution, DelegateExecutionImpl impl) { + + impl.setDelegateExecution(execution); + return impl; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectionHelper.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectionHelper.java new file mode 100644 index 0000000000..f1c2c8dda6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/InjectionHelper.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common; + +import org.onap.so.client.aai.AAICommonObjectMapperProvider; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.sdno.SDNOValidator; +import org.onap.so.client.sdno.SDNOValidatorImpl; +import org.springframework.stereotype.Component; + +/* + * This object is intended to be a helper for acquiring classes + * that cannot be acquired via Spring injection. + * + * It brings two benefits: + * + * 1) Enforces acquisition of a new copy of these classes every + * time to help with picking up properties files changes, etc + * 2) The classes are exposed in such a way that mocks of them can + * still be injected when testing the Spring objects that use + * them + */ + +@Component +public class InjectionHelper { + public AAIResourcesClient getAaiClient() { + return new AAIResourcesClient(); + } + + public SDNOValidator getSdnoValidator() { + return new SDNOValidatorImpl(); + } + + public AAICommonObjectMapperProvider getAaiCommonObjectMapperProvider() { + return new AAICommonObjectMapperProvider(); + } + + public AAIResultWrapper getAaiResultWrapper(String json) { + return new AAIResultWrapper(json); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/SpringContextHelper.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/SpringContextHelper.java new file mode 100644 index 0000000000..edc544d939 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/SpringContextHelper.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +@Component +public class SpringContextHelper implements ApplicationContextAware { + + private static ApplicationContext context; + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + context = applicationContext; + } + + public static ApplicationContext getAppContext() { + return context; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/exceptions/MalformedBuildingBlockInputException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/exceptions/MalformedBuildingBlockInputException.java new file mode 100644 index 0000000000..1da989bfb7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/exceptions/MalformedBuildingBlockInputException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.exceptions; + +public class MalformedBuildingBlockInputException extends RuntimeException { + private static final long serialVersionUID = -9168146273898271648L; + + public MalformedBuildingBlockInputException() { + super(); + } + + public MalformedBuildingBlockInputException(String message) { + super(message); + } + + public MalformedBuildingBlockInputException(String message, Throwable cause) { + super(message, cause); + } + + public MalformedBuildingBlockInputException(Throwable cause) { + super(cause); + } + + protected MalformedBuildingBlockInputException(String message, Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/exceptions/MissingBuildingBlockInputException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/exceptions/MissingBuildingBlockInputException.java new file mode 100644 index 0000000000..5ad28a5ba0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/exceptions/MissingBuildingBlockInputException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.exceptions; + +public class MissingBuildingBlockInputException extends RuntimeException { + private static final long serialVersionUID = 7098084383189271401L; + + public MissingBuildingBlockInputException() { + super(); + } + + public MissingBuildingBlockInputException(String message) { + super(message); + } + + public MissingBuildingBlockInputException(String message, Throwable cause) { + super(message, cause); + } + + public MissingBuildingBlockInputException(Throwable cause) { + super(cause); + } + + protected MissingBuildingBlockInputException(String message, Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/exceptions/RequiredExecutionVariableExeception.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/exceptions/RequiredExecutionVariableExeception.java new file mode 100644 index 0000000000..8c77bb445e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/exceptions/RequiredExecutionVariableExeception.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.exceptions; + +public class RequiredExecutionVariableExeception extends Exception { + + private static final long serialVersionUID = 5135274986874563746L; + + public RequiredExecutionVariableExeception(String message) { + super(message); + } + + public RequiredExecutionVariableExeception(String message, Throwable t) { + super(message, t); + } + + public RequiredExecutionVariableExeception(Throwable t) { + super(t); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnIntegerParam.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnIntegerParam.java new file mode 100644 index 0000000000..80479e19c0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnIntegerParam.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.common.recipe; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class BpmnIntegerParam { + + @JsonProperty("value") + private int value; + @JsonProperty("type") + private final String type = "Integer"; + + public BpmnIntegerParam() { + } + + @JsonProperty("value") + public int getValue() { + return value; + } + + @JsonProperty("type") + public void setValue(int value) { + this.value = value; + } + + @Override + public String toString() { + return "CamundaInput [value=" + Integer.toString(value) + ", type=" + type + "]"; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnParam.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnParam.java new file mode 100644 index 0000000000..01285cd5ec --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnParam.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.recipe; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The bpmn workflow input param object + */ +public class BpmnParam { + + @JsonProperty("value") + private String value; + @JsonProperty("type") + private String type = "String"; + + + public BpmnParam() { + /* Empty constructor */ + } + + @JsonProperty("value") + public String getValue() { + return value; + } + + @JsonProperty("value") + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return "CamundaInput [value=" + value + ", type=" + type + "]"; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java new file mode 100644 index 0000000000..bbaebb64dc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java @@ -0,0 +1,205 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.recipe; + +import java.io.IOException; +import java.security.GeneralSecurityException; + +import javax.xml.bind.DatatypeConverter; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClientBuilder; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.onap.so.utils.CryptoUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Support to call resource recipes from the BPMN workflow. + * Such as call resource recipe in service workflow. + * <br> + * <p> + * </p> + * + * @author + * @version ONAP Beijing Release 2018-02-27 + */ +@Component +public class BpmnRestClient { + + public static final String DEFAULT_BPEL_AUTH = "admin:admin"; + + public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + + public static final String CONTENT_TYPE_JSON = "application/json"; + + public static final String CAMUNDA_AUTH = "camundaAuth"; + + private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + @Autowired + private UrnPropertiesReader urnPropertiesReader; + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, BpmnRestClient.class); + + private static boolean noProperties = true; + + //because for NS it will take a long time the time out of the resouce will be 2 hours. + private static final String DEFAULT_TIME_OUT = "7200"; + + public synchronized final boolean getNoPropertiesState() { + return noProperties; + } + + /** + * post the recipe Uri + * <br> + * + * @param recipeUri The request recipe uri + * @param requestId the request id + * @param recipeTimeout The recipe time out + * @param requestAction The request action + * @param serviceInstanceId The service instance id + * @param serviceType The service Type + * @param requestDetails The request Details, these information is from runtime + * @param recipeParamXsd The recipe params, its from recipe design + * @return The response of the recipe. + * @throws ClientProtocolException + * @throws IOException + * @since ONAP Beijing Release + */ + public HttpResponse post(String recipeUri, String requestId, int recipeTimeout, String requestAction, String serviceInstanceId, String serviceType, + String requestDetails, String recipeParamXsd) throws ClientProtocolException, IOException { + + HttpClient client = HttpClientBuilder.create().build(); + + HttpPost post = new HttpPost(recipeUri); + RequestConfig requestConfig = + RequestConfig.custom().setSocketTimeout(recipeTimeout).setConnectTimeout(recipeTimeout).setConnectionRequestTimeout(recipeTimeout).build(); + post.setConfig(requestConfig); + msoLogger.debug("call the bpmn, url:" + recipeUri); + String jsonReq = wrapResourceRequest(requestId, recipeTimeout, requestAction, serviceInstanceId, serviceType, requestDetails, recipeParamXsd); + + StringEntity input = new StringEntity(jsonReq); + input.setContentType(CONTENT_TYPE_JSON); + String encryptedCredentials; + encryptedCredentials = urnPropertiesReader.getVariable(CAMUNDA_AUTH); + if(encryptedCredentials != null) { + String userCredentials = getEncryptedPropValue(encryptedCredentials, DEFAULT_BPEL_AUTH, ENCRYPTION_KEY); + if(userCredentials != null) { + post.addHeader("Authorization", "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes())); + } + } + + post.setEntity(input); + return client.execute(post); + } + + /** + * prepare the resource recipe bpmn request. + * <br> + * + * @param requestId + * @param recipeTimeout + * @param requestAction + * @param serviceInstanceId + * @param serviceType + * @param requestDetails + * @param recipeParams + * @return + * @since ONAP Beijing Release + */ + private String wrapResourceRequest(String requestId, int recipeTimeout, String requestAction, String serviceInstanceId, String serviceType, + String requestDetails, String recipeParams) { + String jsonReq = null; + if(requestId == null) { + requestId = ""; + } + if(requestAction == null) { + requestAction = ""; + } + if(serviceInstanceId == null) { + serviceInstanceId = ""; + } + + if(requestDetails == null) { + requestDetails = ""; + } + + try { + ResourceRecipeRequest recipeRequest = new ResourceRecipeRequest(); + BpmnParam resourceInput = new BpmnParam(); + BpmnParam host = new BpmnParam(); + BpmnParam requestIdInput = new BpmnParam(); + BpmnParam requestActionInput = new BpmnParam(); + BpmnParam serviceInstanceIdInput = new BpmnParam(); + BpmnParam serviceTypeInput = new BpmnParam(); + BpmnParam recipeParamsInput = new BpmnParam(); + BpmnIntegerParam recipeTimeoutInput = new BpmnIntegerParam(); + recipeTimeoutInput.setValue(recipeTimeout); + // host.setValue(parseURL()); + requestIdInput.setValue(requestId); + requestActionInput.setValue(requestAction); + serviceInstanceIdInput.setValue(serviceInstanceId); + serviceTypeInput.setValue(serviceType); + recipeParamsInput.setValue(recipeParams); + resourceInput.setValue(requestDetails); + recipeRequest.setHost(host); + recipeRequest.setRequestId(requestIdInput); + recipeRequest.setRequestAction(requestActionInput); + recipeRequest.setServiceInstanceId(serviceInstanceIdInput); + recipeRequest.setServiceType(serviceTypeInput); + recipeRequest.setRecipeParams(recipeParamsInput); + recipeRequest.setResourceInput(resourceInput); + recipeRequest.setRecipeTimeout(recipeTimeoutInput); + jsonReq = recipeRequest.toString(); + msoLogger.trace("request body is " + jsonReq); + } catch(Exception e) { + msoLogger.error(MessageEnum.APIH_WARP_REQUEST, "Camunda", "wrapVIDRequest", MsoLogger.ErrorCode.BusinessProcesssError, "Error in APIH Warp request", + e); + } + return jsonReq; + } + + /** + * <br> + * + * @param prop + * @param defaultValue + * @param encryptionKey + * @return + * @since ONAP Beijing Release + */ + protected String getEncryptedPropValue(String prop, String defaultValue, String encryptionKey) { + try { + return CryptoUtils.decrypt(prop, encryptionKey); + } catch(GeneralSecurityException e) { + msoLogger.debug("Security exception", e); + } + return defaultValue; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java new file mode 100644 index 0000000000..4c345babc8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java @@ -0,0 +1,295 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.common.recipe; + +import org.onap.so.bpmn.core.domain.ModelInfo; +import org.onap.so.logger.MsoLogger; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +/** + * the inputs for the resource recipe + * <br> + * <p> + * </p> + * + * @author + * @version ONAP Beijing Release 2018-03-08 + */ +@JsonPropertyOrder({"resourceInstanceName", "resourceInstanceDes", "globalSubscriberId", "serviceType", "serviceId", "operationId", "serviceModelInfo","resourceModelInfo", "resourceInstancenUuid","resourceParameters","operationType"}) +@JsonRootName("variables") +public class ResourceInput { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, ResourceInput.class); + + @JsonProperty("resourceInstanceName") + private String resourceInstanceName; + + @JsonProperty("resourceInstanceDes") + private String resourceInstanceDes; + + @JsonProperty("globalSubscriberId") + private String globalSubscriberId; + + @JsonProperty("serviceType") + private String serviceType; + + @JsonProperty("serviceInstanceId") + private String serviceInstanceId; + + @JsonProperty("operationId") + private String operationId; + + @JsonProperty("serviceModelInfo") + private ModelInfo serviceModelInfo; + + @JsonProperty("resourceModelInfo") + private ModelInfo resourceModelInfo; + + //for delete resource + @JsonProperty("resourceInstancenUuid") + private String resourceInstancenUuid; + + @JsonProperty("resourceParameters") + private String resourceParameters; + + @JsonProperty("operationType") + private String operationType; + + + /** + * @return Returns the resourceInstanceName. + */ + @JsonProperty("resourceInstanceName") + public String getResourceInstanceName() { + return resourceInstanceName; + } + + + /** + * @param resourceInstanceName The resourceInstanceName to set. + */ + @JsonProperty("resourceInstanceName") + public void setResourceInstanceName(String resourceInstanceName) { + this.resourceInstanceName = resourceInstanceName; + } + + + /** + * @return Returns the resourceInstanceDes. + */ + @JsonProperty("resourceInstanceDes") + public String getResourceInstanceDes() { + return resourceInstanceDes; + } + + + /** + * @param resourceInstanceDes The resourceInstanceDes to set. + */ + @JsonProperty("resourceInstanceDes") + public void setResourceInstanceDes(String resourceInstanceDes) { + this.resourceInstanceDes = resourceInstanceDes; + } + + + /** + * @return Returns the globalSubscriberId. + */ + @JsonProperty("globalSubscriberId") + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + + /** + * @param globalSubscriberId The globalSubscriberId to set. + */ + @JsonProperty("globalSubscriberId") + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + + /** + * @return Returns the serviceType. + */ + @JsonProperty("serviceType") + public String getServiceType() { + return serviceType; + } + + + /** + * @param serviceType The serviceType to set. + */ + @JsonProperty("serviceType") + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + + /** + * @return Returns the serviceId. + */ + @JsonProperty("serviceInstanceId") + public String getServiceInstanceId() { + return serviceInstanceId; + } + + + /** + * @param serviceId The serviceId to set. + */ + @JsonProperty("serviceInstanceId") + public void setServiceInstanceId(String serviceId) { + this.serviceInstanceId = serviceId; + } + + + /** + * @return Returns the operationId. + */ + @JsonProperty("operationId") + public String getOperationId() { + return operationId; + } + + + /** + * @param operationId The operationId to set. + */ + @JsonProperty("operationId") + public void setOperationId(String operationId) { + this.operationId = operationId; + } + + /** + * @return Returns the serviceModelInfo. + */ + @JsonProperty("serviceModelInfo") + public ModelInfo getServiceModelInfo() { + return serviceModelInfo; + } + + + + /** + * @param serviceModelInfo The serviceModelInfo to set. + */ + @JsonProperty("serviceModelInfo") + public void setServiceModelInfo(ModelInfo serviceModelInfo) { + this.serviceModelInfo = serviceModelInfo; + } + + + + /** + * @return Returns the resourceModelInfo. + */ + @JsonProperty("resourceModelInfo") + public ModelInfo getResourceModelInfo() { + return resourceModelInfo; + } + + + + /** + * @param resourceModelInfo The resourceModelInfo to set. + */ + @JsonProperty("resourceModelInfo") + public void setResourceModelInfo(ModelInfo resourceModelInfo) { + this.resourceModelInfo = resourceModelInfo; + } + + + /** + * @return Returns the resourceParameters. + */ + @JsonProperty("resourceParameters") + public String getResourceParameters() { + return resourceParameters; + } + + + /** + * @param resourceParameters The resourceParameters to set. + */ + @JsonProperty("resourceParameters") + public void setResourceParameters(String resourceParameters) { + this.resourceParameters = resourceParameters; + } + + + /** + * @return Returns the operationType. + */ + @JsonProperty("operationType") + public String getOperationType() { + return operationType; + } + + + /** + * @param operationType The operationType to set. + */ + @JsonProperty("operationType") + public void setOperationType(String operationType) { + this.operationType = operationType; + } + + + + /** + * @return Returns the resourceInstancenUuid. + */ + @JsonProperty("resourceInstancenUuid") + public String getResourceInstancenUuid() { + return resourceInstancenUuid; + } + + + + /** + * @param resourceInstancenUuid The resourceInstancenUuid to set. + */ + @JsonProperty("resourceInstancenUuid") + public void setResourceInstancenUuid(String resourceInstancenUuid) { + this.resourceInstancenUuid = resourceInstancenUuid; + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); + String jsonStr = ""; + try { + jsonStr = mapper.writeValueAsString(this); + } catch(JsonProcessingException e) { + msoLogger.error("JsonProcessingException", e); + } + return jsonStr; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequest.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequest.java new file mode 100644 index 0000000000..4c6edfa099 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequest.java @@ -0,0 +1,159 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.recipe; + +import org.onap.so.logger.MsoLogger; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +/** + * java object of the resource recipe , it + * will be passed to the Camunda process + */ +@JsonPropertyOrder({"resourceInput", "host", "requestId", "requestAction", "serviceInstanceId", "serviceType", "recipeParams"}) +@JsonRootName("variables") +public class ResourceRecipeRequest { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, ResourceRecipeRequest.class); + + @JsonProperty("resourceInput") + private BpmnParam resourceInput; + + @JsonProperty("host") + private BpmnParam host; + + @JsonProperty("mso-request-id") + private BpmnParam requestId; + + @JsonProperty("requestAction") + private BpmnParam requestAction; + + @JsonProperty("serviceInstanceId") + private BpmnParam serviceInstanceId; + + @JsonProperty("serviceType") + private BpmnParam serviceType; + + @JsonProperty("recipeParams") + private BpmnParam recipeParams; + + @JsonProperty("mso-service-request-timeout") + private BpmnIntegerParam recipeTimeout; + + @JsonProperty("resourceInput") + public BpmnParam getResourceInput() { + return resourceInput; + } + + @JsonProperty("resourceInput") + public void setResourceInput(BpmnParam resourceInput) { + this.resourceInput = resourceInput; + } + + @JsonProperty("host") + public BpmnParam getHost() { + return host; + } + + @JsonProperty("host") + public void setHost(BpmnParam host) { + this.host = host; + } + + @JsonProperty("mso-request-id") + public BpmnParam getRequestId() { + return requestId; + } + + @JsonProperty("mso-request-id") + public void setRequestId(BpmnParam requestId) { + this.requestId = requestId; + } + + @JsonProperty("requestAction") + public BpmnParam getRequestAction() { + return requestAction; + } + + @JsonProperty("requestAction") + public void setRequestAction(BpmnParam requestAction) { + this.requestAction = requestAction; + } + + @JsonProperty("serviceInstanceId") + public BpmnParam getServiceInstanceId() { + return serviceInstanceId; + } + + @JsonProperty("serviceInstanceId") + public void setServiceInstanceId(BpmnParam serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + @JsonProperty("serviceType") + public BpmnParam getServiceType() { + return serviceType; + } + + @JsonProperty("serviceType") + public void setServiceType(BpmnParam serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty("recipeParams") + public BpmnParam getRecipeParams() { + return recipeParams; + } + + @JsonProperty("recipeParams") + public void setRecipeParams(BpmnParam recipeParams) { + this.recipeParams = recipeParams; + } + + @JsonProperty("mso-service-request-timeout") + public BpmnIntegerParam getRecipeTimeout() { + return recipeTimeout; + } + + @JsonProperty("mso-service-request-timeout") + public void setRecipeTimeout(BpmnIntegerParam recipeTimeout) { + this.recipeTimeout = recipeTimeout; + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + String jsonStr = "ResourceRecipeRequest"; + try { + jsonStr = mapper.writeValueAsString(this); + } catch(JsonProcessingException e) { + msoLogger.error("JsonProcessingException", e); + } + return jsonStr; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java new file mode 100644 index 0000000000..ca2da772fb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java @@ -0,0 +1,225 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.resource; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; + +import org.camunda.bpm.engine.runtime.Execution; +import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; +import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; +import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.Property; +import org.onap.sdc.toscaparser.api.functions.GetInput; +import org.onap.sdc.toscaparser.api.parameters.Input; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.HttpClient; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.onap.so.utils.TargetEntity; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + +public class ResourceRequestBuilder { + + public static String CUSTOMIZATION_UUID = "customizationUUID"; + + public static String SERVICE_URL_TOSCA_CSAR = "/v3/serviceToscaCsar?serviceModelUuid="; + + private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, ResourceRequestBuilder.class); + + static JsonUtils jsonUtil = new JsonUtils(); + + /** + * build the resource Parameters detail. + * It's a json string for resource instantiant + * { + * "locationConstraints":[...] + * "requestInputs":{K,V} + * } + * <br> + * + * @param execution Execution context + * @param serviceUuid The service template uuid + * @param resourceCustomizationUuid The resource customization uuid + * @param serviceParameters the service parameters passed from the API + * @return the resource instantiate parameters + * @since ONAP Beijing Release + */ + @SuppressWarnings("unchecked") + public static String buildResourceRequestParameters(Execution execution, String serviceUuid, String resourceCustomizationUuid, String serviceParameters) { + List<String> resourceList = jsonUtil.StringArrayToList(execution, (String)JsonUtils.getJsonValue(serviceParameters, "resources")); + //Get the right location str for resource. default is an empty array. + String locationConstraints ="[]"; + String resourceInputsFromUui = ""; + for(String resource: resourceList){ + String resCusUuid = (String)JsonUtils.getJsonValue(resource, "resourceCustomizationUuid"); + if(resourceCustomizationUuid.equals(resCusUuid)){ + String resourceParameters = JsonUtils.getJsonValue(resource, "parameters"); + locationConstraints = JsonUtils.getJsonValue(resourceParameters, "locationConstraints"); + resourceInputsFromUui = JsonUtils.getJsonValue(resourceParameters, "requestInputs"); + } + } + Map<String, Object> serviceInput = null; + if (JsonUtils.getJsonValue(serviceParameters, "requestInputs") != null) { + serviceInput = getJsonObject((String)JsonUtils.getJsonValue(serviceParameters, "requestInputs"), Map.class); + } + + Map<String, Object> resourceInputsFromUuiMap = getJsonObject(resourceInputsFromUui, Map.class); + + if (serviceInput == null) { + serviceInput = new HashMap(); + } + + if (resourceInputsFromUuiMap == null) { + resourceInputsFromUuiMap = new HashMap(); + } + + try { + Map<String, Object> resourceInputsFromServiceDeclaredLevel = buildResouceRequest(serviceUuid, resourceCustomizationUuid, serviceInput); + resourceInputsFromUuiMap.putAll(resourceInputsFromServiceDeclaredLevel); + } catch(SdcToscaParserException e) { + LOGGER.error("SdcToscaParserException", e); + } + String resourceInputsStr = getJsonString(resourceInputsFromUuiMap); + String result = "{\n" + + "\"locationConstraints\":" + locationConstraints +",\n" + + "\"requestInputs\":" + resourceInputsStr +"\n" + +"}"; + return result; + } + + public static Map<String, Object> buildResouceRequest(String serviceUuid, String resourceCustomizationUuid, Map<String, Object> serviceInputs) + throws SdcToscaParserException { + + Map<String, Object> resouceRequest = new HashMap<>(); + + String csarpath = null; + try { + csarpath = getCsarFromUuid(serviceUuid); + } catch(Exception e) { + LOGGER.debug("csar file is not available for service uuid:" + serviceUuid, e); + return resouceRequest; + } + + SdcToscaParserFactory toscaParser = SdcToscaParserFactory.getInstance(); + ISdcCsarHelper iSdcCsarHelper = toscaParser.getSdcCsarHelper(csarpath, false); + + List<Input> serInput = iSdcCsarHelper.getServiceInputs(); + Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream() + .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst(); + + if(nodeTemplateOpt.isPresent()) { + NodeTemplate nodeTemplate = nodeTemplateOpt.get(); + LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties(); + + for(String key : resourceProperties.keySet()) { + Property property = resourceProperties.get(key); + + Object value = getValue(property.getValue(), serviceInputs, serInput); + resouceRequest.put(key, value); + } + } + return resouceRequest; + } + + private static Object getValue(Object value, Map<String, Object> serviceInputs, List<Input> servInputs) { + if(value instanceof Map) { + Map<String, Object> valueMap = new HashMap<>(); + + Map<String, Object> propertyMap = (Map<String, Object>)value; + + for(String key : propertyMap.keySet()) { + valueMap.put(key, getValue(propertyMap.get(key), serviceInputs, servInputs)); + } + return valueMap; // return if the value is nested hashmap + } else if(value instanceof GetInput) { + String inputName = ((GetInput)value).getInputName(); + + if(serviceInputs.get(inputName) != null) { + value = serviceInputs.get(inputName); + } else { + for(Input input : servInputs) { + if(input.getName().equals(inputName)) { + return input.getDefault(); // return default value + } + } + } + } + return value; // return property value + } + + private static String getCsarFromUuid(String uuid) throws Exception { + String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint"); + HttpClient client = new HttpClient(UriBuilder.fromUri(catalogEndPoint + SERVICE_URL_TOSCA_CSAR + uuid).build().toURL(), "application/json", TargetEntity.CATALOG_DB); + + Response response = client.get(); + String value = response.readEntity(String.class); + + HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType()); + + File csarFile = new File(System.getProperty("mso.config.path") + "ASDC/" + map.get("name")); + + if(!csarFile.exists()) { + throw new Exception("csar file does not exist."); + } + + return csarFile.getAbsolutePath(); + } + + public static <T> T getJsonObject(String jsonstr, Class<T> type) { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + try { + return mapper.readValue(jsonstr, type); + } catch(IOException e) { + LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "fail to unMarshal json", e); + } + return null; + } + + public static String getJsonString(Object srcObj) { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); + String jsonStr = null; + try { + jsonStr = mapper.writeValueAsString(srcObj); + } catch(JsonProcessingException e) { + LOGGER.error("SdcToscaParserException", e); + } + return jsonStr; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CryptoHandler.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CryptoHandler.java new file mode 100644 index 0000000000..093dac39c3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/CryptoHandler.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.util; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.util.Properties; +import org.onap.so.utils.CryptoUtils; + +import org.onap.so.logger.MsoLogger; + +public class CryptoHandler implements ICryptoHandler { + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CryptoHandler.class); + private static final String GENERAL_SECURITY_EXCEPTION_PREFIX = "GeneralSecurityException :"; + private static final String MSO_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; + private static final String PROPERTY_KEY = "mso.AaiEncrypted.Pwd"; + + @Override + public String getMsoAaiPassword() { + Properties keyProp = new Properties (); + try { + keyProp.load (Thread.currentThread ().getContextClassLoader ().getResourceAsStream ("urn.properties")); + return CryptoUtils.decrypt((String) keyProp.get(PROPERTY_KEY), MSO_KEY); + } catch (GeneralSecurityException | IOException e) { + LOGGER.error(GENERAL_SECURITY_EXCEPTION_PREFIX + e.getMessage(), e); + return null; + } + } + + + @Override + public String encryptMsoPassword(String plainMsoPwd) { + try { + return CryptoUtils.encrypt(plainMsoPwd, MSO_KEY); + } catch (GeneralSecurityException e) { + LOGGER.error(GENERAL_SECURITY_EXCEPTION_PREFIX + e.getMessage(), e); + return null; + } + } + + @Override + public String decryptMsoPassword(String encryptedPwd) { + try { + return CryptoUtils.decrypt(encryptedPwd, MSO_KEY); + } catch (GeneralSecurityException e) { + LOGGER.error(GENERAL_SECURITY_EXCEPTION_PREFIX + e.getMessage(), e); + return null; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/ICryptoHandler.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/ICryptoHandler.java new file mode 100644 index 0000000000..6314a849d2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/ICryptoHandler.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.util; + +public interface ICryptoHandler { + public String getMsoAaiPassword(); + public String encryptMsoPassword(String plainPwd); + public String decryptMsoPassword(String encryptedPwd); +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowCallbackResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowCallbackResponse.java new file mode 100644 index 0000000000..13d2126805 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowCallbackResponse.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.common.workflow.context; + + +/** + * @version 1.0 + * Workflow Response bean to generate workflow response in JSON format + */ +public class WorkflowCallbackResponse { + + private String response; + private int statusCode; + private String message; + + public String getResponse() { + return response; + } + public void setResponse(String response) { + this.response = response; + } + public int getStatusCode() { + return statusCode; + } + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContext.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContext.java new file mode 100644 index 0000000000..3ec7773791 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContext.java @@ -0,0 +1,98 @@ +package org.onap.so.bpmn.common.workflow.context; +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + + +import java.util.concurrent.Delayed; +import java.util.concurrent.TimeUnit; + + +/** + * @version 1.0 + * Workflow context object used to send timeout response, if workflow instance does not write the response in time + */ +public class WorkflowContext implements Delayed { + private final String processKey; + private final String requestId; + + private final long startTime; + private final long timeout; + + private final WorkflowResponse workflowResponse; + + public WorkflowContext(String processKey, String requestId, long timeout, WorkflowResponse workflowResponse) { + this.processKey = processKey; + this.requestId = requestId; + this.timeout = timeout; + this.startTime = System.currentTimeMillis(); + this.workflowResponse = workflowResponse; + } + + public String getRequestId() { + return requestId; + } + + public String getProcessKey() { + return processKey; + } + + + public long getTimeout() { + return timeout; + } + + public long getStartTime() { + return startTime; + } + + public WorkflowResponse getWorkflowResponse() { + return workflowResponse; + } + + /** + * Required implementation by Delay queue + * Returns the elapsed time for this context + */ + @Override + public long getDelay(TimeUnit unit) { + // 0 or negative means this object is considered to be expired + return unit.convert(startTime + timeout - System.currentTimeMillis(), unit); + } + + /** + * Required implementation by Delay queue + * Compares the object to determine whether the object can be marked as expired + */ + @Override + public int compareTo(Delayed object) { + WorkflowContext that = (WorkflowContext) object; + long thisEndTime = startTime + timeout; + long thatEndTime = that.startTime + that.timeout; + + if (thisEndTime < thatEndTime) { + return -1; + } else if (thisEndTime > thatEndTime) { + return 1; + } else { + return 0; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java new file mode 100644 index 0000000000..39c32de77d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowContextHolder.java @@ -0,0 +1,140 @@ +package org.onap.so.bpmn.common.workflow.context; +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + + +import java.util.concurrent.DelayQueue; +import java.util.concurrent.TimeUnit; + +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.springframework.stereotype.Component; + +/** + * Workflow Context Holder instance which can be accessed elsewhere either in groovy scripts or Java + * @version 1.0 + * + */ + +@Component +public class WorkflowContextHolder { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,WorkflowContextHolder.class); + private static final String logMarker = "[WORKFLOW-CONTEXT-HOLDER]"; + private static WorkflowContextHolder instance = null; + + + private long defaultContextTimeout=60000; + + /** + * Delay Queue which holds workflow context holder objects + */ + private final DelayQueue<WorkflowContext> responseQueue = new DelayQueue<>(); + private final TimeoutThread timeoutThread = new TimeoutThread(); + + private WorkflowContextHolder() { + timeoutThread.start(); + } + + /** + * Singleton holder which eliminates hot lock + * Since the JVM synchronizes static method there is no synchronization needed for this method + * @return + */ + public static synchronized WorkflowContextHolder getInstance() { + if (instance == null) { + instance = new WorkflowContextHolder(); + } + return instance; + } + + public void put(WorkflowContext context) { + msoLogger.debug(logMarker + " Adding context to the queue: " + + context.getRequestId()); + responseQueue.put(context); + } + + public void remove(WorkflowContext context) { + msoLogger.debug(logMarker + " Removing context from the queue: " + + context.getRequestId()); + responseQueue.remove(context); + } + + public WorkflowContext getWorkflowContext(String requestId) { + // Note: DelayQueue interator is threadsafe + for (WorkflowContext context : responseQueue) { + if (requestId.equals(context.getRequestId())) { + msoLogger.debug("Found context for request id: " + requestId); + return context; + } + } + + msoLogger.debug("Unable to find context for request id: " + requestId); + return null; + } + + /** + * Builds the callback response object to respond to client + * @param processKey + * @param processInstanceId + * @param requestId + * @param callbackResponse + * @return + */ + public void processCallback(String processKey, String processInstanceId, + String requestId, WorkflowCallbackResponse callbackResponse) { + WorkflowResponse workflowResponse = new WorkflowResponse(); + workflowResponse.setResponse(callbackResponse.getResponse()); + workflowResponse.setProcessInstanceID(processInstanceId); + workflowResponse.setMessageCode(callbackResponse.getStatusCode()); + workflowResponse.setMessage(callbackResponse.getMessage()); + WorkflowContext context = new WorkflowContext(processKey, requestId, defaultContextTimeout,workflowResponse); + put(context); + } + + + /** + * Timeout thread which monitors the delay queue for expired context and send timeout response + * to client + * + * */ + private class TimeoutThread extends Thread { + @Override + public void run() { + while (!isInterrupted()) { + try { + WorkflowContext requestObject = responseQueue.take(); + MsoLogger.setLogContext(requestObject.getRequestId(), null); + msoLogger.debug("Time remaining for request id: " + requestObject.getRequestId() + ":" + requestObject.getDelay(TimeUnit.MILLISECONDS)); + msoLogger.debug("Preparing timeout response for " + requestObject.getProcessKey() + ":" + ":" + requestObject.getRequestId()); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } catch (Exception e) { + msoLogger.debug("WorkflowContextHolder timeout thread caught exception: " + e); + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError, "Error in WorkflowContextHolder timeout thread"); + + } + } + msoLogger.debug("WorkflowContextHolder timeout thread interrupted, quitting"); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowResponse.java new file mode 100644 index 0000000000..f5aa0b33c6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/workflow/context/WorkflowResponse.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.workflow.context; + +import java.util.Map; + +/** + * @version 1.0 + * Synchronous workflow response bean + * + */ + +public class WorkflowResponse { + + private String response; + private String message; + private String processInstanceID; + private Map<String,String> variables; + private int messageCode; + + public String getResponse() { + return response; + } + public void setResponse(String response) { + this.response = response; + } + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + public String getProcessInstanceID() { + return processInstanceID; + } + public void setProcessInstanceID(String pID) { + this.processInstanceID = pID; + } + public Map<String, String> getVariables() { + return variables; + } + public void setVariables(Map<String, String> variables) { + this.variables = variables; + } + public void setMessageCode(int messageCode) { + this.messageCode = messageCode; + } + + public int getMessageCode() { + return messageCode; + } + + @Override + public String toString() { + return "WorkflowResponse [response=" + response + ", message=" + message + ", processInstanceID=" + + processInstanceID + ", variables=" + variables + ", messageCode=" + messageCode + "]"; + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/Metadata.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/Metadata.java new file mode 100644 index 0000000000..1f83c3135e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/Metadata.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Metadatum; + +public class Metadata implements Serializable{ + + private static final long serialVersionUID = 4981393122007858950L; + + @JsonProperty("metadatum") + private List<Metadatum> metadatum = new ArrayList<Metadatum>(); + + public List<Metadatum> getMetadatum() { + return metadatum; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/ShallowCopy.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/ShallowCopy.java new file mode 100644 index 0000000000..1263e7ba7c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/ShallowCopy.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import javax.persistence.Id; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public interface ShallowCopy<T> { + default T shallowCopyId() { + try { + T obj = (T) this.getClass().newInstance(); + for (Field field : this.getClass().getDeclaredFields()) { + if (field.isAnnotationPresent(Id.class)) { + String fieldName = Character.toUpperCase(field.getName().charAt(0)) + field.getName().substring(1); + Method setter = this.getClass().getMethod("set" + fieldName, field.getType()); + Method getter = this.getClass().getMethod("get" + fieldName, null); + setter.invoke(obj, getter.invoke(this, null)); + } + } + return obj; + }catch(Exception e){ + throw new RuntimeException(e); + } + + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AllottedResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AllottedResource.java new file mode 100644 index 0000000000..775d80db75 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AllottedResource.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; +import org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionCandidates; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoAllottedResource; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.EqualsBuilder; + +@JsonRootName("allotted-resource") +public class AllottedResource extends SolutionCandidates implements Serializable, ShallowCopy<AllottedResource> { + + private static final long serialVersionUID = 8674239064804424306L; + + @Id + @JsonProperty("id") + private String id; + @JsonProperty("target-network-role") + private String targetNetworkRole; + @JsonProperty("self-link") + private String selflink; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("operational-status") + private String operationalStatus; + @JsonProperty("type") + private String type; + @JsonProperty("role") + private String role; + @JsonProperty("model-info-allotted-resource") + private ModelInfoAllottedResource modelInfoAllottedResource; + @JsonProperty("service-instance") + private ServiceInstance parentServiceInstance; + + public ModelInfoAllottedResource getModelInfoAllottedResource() { + return modelInfoAllottedResource; + } + public void setModelInfoAllottedResource(ModelInfoAllottedResource modelInfoAllottedResource) { + this.modelInfoAllottedResource = modelInfoAllottedResource; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getTargetNetworkRole() { + return targetNetworkRole; + } + public void setTargetNetworkRole(String targetNetworkRole) { + this.targetNetworkRole = targetNetworkRole; + } + public String getSelflink() { + return selflink; + } + public void setSelflink(String selflink) { + this.selflink = selflink; + } + public String getOperationalStatus() { + return operationalStatus; + } + public void setOperationalStatus(String operationalStatus) { + this.operationalStatus = operationalStatus; + } + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getRole() { + return role; + } + public void setRole(String role) { + this.role = role; + } + public ServiceInstance getParentServiceInstance() { + return parentServiceInstance; + } + public void setParentServiceInstance(ServiceInstance parentServiceInstance) { + this.parentServiceInstance = parentServiceInstance; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof AllottedResource)) { + return false; + } + AllottedResource castOther = (AllottedResource) other; + return new EqualsBuilder().append(id, castOther.id).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(id).toHashCode(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CloudRegion.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CloudRegion.java new file mode 100644 index 0000000000..f39253e6aa --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CloudRegion.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +public class CloudRegion implements Serializable, ShallowCopy<CloudRegion> { + + private static final long serialVersionUID = 680593168655326021L; + + @Id + @JsonProperty("lcp-cloud-region-id") + private String lcpCloudRegionId; + @Id + @JsonProperty("cloud-owner") + private String cloudOwner; + @JsonProperty("tenant-id") + private String tenantId; + @JsonProperty("complex") + private String complex; + @JsonProperty("cloud-region-version") + private String cloudRegionVersion; + + public String getLcpCloudRegionId() { + return lcpCloudRegionId; + } + public void setLcpCloudRegionId(String lcpCloudRegionId) { + this.lcpCloudRegionId = lcpCloudRegionId; + } + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getCloudOwner() { + return cloudOwner; + } + public void setCloudOwner(String cloudOwner) { + this.cloudOwner = cloudOwner; + } + /** + * i.e. aic version + */ + public String getCloudRegionVersion() { + return cloudRegionVersion; + } + /** + * i.e. aic version + */ + public void setCloudRegionVersion(String cloudRegionVersion) { + this.cloudRegionVersion = cloudRegionVersion; + } + /** + * i.e. aic clli, physical location id, site id + */ + public String getComplex() { + return complex; + } + /** + * i.e. aic clli, physical location id, site id + */ + public void setComplex(String complex) { + this.complex = complex; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof CloudRegion)) { + return false; + } + CloudRegion castOther = (CloudRegion) other; + return new EqualsBuilder().append(lcpCloudRegionId, castOther.lcpCloudRegionId) + .append(cloudOwner, castOther.cloudOwner).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(lcpCloudRegionId).append(cloudOwner).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Collection.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Collection.java new file mode 100644 index 0000000000..6bbdb1ed67 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Collection.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + + +@JsonRootName("collection") +public class Collection implements Serializable, ShallowCopy<Collection> { + + private static final long serialVersionUID = 6389915895863066288L; + + @Id + @JsonProperty("id") + private String id; + @JsonProperty("model-info-collection") + private ModelInfoCollection modelInfoCollection; + @JsonProperty("instance-group") + private InstanceGroup instanceGroup; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("name") + private String name; + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public ModelInfoCollection getModelInfoCollection() { + return modelInfoCollection; + } + public void setModelInfoCollection(ModelInfoCollection modelInfoCollection) { + this.modelInfoCollection = modelInfoCollection; + } + public InstanceGroup getInstanceGroup() { + return instanceGroup; + } + public void setInstanceGroup(InstanceGroup instanceGroup) { + this.instanceGroup = instanceGroup; + } + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof Collection)) { + return false; + } + Collection castOther = (Collection) other; + return new EqualsBuilder().append(id, castOther.id).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(id).toHashCode(); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Configuration.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Configuration.java new file mode 100644 index 0000000000..bcff93c5af --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Configuration.java @@ -0,0 +1,230 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.Metadata; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import javax.persistence.Id; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("configuration") +public class Configuration implements Serializable, ShallowCopy<Configuration> { + private static final long serialVersionUID = 4525487672816730299L; + + @Id + @JsonProperty("configuration-id") + private String configurationId; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("tunnel-bandwidth") + private String tunnelBandwidth; + @JsonProperty("vendor-allowed-max-bandwidth") + private String vendorAllowedMaxBandwidth; + @JsonProperty("management-option") + private String managementOption; + @JsonProperty("configuration-name") + private String configurationName; + @JsonProperty("configuration-type") + private String configurationType; + @JsonProperty("configuration-sub-type") + private String configurationSubType; + @JsonProperty("operational-status") + private String operationalStatus; + @JsonProperty("configuration-selflink") + private String configurationSelflink; + @JsonProperty("metadata") + private Metadata metadata; + @JsonProperty("forwarder-evcs") + private List<ForwarderEvc> forwarderEvcs = new ArrayList<ForwarderEvc>(); + @JsonProperty("evcs") + private List<Evc> evcs = new ArrayList<Evc>(); + @JsonProperty("model-info-configuration") + private ModelInfoConfiguration modelInfoConfiguration; + + @JsonProperty("related-configuration") + private Configuration relatedConfiguration; + + @JsonProperty("l3-network") + private L3Network network; + + @JsonProperty("l-interface") + private LInterface lInterface; + + public ModelInfoConfiguration getModelInfoConfiguration() { + return modelInfoConfiguration; + } + + public void setModelInfoConfiguration(ModelInfoConfiguration modelInfoConfiguration) { + this.modelInfoConfiguration = modelInfoConfiguration; + } + + public List<ForwarderEvc> getForwarderEvcs() { + return forwarderEvcs; + } + + public List<Evc> getEvcs() { + return evcs; + } + + public String getConfigurationId() { + return configurationId; + } + + public void setConfigurationId(String configurationId) { + this.configurationId = configurationId; + } + + public String getManagementOption() { + return managementOption; + } + + public void setManagementOption(String managementOption) { + this.managementOption = managementOption; + } + + public String getConfigurationName() { + return configurationName; + } + + public void setConfigurationName(String configurationName) { + this.configurationName = configurationName; + } + + public String getConfigurationType() { + return configurationType; + } + + public void setConfigurationType(String configurationType) { + this.configurationType = configurationType; + } + + public String getConfigurationSubType() { + return configurationSubType; + } + + public void setConfigurationSubType(String configurationSubType) { + this.configurationSubType = configurationSubType; + } + + public String getOperationalStatus() { + return operationalStatus; + } + + public void setOperationalStatus(String operationalStatus) { + this.operationalStatus = operationalStatus; + } + + public String getConfigurationSelflink() { + return configurationSelflink; + } + + public void setConfigurationSelflink(String configurationSelflink) { + this.configurationSelflink = configurationSelflink; + } + + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public String getTunnelBandwidth() { + return tunnelBandwidth; + } + + public void setTunnelBandwidth(String tunnelBandwidth) { + this.tunnelBandwidth = tunnelBandwidth; + } + + public String getVendorAllowedMaxBandwidth() { + return vendorAllowedMaxBandwidth; + } + + public void setVendorAllowedMaxBandwidth(String vendorAllowedMaxBandwidth) { + this.vendorAllowedMaxBandwidth = vendorAllowedMaxBandwidth; + } + + public Metadata getMetadata() { + return metadata; + } + + public void setMetadata(Metadata metadata) { + this.metadata = metadata; + } + + public Configuration getRelatedConfiguration() { + return relatedConfiguration; + } + + public void setRelatedConfiguration(Configuration relatedConfiguration) { + this.relatedConfiguration = relatedConfiguration; + } + + public void setForwarderEvcs(List<ForwarderEvc> forwarderEvcs) { + this.forwarderEvcs = forwarderEvcs; + } + + public void setEvcs(List<Evc> evcs) { + this.evcs = evcs; + } + + public L3Network getNetwork() { + return network; + } + + public void setNetwork(L3Network network) { + this.network = network; + } + + public LInterface getlInterface() { + return lInterface; + } + + public void setlInterface(LInterface lInterface) { + this.lInterface = lInterface; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof Configuration)) { + return false; + } + Configuration castOther = (Configuration) other; + return new EqualsBuilder().append(configurationId, castOther.configurationId).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(configurationId).toHashCode(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CtagAssignment.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CtagAssignment.java new file mode 100644 index 0000000000..937c79be1d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/CtagAssignment.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("ctag-assignment") +public class CtagAssignment implements Serializable, ShallowCopy<CtagAssignment> { + + private static final long serialVersionUID = 2314290576523243571L; + + @Id + @JsonProperty("vlan-id-inner") + private long vlanIdInner; + + public long getVlanIdInner() { + return vlanIdInner; + } + + public void setVlanIdInner(long vlanIdInner) { + this.vlanIdInner = vlanIdInner; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof CtagAssignment)) { + return false; + } + CtagAssignment castOther = (CtagAssignment) other; + return new EqualsBuilder().append(vlanIdInner, castOther.vlanIdInner).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(vlanIdInner).toHashCode(); + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Customer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Customer.java new file mode 100644 index 0000000000..985f51035c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Customer.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("customer") +public class Customer implements Serializable, ShallowCopy<Customer> { + + private static final long serialVersionUID = 2006599484099139618L; + + @Id + @JsonProperty("global-customer-id") + private String globalCustomerId; + @JsonProperty("subscriber-name") + private String subscriberName; + @JsonProperty("subscriber-type") + private String subscriberType; + @JsonProperty("subscriber-common-site-id") + private String subscriberCommonSiteId; + @JsonProperty("service-subscription") + private ServiceSubscription serviceSubscription; + @JsonProperty("vpn-bindings") + private List<VpnBinding> vpnBindings = new ArrayList<>(); + + public String getGlobalCustomerId() { + return globalCustomerId; + } + public void setGlobalCustomerId(String globalCustomerId) { + this.globalCustomerId = globalCustomerId; + } + public String getSubscriberName() { + return subscriberName; + } + public void setSubscriberName(String subscriberName) { + this.subscriberName = subscriberName; + } + public String getSubscriberType() { + return subscriberType; + } + public void setSubscriberType(String subscriberType) { + this.subscriberType = subscriberType; + } + public String getSubscriberCommonSiteId() { + return subscriberCommonSiteId; + } + public void setSubscriberCommonSiteId(String subscriberCommonSiteId) { + this.subscriberCommonSiteId = subscriberCommonSiteId; + } + public ServiceSubscription getServiceSubscription() { + return serviceSubscription; + } + public void setServiceSubscription(ServiceSubscription serviceSubscription) { + this.serviceSubscription = serviceSubscription; + } + public List<VpnBinding> getVpnBindings() { + return vpnBindings; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof Customer)) { + return false; + } + Customer castOther = (Customer) other; + return new EqualsBuilder().append(globalCustomerId, castOther.globalCustomerId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(globalCustomerId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Entitlement.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Entitlement.java new file mode 100644 index 0000000000..fdcb59d3c3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Entitlement.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("entitlement") +public class Entitlement implements Serializable, ShallowCopy<Entitlement>{ + + private static final long serialVersionUID = 5186878328988717088L; + + @Id + @JsonProperty("group-uuid") + private String groupUuid; + @Id + @JsonProperty("resource-uuid") + private String resourceUuid; + + public String getGroupUuid() { + return groupUuid; + } + public void setGroupUuid(String groupUuid) { + this.groupUuid = groupUuid; + } + public String getResourceUuid() { + return resourceUuid; + } + public void setResourceUuid(String resourceUuid) { + this.resourceUuid = resourceUuid; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof Entitlement)) { + return false; + } + Entitlement castOther = (Entitlement) other; + return new EqualsBuilder().append(groupUuid, castOther.groupUuid).append(resourceUuid, castOther.resourceUuid) + .isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(groupUuid).append(resourceUuid).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Evc.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Evc.java new file mode 100644 index 0000000000..3ef0f71386 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Evc.java @@ -0,0 +1,164 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("evc") +public class Evc implements Serializable, ShallowCopy<Evc> { + + private static final long serialVersionUID = -3556506672371317659L; + + @Id + @JsonProperty("evc-id") + private String evcId; + @JsonProperty("forwarding-path-topology") + private String forwardingPathTopology; + @JsonProperty("cir-value") + private String cirValue; + @JsonProperty("cir-units") + private String cirUnits; + @JsonProperty("connection-diversity-group-id") + private String connectionDiversityGroupId; + @JsonProperty("service-hours") + private String serviceHours; + @JsonProperty("esp-evc-circuit-id") + private String espEvcCircuitId; + @JsonProperty("esp-evc-cir-value") + private String espEvcCirValue; + @JsonProperty("esp-evc-cir-units") + private String espEvcCirUnits; + @JsonProperty("esp-itu-code") + private String espItuCode; + @JsonProperty("collector-pop-clli") + private String collectorPopClli; + @JsonProperty("inter-connect-type-ingress") + private String interConnectTypeIngress; + @JsonProperty("tagmode-access-ingress") + private String tagmodeAccessIngress; + @JsonProperty("tagmode-access-egress") + private String tagmodeAccessEgress; + + public String getEvcId() { + return evcId; + } + public void setEvcId(String evcId) { + this.evcId = evcId; + } + public String getForwardingPathTopology() { + return forwardingPathTopology; + } + public void setForwardingPathTopology(String forwardingPathTopology) { + this.forwardingPathTopology = forwardingPathTopology; + } + public String getCirValue() { + return cirValue; + } + public void setCirValue(String cirValue) { + this.cirValue = cirValue; + } + public String getCirUnits() { + return cirUnits; + } + public void setCirUnits(String cirUnits) { + this.cirUnits = cirUnits; + } + public String getConnectionDiversityGroupId() { + return connectionDiversityGroupId; + } + public void setConnectionDiversityGroupId(String connectionDiversityGroupId) { + this.connectionDiversityGroupId = connectionDiversityGroupId; + } + public String getServiceHours() { + return serviceHours; + } + public void setServiceHours(String serviceHours) { + this.serviceHours = serviceHours; + } + public String getEspEvcCircuitId() { + return espEvcCircuitId; + } + public void setEspEvcCircuitId(String espEvcCircuitId) { + this.espEvcCircuitId = espEvcCircuitId; + } + public String getEspEvcCirValue() { + return espEvcCirValue; + } + public void setEspEvcCirValue(String espEvcCirValue) { + this.espEvcCirValue = espEvcCirValue; + } + public String getEspEvcCirUnits() { + return espEvcCirUnits; + } + public void setEspEvcCirUnits(String espEvcCirUnits) { + this.espEvcCirUnits = espEvcCirUnits; + } + public String getEspItuCode() { + return espItuCode; + } + public void setEspItuCode(String espItuCode) { + this.espItuCode = espItuCode; + } + public String getCollectorPopClli() { + return collectorPopClli; + } + public void setCollectorPopClli(String collectorPopClli) { + this.collectorPopClli = collectorPopClli; + } + public String getInterConnectTypeIngress() { + return interConnectTypeIngress; + } + public void setInterConnectTypeIngress(String interConnectTypeIngress) { + this.interConnectTypeIngress = interConnectTypeIngress; + } + public String getTagmodeAccessIngress() { + return tagmodeAccessIngress; + } + public void setTagmodeAccessIngress(String tagmodeAccessIngress) { + this.tagmodeAccessIngress = tagmodeAccessIngress; + } + public String getTagmodeAccessEgress() { + return tagmodeAccessEgress; + } + public void setTagmodeAccessEgress(String tagmodeAccessEgress) { + this.tagmodeAccessEgress = tagmodeAccessEgress; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof Evc)) { + return false; + } + Evc castOther = (Evc) other; + return new EqualsBuilder().append(evcId, castOther.evcId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(evcId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ForwarderEvc.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ForwarderEvc.java new file mode 100644 index 0000000000..70f7d5af42 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ForwarderEvc.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("forwarder-evc") +public class ForwarderEvc implements Serializable, ShallowCopy<ForwarderEvc> { + + private static final long serialVersionUID = 3822241337439817708L; + + @Id + @JsonProperty("forwarder-evc-id") + private String forwarderEvcId; + @JsonProperty("circuit-id") + private String circuitId; + @JsonProperty("ivlan") + private String ivlan; + @JsonProperty("svlan") + private String svlan; + @JsonProperty("cvlan") + private String cvlan; + + public String getForwarderEvcId() { + return forwarderEvcId; + } + + public void setForwarderEvcId(String forwarderEvcId) { + this.forwarderEvcId = forwarderEvcId; + } + + public String getCircuitId() { + return circuitId; + } + + public void setCircuitId(String circuitId) { + this.circuitId = circuitId; + } + + public String getIvlan() { + return ivlan; + } + + public void setIvlan(String ivlan) { + this.ivlan = ivlan; + } + + public String getSvlan() { + return svlan; + } + + public void setSvlan(String svlan) { + this.svlan = svlan; + } + + public String getCvlan() { + return cvlan; + } + + public void setCvlan(String cvlan) { + this.cvlan = cvlan; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ForwarderEvc)) { + return false; + } + ForwarderEvc castOther = (ForwarderEvc) other; + return new EqualsBuilder().append(forwarderEvcId, castOther.forwarderEvcId).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(forwarderEvcId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java new file mode 100644 index 0000000000..218763a006 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java @@ -0,0 +1,510 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; +import org.onap.so.bpmn.servicedecomposition.generalobjects.License; +import org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("generic-vnf") +public class GenericVnf implements Serializable, ShallowCopy<GenericVnf> { + + private static final long serialVersionUID = -5107610336831330403L; + + @Id + @JsonProperty("vnf-id") + private String vnfId; + @JsonProperty("vnf-name") + private String vnfName; + @JsonProperty("vnf-type") + private String vnfType; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("vf-modules") + private List<VfModule> vfModules = new ArrayList<>(); + @JsonProperty("volume-groups") + private List<VolumeGroup> volumeGroups = new ArrayList<>(); + @JsonProperty("line-of-business") + private LineOfBusiness lineOfBusiness; + @JsonProperty("platform") + private Platform platform; + @JsonProperty("cascaded") + private boolean cascaded; + @JsonProperty("cloud-params") + private Map<String, String> cloudParams = new HashMap<>(); + @JsonProperty("cloud-context") + private CloudRegion cloudRegion; + @JsonProperty("solution") + private SolutionInfo solution; + @JsonProperty("vnf-name-2") + private String vnfName2; + @JsonProperty("service-id") + private String serviceId; + @JsonProperty("regional-resource-zone") + private String regionalResourceZone; + @JsonProperty("prov-status") + private String provStatus; + @JsonProperty("operational-status") + private String operationalStatus; + @JsonProperty("equipment-role") + private String equipmentRole; + @JsonProperty("management-option") + private String managementOption; + @JsonProperty("ipv4-oam-address") + private String ipv4OamAddress; + @JsonProperty("ipv4-loopback0-address") + private String ipv4Loopback0Address; + @JsonProperty("nm-lan-v6-address") + private String nmLanV6Address; + @JsonProperty("management-v6-address") + private String managementV6Address; + @JsonProperty("vcpu") + private Long vcpu; + @JsonProperty("vcpu-units") + private String vcpuUnits; + @JsonProperty("vmemory") + private Long vmemory; + @JsonProperty("vmemory-units") + private String vmemoryUnits; + @JsonProperty("vdisk") + private Long vdisk; + @JsonProperty("vdisk-units") + private String vdiskUnits; + @JsonProperty("in-maint") + private boolean inMaint; + @JsonProperty("is-closed-loop-disabled") + private boolean isClosedLoopDisabled; + @JsonProperty("summary-status") + private String summaryStatus; + @JsonProperty("encrypted-access-flag") + private Boolean encryptedAccessFlag; + @JsonProperty("as-number") + private String asNumber; + @JsonProperty("regional-resource-subzone") + private String regionalResourceSubzone; + @JsonProperty("self-link") + private String selflink; + @JsonProperty("ipv4-oam-gateway-address") + private String ipv4OamGatewayAddress; + @JsonProperty("ipv4-oam-gateway-address-prefix-length") + private Integer ipv4OamGatewayAddressPrefixLength; + @JsonProperty("vlan-id-outer") + private Long vlanIdOuter; + @JsonProperty("nm-profile-name") + private String nmProfileName; + @JsonProperty("l-interfaces") + private List<LInterface> lInterfaces = new ArrayList<>(); + @JsonProperty("lag-interfaces") + private List<LagInterface> lagInterfaces = new ArrayList<>(); + @JsonProperty("license") + private License license; + @JsonProperty("entitlements") //TODO remove, duplicated + private List<Entitlement> entitlements = new ArrayList<>(); + @JsonProperty("model-info-generic-vnf") + private ModelInfoGenericVnf modelInfoGenericVnf; + @JsonProperty("instance-groups") + private List<InstanceGroup> instanceGroups = new ArrayList<InstanceGroup>(); + @JsonProperty("call-homing") + private boolean callHoming; + + + public List<InstanceGroup> getInstanceGroups() { + return instanceGroups; + } + + public List<VolumeGroup> getVolumeGroups() { + return volumeGroups; + } + + public ModelInfoGenericVnf getModelInfoGenericVnf() { + return modelInfoGenericVnf; + } + + public void setModelInfoGenericVnf(ModelInfoGenericVnf modelInfoGenericVnf) { + this.modelInfoGenericVnf = modelInfoGenericVnf; + } + + public String getVnfName2() { + return vnfName2; + } + + public void setVnfName2(String vnfName2) { + this.vnfName2 = vnfName2; + } + + public String getServiceId() { + return serviceId; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + public String getRegionalResourceZone() { + return regionalResourceZone; + } + + public void setRegionalResourceZone(String regionalResourceZone) { + this.regionalResourceZone = regionalResourceZone; + } + + public String getProvStatus() { + return provStatus; + } + + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + + public String getOperationalStatus() { + return operationalStatus; + } + + public void setOperationalStatus(String operationalStatus) { + this.operationalStatus = operationalStatus; + } + + public String getEquipmentRole() { + return equipmentRole; + } + + public void setEquipmentRole(String equipmentRole) { + this.equipmentRole = equipmentRole; + } + + public String getManagementOption() { + return managementOption; + } + + public void setManagementOption(String managementOption) { + this.managementOption = managementOption; + } + + public String getIpv4OamAddress() { + return ipv4OamAddress; + } + + public void setIpv4OamAddress(String ipv4OamAddress) { + this.ipv4OamAddress = ipv4OamAddress; + } + + public String getIpv4Loopback0Address() { + return ipv4Loopback0Address; + } + + public void setIpv4Loopback0Address(String ipv4Loopback0Address) { + this.ipv4Loopback0Address = ipv4Loopback0Address; + } + + public String getNmLanV6Address() { + return nmLanV6Address; + } + + public void setNmLanV6Address(String nmLanV6Address) { + this.nmLanV6Address = nmLanV6Address; + } + + public String getManagementV6Address() { + return managementV6Address; + } + + public void setManagementV6Address(String managementV6Address) { + this.managementV6Address = managementV6Address; + } + + public Long getVcpu() { + return vcpu; + } + + public void setVcpu(Long vcpu) { + this.vcpu = vcpu; + } + + public String getVcpuUnits() { + return vcpuUnits; + } + + public void setVcpuUnits(String vcpuUnits) { + this.vcpuUnits = vcpuUnits; + } + + public List<LInterface> getlInterfaces() { + return lInterfaces; + } + + public List<LagInterface> getLagInterfaces() { + return lagInterfaces; + } + + public List<Entitlement> getEntitlements() { + return entitlements; + } + + public List<VfModule> getVfModules() { + return vfModules; + } + + public Long getVmemory() { + return vmemory; + } + + public void setVmemory(Long vmemory) { + this.vmemory = vmemory; + } + + public String getVmemoryUnits() { + return vmemoryUnits; + } + + public void setVmemoryUnits(String vmemoryUnits) { + this.vmemoryUnits = vmemoryUnits; + } + + public Long getVdisk() { + return vdisk; + } + + public void setVdisk(Long vdisk) { + this.vdisk = vdisk; + } + + public String getVdiskUnits() { + return vdiskUnits; + } + + public void setVdiskUnits(String vdiskUnits) { + this.vdiskUnits = vdiskUnits; + } + + public boolean isInMaint() { + return inMaint; + } + + public void setInMaint(boolean inMaint) { + this.inMaint = inMaint; + } + + public boolean isClosedLoopDisabled() { + return isClosedLoopDisabled; + } + + public void setClosedLoopDisabled(boolean isClosedLoopDisabled) { + this.isClosedLoopDisabled = isClosedLoopDisabled; + } + + public String getSummaryStatus() { + return summaryStatus; + } + + public void setSummaryStatus(String summaryStatus) { + this.summaryStatus = summaryStatus; + } + + public Boolean getEncryptedAccessFlag() { + return encryptedAccessFlag; + } + + public void setEncryptedAccessFlag(Boolean encryptedAccessFlag) { + this.encryptedAccessFlag = encryptedAccessFlag; + } + + public String getAsNumber() { + return asNumber; + } + + public void setAsNumber(String asNumber) { + this.asNumber = asNumber; + } + + public String getRegionalResourceSubzone() { + return regionalResourceSubzone; + } + + public void setRegionalResourceSubzone(String regionalResourceSubzone) { + this.regionalResourceSubzone = regionalResourceSubzone; + } + + public License getLicense() { + return license; + } + + public void setLicense(License license) { + this.license = license; + } + + public String getSelflink() { + return selflink; + } + + public void setSelflink(String selflink) { + this.selflink = selflink; + } + + public String getIpv4OamGatewayAddress() { + return ipv4OamGatewayAddress; + } + + public void setIpv4OamGatewayAddress(String ipv4OamGatewayAddress) { + this.ipv4OamGatewayAddress = ipv4OamGatewayAddress; + } + + public Integer getIpv4OamGatewayAddressPrefixLength() { + return ipv4OamGatewayAddressPrefixLength; + } + + public void setIpv4OamGatewayAddressPrefixLength(Integer ipv4OamGatewayAddressPrefixLength) { + this.ipv4OamGatewayAddressPrefixLength = ipv4OamGatewayAddressPrefixLength; + } + + public Long getVlanIdOuter() { + return vlanIdOuter; + } + + public void setVlanIdOuter(Long vlanIdOuter) { + this.vlanIdOuter = vlanIdOuter; + } + + public String getNmProfileName() { + return nmProfileName; + } + + public void setNmProfileName(String nmProfileName) { + this.nmProfileName = nmProfileName; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public LineOfBusiness getLineOfBusiness() { + return lineOfBusiness; + } + + public void setLineOfBusiness(LineOfBusiness lineOfBusiness) { + this.lineOfBusiness = lineOfBusiness; + } + + public Platform getPlatform() { + return platform; + } + + public void setPlatform(Platform platform) { + this.platform = platform; + } + + public boolean isCascaded() { + return cascaded; + } + + public void setCascaded(boolean cascaded) { + this.cascaded = cascaded; + } + + public Map<String, String> getCloudParams() { + return cloudParams; + } + + public void setCloudParams(Map<String, String> cloudParams) { + this.cloudParams = cloudParams; + } + + public SolutionInfo getSolution() { + return solution; + } + + public void setSolution(SolutionInfo solution) { + this.solution = solution; + } + + public CloudRegion getCloudRegion() { + return cloudRegion; + } + + public void setCloudRegion(CloudRegion cloudRegion) { + this.cloudRegion = cloudRegion; + } + + public boolean isCallHoming() { + return callHoming; + } + + public void setCallHoming(boolean callHoming) { + this.callHoming = callHoming; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof GenericVnf)) { + return false; + } + GenericVnf castOther = (GenericVnf) other; + return new EqualsBuilder().append(vnfId, castOther.vnfId).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(vnfId).toHashCode(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/HostRoute.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/HostRoute.java new file mode 100644 index 0000000000..75356ac9db --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/HostRoute.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("host-route") +public class HostRoute implements Serializable, ShallowCopy<HostRoute>{ + + private static final long serialVersionUID = -2468793257174064133L; + + @Id + @JsonProperty("host-route-id") + private String hostRouteId; + @JsonProperty("route-prefix") + private String routePrefix; + @JsonProperty("next-hop") + private String nextHop; + @JsonProperty("next-hop-type") + private String nextHopType; + + public String getHostRouteId() { + return hostRouteId; + } + public void setHostRouteId(String hostRouteId) { + this.hostRouteId = hostRouteId; + } + public String getRoutePrefix() { + return routePrefix; + } + public void setRoutePrefix(String routePrefix) { + this.routePrefix = routePrefix; + } + public String getNextHop() { + return nextHop; + } + public void setNextHop(String nextHop) { + this.nextHop = nextHop; + } + public String getNextHopType() { + return nextHopType; + } + public void setNextHopType(String nextHopType) { + this.nextHopType = nextHopType; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof HostRoute)) { + return false; + } + HostRoute castOther = (HostRoute) other; + return new EqualsBuilder().append(hostRouteId, castOther.hostRouteId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(hostRouteId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java new file mode 100644 index 0000000000..deb8c8e393 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("instance-group") +public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup> { + + private static final long serialVersionUID = -2330859693128099141L; + + @Id + @JsonProperty("id") + private String id; + @JsonProperty("description") + private String description; + @JsonProperty("resource-version") + private String resourceVersion; + @JsonProperty("instance-group-name") + private String instanceGroupName; + @JsonProperty("model-info-instance-group") + private ModelInfoInstanceGroup modelInfoInstanceGroup; + @JsonProperty("instance-group-function") + private String instanceGroupFunction; + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getResourceVersion() { + return resourceVersion; + } + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + public String getInstanceGroupName() { + return instanceGroupName; + } + public void setInstanceGroupName(String instanceGroupName) { + this.instanceGroupName = instanceGroupName; + } + public ModelInfoInstanceGroup getModelInfoInstanceGroup() { + return modelInfoInstanceGroup; + } + public void setModelInfoInstanceGroup(ModelInfoInstanceGroup modelInfoInstanceGroup) { + this.modelInfoInstanceGroup = modelInfoInstanceGroup; + } + public String getInstanceGroupFunction() { + return instanceGroupFunction; + } + public void setInstanceGroupFunction(String instanceGroupFunction) { + this.instanceGroupFunction = instanceGroupFunction; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof InstanceGroup)) { + return false; + } + InstanceGroup castOther = (InstanceGroup) other; + return new EqualsBuilder().append(id, castOther.id).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(id).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3InterfaceIpv4AddressList.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3InterfaceIpv4AddressList.java new file mode 100644 index 0000000000..55b8a752b6 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3InterfaceIpv4AddressList.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("l3-interface-ipv4-address-list") +public class L3InterfaceIpv4AddressList implements Serializable, ShallowCopy<L3InterfaceIpv4AddressList>{ + + private static final long serialVersionUID = -1566884527411610879L; + + @Id + @JsonProperty("l3-interface-ipv4-address") + private String l3InterfaceIpv4Address; + @JsonProperty("l3-interface-ipv4-prefix-length") + private Long l3InterfaceIpv4PrefixLength; + @JsonProperty("vlan-id-inner") + private Long vlanIdInner; + @JsonProperty("vlan-id-outer") + private Long vlanIdOuter; + @JsonProperty("is-floating") + private Boolean isFloating; + @JsonProperty("neutron-network-id") + private String neutronNetworkId; + @JsonProperty("neutron-subnet-id") + private String neutronSubnetId; + + public String getL3InterfaceIpv4Address() { + return l3InterfaceIpv4Address; + } + public void setL3InterfaceIpv4Address(String l3InterfaceIpv4Address) { + this.l3InterfaceIpv4Address = l3InterfaceIpv4Address; + } + public Long getL3InterfaceIpv4PrefixLength() { + return l3InterfaceIpv4PrefixLength; + } + public void setL3InterfaceIpv4PrefixLength(Long l3InterfaceIpv4PrefixLength) { + this.l3InterfaceIpv4PrefixLength = l3InterfaceIpv4PrefixLength; + } + public Long getVlanIdInner() { + return vlanIdInner; + } + public void setVlanIdInner(Long vlanIdInner) { + this.vlanIdInner = vlanIdInner; + } + public Long getVlanIdOuter() { + return vlanIdOuter; + } + public void setVlanIdOuter(Long vlanIdOuter) { + this.vlanIdOuter = vlanIdOuter; + } + public Boolean getIsFloating() { + return isFloating; + } + public void setIsFloating(Boolean isFloating) { + this.isFloating = isFloating; + } + public String getNeutronNetworkId() { + return neutronNetworkId; + } + public void setNeutronNetworkId(String neutronNetworkId) { + this.neutronNetworkId = neutronNetworkId; + } + public String getNeutronSubnetId() { + return neutronSubnetId; + } + public void setNeutronSubnetId(String neutronSubnetId) { + this.neutronSubnetId = neutronSubnetId; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof L3InterfaceIpv4AddressList)) { + return false; + } + L3InterfaceIpv4AddressList castOther = (L3InterfaceIpv4AddressList) other; + return new EqualsBuilder().append(l3InterfaceIpv4Address, castOther.l3InterfaceIpv4Address).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(l3InterfaceIpv4Address).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3InterfaceIpv6AddressList.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3InterfaceIpv6AddressList.java new file mode 100644 index 0000000000..209c64762f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3InterfaceIpv6AddressList.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("l3-interface-ipv6-address-list") +public class L3InterfaceIpv6AddressList implements Serializable, ShallowCopy<L3InterfaceIpv6AddressList> { + + private static final long serialVersionUID = -414901751774739052L; + + @Id + @JsonProperty("l3-interface-ipv6-address") + private String l3InterfaceIpv6Address; + @JsonProperty("l3-interface-ipv6-prefix-length") + private Long l3InterfaceIpv6PrefixLength; + @JsonProperty("vlan-id-inner") + private Long vlanIdInner; + @JsonProperty("vlan-id-outer") + private Long vlanIdOuter; + @JsonProperty("is-floating") + private Boolean isFloating; + @JsonProperty("neutron-network-id") + private String neutronNetworkId; + @JsonProperty("neutron-subnet-id") + private String neutronSubnetId; + + public String getL3InterfaceIpv6Address() { + return l3InterfaceIpv6Address; + } + + public void setL3InterfaceIpv6Address(String l3InterfaceIpv6Address) { + this.l3InterfaceIpv6Address = l3InterfaceIpv6Address; + } + + public Long getL3InterfaceIpv6PrefixLength() { + return l3InterfaceIpv6PrefixLength; + } + + public void setL3InterfaceIpv6PrefixLength(Long l3InterfaceIpv6PrefixLength) { + this.l3InterfaceIpv6PrefixLength = l3InterfaceIpv6PrefixLength; + } + + public Long getVlanIdInner() { + return vlanIdInner; + } + + public void setVlanIdInner(Long vlanIdInner) { + this.vlanIdInner = vlanIdInner; + } + + public Long getVlanIdOuter() { + return vlanIdOuter; + } + + public void setVlanIdOuter(Long vlanIdOuter) { + this.vlanIdOuter = vlanIdOuter; + } + + public Boolean getIsFloating() { + return isFloating; + } + + public void setIsFloating(Boolean isFloating) { + this.isFloating = isFloating; + } + + public String getNeutronNetworkId() { + return neutronNetworkId; + } + + public void setNeutronNetworkId(String neutronNetworkId) { + this.neutronNetworkId = neutronNetworkId; + } + + public String getNeutronSubnetId() { + return neutronSubnetId; + } + + public void setNeutronSubnetId(String neutronSubnetId) { + this.neutronSubnetId = neutronSubnetId; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof L3InterfaceIpv6AddressList)) { + return false; + } + L3InterfaceIpv6AddressList castOther = (L3InterfaceIpv6AddressList) other; + return new EqualsBuilder().append(l3InterfaceIpv6Address, castOther.l3InterfaceIpv6Address).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(l3InterfaceIpv6Address).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java new file mode 100644 index 0000000000..51cd998073 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java @@ -0,0 +1,269 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("l3Network") +public class L3Network implements Serializable, ShallowCopy<L3Network> { + + private static final long serialVersionUID = 4434492567957111317L; + + @Id + @JsonProperty("network-id") + private String networkId; + @JsonProperty("cascaded") + private boolean cascaded; + @JsonProperty("cloud-params") + private Map<String, String> cloudParams = new HashMap<>(); + @JsonProperty("network-name") + private String networkName; + @JsonProperty("neutron-network-id") + private String neutronNetworkId; + @JsonProperty("network-type") + private String networkType; + @JsonProperty("network-technology") + private String networkTechnology; + @JsonProperty("network-role") + private String networkRole; + @JsonProperty("is-bound-to-vpn") + private boolean isBoundToVpn; + @JsonProperty("service-id") + private String serviceId; + @JsonProperty("network-role-instance") + private Long networkRoleInstance; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("heat-stack-id") + private String heatStackId; + @JsonProperty("contrail-network-fqdn") + private String contrailNetworkFqdn; + @JsonProperty("network-policies") + private List<NetworkPolicy> networkPolicies = new ArrayList<>(); + @JsonProperty("contrail-network-route-table-references") + private List<RouteTableReference> contrailNetworkRouteTableReferences = new ArrayList<>(); + @JsonProperty("widget-model-id") + private String widgetModelId; + @JsonProperty("widget-model-version") + private String widgetModelVersion; + @JsonProperty("physical-network-name") + private String physicalNetworkName; + @JsonProperty("is-provider-network") + private boolean isProviderNetwork; + @JsonProperty("is-shared-network") + private boolean isSharedNetwork; + @JsonProperty("is-external-network") + private boolean isExternalNetwork; + @JsonProperty("self-link") + private String selflink; + @JsonProperty("operational-status") + private String operationalStatus; + @JsonProperty("subnets") + private List<Subnet> subnets = new ArrayList<>(); + @JsonProperty("ctag-assignments") + private List<CtagAssignment> ctagAssignments = new ArrayList<>(); + @JsonProperty("segmentation-assignments") + private List<SegmentationAssignment> segmentationAssignments = new ArrayList<>(); + @JsonProperty("model-info-network") + private ModelInfoNetwork modelInfoNetwork; + + public ModelInfoNetwork getModelInfoNetwork() { + return modelInfoNetwork; + } + public void setModelInfoNetwork(ModelInfoNetwork modelInfoNetwork) { + this.modelInfoNetwork = modelInfoNetwork; + } + public String getNeutronNetworkId() { + return neutronNetworkId; + } + public void setNeutronNetworkId(String neutronNetworkId) { + this.neutronNetworkId = neutronNetworkId; + } + 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; + } + public String getNetworkTechnology() { + return networkTechnology; + } + public void setNetworkTechnology(String networkTechnology) { + this.networkTechnology = networkTechnology; + } + public String getNetworkRole() { + return networkRole; + } + public void setNetworkRole(String networkRole) { + this.networkRole = networkRole; + } + public boolean isBoundToVpn() { + return isBoundToVpn; + } + public void setIsBoundToVpn(boolean isBoundToVpn) { + this.isBoundToVpn = isBoundToVpn; + } + public String getServiceId() { + return serviceId; + } + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + public Long getNetworkRoleInstance() { + return networkRoleInstance; + } + public void setNetworkRoleInstance(Long networkRoleInstance) { + this.networkRoleInstance = networkRoleInstance; + } + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + public String getHeatStackId() { + return heatStackId; + } + public void setHeatStackId(String heatStackId) { + this.heatStackId = heatStackId; + } + public String getContrailNetworkFqdn() { + return contrailNetworkFqdn; + } + public void setContrailNetworkFqdn(String contrailNetworkFqdn) { + this.contrailNetworkFqdn = contrailNetworkFqdn; + } + public List<NetworkPolicy> getNetworkPolicies() { + return networkPolicies; + } + public List<RouteTableReference> getContrailNetworkRouteTableReferences() { + return contrailNetworkRouteTableReferences; + } + public String getWidgetModelId() { + return widgetModelId; + } + public void setWidgetModelId(String widgetModelId) { + this.widgetModelId = widgetModelId; + } + public String getWidgetModelVersion() { + return widgetModelVersion; + } + public void setWidgetModelVersion(String widgetModelVersion) { + this.widgetModelVersion = widgetModelVersion; + } + public String getPhysicalNetworkName() { + return physicalNetworkName; + } + public void setPhysicalNetworkName(String physicalNetworkName) { + this.physicalNetworkName = physicalNetworkName; + } + public boolean isProviderNetwork() { + return isProviderNetwork; + } + public void setIsProviderNetwork(boolean isProviderNetwork) { + this.isProviderNetwork = isProviderNetwork; + } + public boolean isSharedNetwork() { + return isSharedNetwork; + } + public void setIsSharedNetwork(boolean isSharedNetwork) { + this.isSharedNetwork = isSharedNetwork; + } + public boolean isExternalNetwork() { + return isExternalNetwork; + } + public void setIsExternalNetwork(boolean isExternalNetwork) { + this.isExternalNetwork = isExternalNetwork; + } + public String getSelflink() { + return selflink; + } + public void setSelflink(String selflink) { + this.selflink = selflink; + } + public String getOperationalStatus() { + return operationalStatus; + } + public void setOperationalStatus(String operationalStatus) { + this.operationalStatus = operationalStatus; + } + + public List<Subnet> getSubnets() { + return subnets; + } + public List<CtagAssignment> getCtagAssignments() { + return ctagAssignments; + } + public List<SegmentationAssignment> getSegmentationAssignments() { + return segmentationAssignments; + } + public boolean isCascaded() { + return cascaded; + } + public void setIsCascaded(boolean cascaded) { + this.cascaded = cascaded; + } + public Map<String, String> getCloudParams() { + return cloudParams; + } + public void setCloudParams(Map<String, String> cloudParams) { + this.cloudParams = cloudParams; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof L3Network)) { + return false; + } + L3Network castOther = (L3Network) other; + return new EqualsBuilder().append(networkId, castOther.networkId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(networkId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LInterface.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LInterface.java new file mode 100644 index 0000000000..4bba39ee62 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LInterface.java @@ -0,0 +1,191 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("l-interface") +public class LInterface implements Serializable, ShallowCopy<LInterface>{ + + private static final long serialVersionUID = 5629921809747079453L; + + @Id + @JsonProperty("interface-name") + private String interfaceName; + @JsonProperty("interface-role") + private String interfaceRole; + @JsonProperty("v6-wan-link-ip") + private String v6WanLinkIp; + @JsonProperty("self-link") + private String selflink; + @JsonProperty("interface-id") + private String interfaceId; + @JsonProperty("macaddr") + private String macaddr; + @JsonProperty("network-name") + private String networkName; + @JsonProperty("management-option") + private String managementOption; + @JsonProperty("interface-description") + private String interfaceDescription; + @JsonProperty("is-port-mirrored") + private boolean isPortMirrored; + @JsonProperty("in-maint") + private boolean inMaint; + @JsonProperty("prov-status") + private String provStatus; + @JsonProperty("is-ip-unnumbered") + private boolean isIpUnnumbered; + @JsonProperty("allowed-address-pairs") + private String allowedAddressPairs; + @JsonProperty("vlans") + private List<Vlan> vlans = new ArrayList<Vlan>(); + @JsonProperty("sriov-vfs") + private List<SriovVf> sriovVfs = new ArrayList<SriovVf>(); + @JsonProperty("l-interfaces") + private List<LInterface> lInterfaces = new ArrayList<LInterface>(); + @JsonProperty("l3-interface-ipv4-address-list") + private List<L3InterfaceIpv4AddressList> l3InterfaceIpv4AddressList = new ArrayList<L3InterfaceIpv4AddressList>(); + @JsonProperty("l3-interface-ipv6-address-list") + private List<L3InterfaceIpv6AddressList> l3InterfaceIpv6AddressList = new ArrayList<L3InterfaceIpv6AddressList>(); + + public String getInterfaceName() { + return interfaceName; + } + public void setInterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + public String getInterfaceRole() { + return interfaceRole; + } + public void setInterfaceRole(String interfaceRole) { + this.interfaceRole = interfaceRole; + } + public String getV6WanLinkIp() { + return v6WanLinkIp; + } + public void setV6WanLinkIp(String v6WanLinkIp) { + this.v6WanLinkIp = v6WanLinkIp; + } + public String getSelflink() { + return selflink; + } + public void setSelflink(String selflink) { + this.selflink = selflink; + } + public String getInterfaceId() { + return interfaceId; + } + public void setInterfaceId(String interfaceId) { + this.interfaceId = interfaceId; + } + public String getMacaddr() { + return macaddr; + } + public void setMacaddr(String macaddr) { + this.macaddr = macaddr; + } + public String getNetworkName() { + return networkName; + } + public void setNetworkName(String networkName) { + this.networkName = networkName; + } + public String getManagementOption() { + return managementOption; + } + public void setManagementOption(String managementOption) { + this.managementOption = managementOption; + } + public String getInterfaceDescription() { + return interfaceDescription; + } + public void setInterfaceDescription(String interfaceDescription) { + this.interfaceDescription = interfaceDescription; + } + public boolean isPortMirrored() { + return isPortMirrored; + } + public void setPortMirrored(boolean isPortMirrored) { + this.isPortMirrored = isPortMirrored; + } + public boolean isInMaint() { + return inMaint; + } + public void setInMaint(boolean inMaint) { + this.inMaint = inMaint; + } + public String getProvStatus() { + return provStatus; + } + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + public boolean isIpUnnumbered() { + return isIpUnnumbered; + } + public void setIpUnnumbered(boolean isIpUnnumbered) { + this.isIpUnnumbered = isIpUnnumbered; + } + public String getAllowedAddressPairs() { + return allowedAddressPairs; + } + public void setAllowedAddressPairs(String allowedAddressPairs) { + this.allowedAddressPairs = allowedAddressPairs; + } + public List<Vlan> getVlans() { + return vlans; + } + public List<SriovVf> getSriovVfs() { + return sriovVfs; + } + public List<LInterface> getlInterfaces() { + return lInterfaces; + } + public List<L3InterfaceIpv4AddressList> getL3InterfaceIpv4AddressList() { + return l3InterfaceIpv4AddressList; + } + public List<L3InterfaceIpv6AddressList> getL3InterfaceIpv6AddressList() { + return l3InterfaceIpv6AddressList; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof LInterface)) { + return false; + } + LInterface castOther = (LInterface) other; + return new EqualsBuilder().append(interfaceName, castOther.interfaceName).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(interfaceName).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LagInterface.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LagInterface.java new file mode 100644 index 0000000000..8a3248e92c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LagInterface.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("lag-interface") +public class LagInterface implements Serializable, ShallowCopy<LagInterface>{ + + private static final long serialVersionUID = -7493461787172382640L; + + @Id + @JsonProperty("interface-name") + private String interfaceName; + @JsonProperty("interface-description") + private String interfaceDescription; + @JsonProperty("speed-value") + private String speedValue; + @JsonProperty("speed-units") + private String speedUnits; + @JsonProperty("interface-id") + private String interfaceId; + @JsonProperty("interface-role") + private String interfaceRole; + @JsonProperty("prov-status") + private String provStatus; + @JsonProperty("in-maint") + private boolean inMaint; + @JsonProperty("l-interfaces") + private List<LInterface> lInterfaces = new ArrayList<>(); + + public String getInterfaceName() { + return interfaceName; + } + public void setInterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + public String getInterfaceDescription() { + return interfaceDescription; + } + public void setInterfaceDescription(String interfaceDescription) { + this.interfaceDescription = interfaceDescription; + } + public String getSpeedValue() { + return speedValue; + } + public void setSpeedValue(String speedValue) { + this.speedValue = speedValue; + } + public String getSpeedUnits() { + return speedUnits; + } + public void setSpeedUnits(String speedUnits) { + this.speedUnits = speedUnits; + } + public String getInterfaceId() { + return interfaceId; + } + public void setInterfaceId(String interfaceId) { + this.interfaceId = interfaceId; + } + public String getInterfaceRole() { + return interfaceRole; + } + public void setInterfaceRole(String interfaceRole) { + this.interfaceRole = interfaceRole; + } + public String getProvStatus() { + return provStatus; + } + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + public boolean isInMaint() { + return inMaint; + } + public void setInMaint(boolean inMaint) { + this.inMaint = inMaint; + } + public List<LInterface> getlInterfaces() { + return lInterfaces; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof LagInterface)) { + return false; + } + LagInterface castOther = (LagInterface) other; + return new EqualsBuilder().append(interfaceName, castOther.interfaceName).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(interfaceName).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LineOfBusiness.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LineOfBusiness.java new file mode 100644 index 0000000000..5868da563c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LineOfBusiness.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("line-of-business") +public class LineOfBusiness implements Serializable, ShallowCopy<LineOfBusiness> { + + private static final long serialVersionUID = -7697815326894443926L; + + @Id + @JsonProperty("line-of-business-name") + private String lineOfBusinessName; + + public String getLineOfBusinessName() { + return lineOfBusinessName; + } + + public void setLineOfBusinessName(String lineOfBusinessName) { + this.lineOfBusinessName = lineOfBusinessName; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof LineOfBusiness)) { + return false; + } + LineOfBusiness castOther = (LineOfBusiness) other; + return new EqualsBuilder().append(lineOfBusinessName, castOther.lineOfBusinessName).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(lineOfBusinessName).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Metadatum.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Metadatum.java new file mode 100644 index 0000000000..2e7d278901 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Metadatum.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +public class Metadatum implements Serializable, ShallowCopy<Metadatum>{ + + private static final long serialVersionUID = -2259570072414712965L; + + @Id + @JsonProperty("metaname") + private String metaname; + @JsonProperty("metaval") + private String metaval; + + public String getMetaname() { + return metaname; + } + public void setMetaname(String metaname) { + this.metaname = metaname; + } + public String getMetaval() { + return metaval; + } + public void setMetaval(String metaval) { + this.metaval = metaval; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof Metadatum)) { + return false; + } + Metadatum castOther = (Metadatum) other; + return new EqualsBuilder().append(metaname, castOther.metaname).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(metaname).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/NetworkPolicy.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/NetworkPolicy.java new file mode 100644 index 0000000000..a920a585cb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/NetworkPolicy.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +public class NetworkPolicy implements Serializable, ShallowCopy<NetworkPolicy>{ + + private static final long serialVersionUID = 8925599588239522447L; + + @Id + @JsonProperty("network-policy-id") + private String networkPolicyId; + @JsonProperty("network-policy-fqdn") + private String networkPolicyFqdn; + @JsonProperty("heat-stack-id") + private String heatStackId; + @JsonProperty("resource-version") + private String resourceVersion; + + public String getNetworkPolicyId() { + return this.networkPolicyId; + } + + public void setNetworkPolicyId(String networkPolicyId) { + this.networkPolicyId = networkPolicyId; + } + + public String getNetworkPolicyFqdn() { + return this.networkPolicyFqdn; + } + + public void setNetworkPolicyFqdn(String networkPolicyFqdn) { + this.networkPolicyFqdn = networkPolicyFqdn; + } + + public String getHeatStackId() { + return this.heatStackId; + } + + public void setHeatStackId(String heatStackId) { + this.heatStackId = heatStackId; + } + + public String getResourceVersion() { + return this.resourceVersion; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof NetworkPolicy)) { + return false; + } + NetworkPolicy castOther = (NetworkPolicy) other; + return new EqualsBuilder().append(networkPolicyId, castOther.networkPolicyId).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(networkPolicyId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/OwningEntity.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/OwningEntity.java new file mode 100644 index 0000000000..e28e41ed46 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/OwningEntity.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("owning-entity") +public class OwningEntity implements Serializable, ShallowCopy<OwningEntity> { + + private static final long serialVersionUID = -6565917570694869603L; + + @Id + @JsonProperty("owning-entity-id") + private String owningEntityId; + @JsonProperty("owning-entity-name") + private String owningEntityName; + + public String getOwningEntityId() { + return owningEntityId; + } + public void setOwningEntityId(String owningEntityId) { + this.owningEntityId = owningEntityId; + } + public String getOwningEntityName() { + return owningEntityName; + } + public void setOwningEntityName(String owningEntityName) { + this.owningEntityName = owningEntityName; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof OwningEntity)) { + return false; + } + OwningEntity castOther = (OwningEntity) other; + return new EqualsBuilder().append(owningEntityId, castOther.owningEntityId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(owningEntityId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PServer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PServer.java new file mode 100644 index 0000000000..498d096e65 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PServer.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; + + +public class PServer implements Serializable, ShallowCopy<PServer> { + + private static final long serialVersionUID = 1378547515775540874L; + + @Id + @JsonProperty("pserver-id") + private String pserverId; + @JsonProperty("hostname") + private String hostname; + @JsonProperty("physical-links") + private List<PhysicalLink> physicalLinks = new ArrayList<PhysicalLink>(); //TODO techincally there is a pInterface between (pserver <--> physical-link) but dont really need that pojo + + public String getPserverId(){ + return pserverId; + } + + public void setPserverId(String pserverId){ + this.pserverId = pserverId; + } + + public String getHostname(){ + return hostname; + } + + public void setHostname(String hostname){ + this.hostname = hostname; + } + + public List<PhysicalLink> getPhysicalLinks(){ + return physicalLinks; + } + + @Override + public boolean equals(final Object other){ + if(!(other instanceof PServer)){ + return false; + } + PServer castOther = (PServer) other; + return new EqualsBuilder().append(pserverId, castOther.pserverId).isEquals(); + } + + @Override + public int hashCode(){ + return new HashCodeBuilder().append(pserverId).toHashCode(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PhysicalLink.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PhysicalLink.java new file mode 100644 index 0000000000..4f54139386 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PhysicalLink.java @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("physical-link") +public class PhysicalLink implements Serializable, ShallowCopy<PhysicalLink> { + + private static final long serialVersionUID = -6378347998443741227L; + + @Id + @JsonProperty("link-name") + private String linkName; + @JsonProperty("interface-name") + private String interfaceName; + @JsonProperty("service-provider-name") + private String serviceProviderName; + @JsonProperty("circuit-id") + private String circuitId; + @JsonProperty("management-option") + private String managementOption; + @JsonProperty("bandwidth-up") + private int bandwidthUp; + @JsonProperty("bandwidth-down") + private int bandwidthDown; + @JsonProperty("bandwidth-units") + private String bandwidthUnits; + @JsonProperty("wan-port") + private String wanPort; + + + public String getLinkName(){ + return linkName; + } + + public void setLinkName(String linkName){ + this.linkName = linkName; + } + + public String getInterfaceName(){ + return interfaceName; + } + + public void setInterfaceName(String interfaceName){ + this.interfaceName = interfaceName; + } + + + public String getServiceProviderName(){ + return serviceProviderName; + } + + + public void setServiceProviderName(String serviceProviderName){ + this.serviceProviderName = serviceProviderName; + } + + public String getCircuitId(){ + return circuitId; + } + + public void setCircuitId(String circuitId){ + this.circuitId = circuitId; + } + + public String getManagementOption(){ + return managementOption; + } + + public void setManagementOption(String managementOption){ + this.managementOption = managementOption; + } + + public int getBandwidthUp(){ + return bandwidthUp; + } + + public void setBandwidthUp(int bandwidthUp){ + this.bandwidthUp = bandwidthUp; + } + + public int getBandwidthDown(){ + return bandwidthDown; + } + + public void setBandwidthDown(int bandwidthDown){ + this.bandwidthDown = bandwidthDown; + } + + public String getBandwidthUnits(){ + return bandwidthUnits; + } + + public void setBandwidthUnits(String bandwidthUnits){ + this.bandwidthUnits = bandwidthUnits; + } + + public String getWanPort(){ + return wanPort; + } + + public void setWanPort(String wanPort){ + this.wanPort = wanPort; + } + + + @Override + public boolean equals(final Object other){ + if(!(other instanceof PhysicalLink)){ + return false; + } + PhysicalLink castOther = (PhysicalLink) other; + return new EqualsBuilder().append(linkName, castOther.linkName).isEquals(); + } + + @Override + public int hashCode(){ + return new HashCodeBuilder().append(linkName).toHashCode(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Platform.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Platform.java new file mode 100644 index 0000000000..642417fa56 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Platform.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("platform") +public class Platform implements Serializable, ShallowCopy<Platform> { + + private static final long serialVersionUID = -9127507763010448699L; + + @Id + @JsonProperty("platform-name") + private String platformName; + + public String getPlatformName() { + return platformName; + } + + public void setPlatformName(String platformName) { + this.platformName = platformName; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof Platform)) { + return false; + } + Platform castOther = (Platform) other; + return new EqualsBuilder().append(platformName, castOther.platformName).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(platformName).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Pnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Pnf.java new file mode 100644 index 0000000000..2ec4108343 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Pnf.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("pnf") +public class Pnf implements Serializable, ShallowCopy<Pnf> { + + private static final long serialVersionUID = -2544848120774529501L; + + @Id + @JsonProperty("pnf-id") + private String pnfId; + + @JsonProperty("pnf-name") + private String pnfName; + + @JsonProperty("role") + private String role; + + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + + @JsonProperty("cloud-region") + private CloudRegion cloudRegion; + + + public String getPnfId() { + return pnfId; + } + + public void setPnfId(String pnfId) { + this.pnfId = pnfId; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + /** + * Distinguishes Primary or Secondary + */ + public String getRole() { + return role; + } + + /** + * Distinguishes Primary or Secondary + */ + public void setRole(String role) { + this.role = role; + } + + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public CloudRegion getCloudRegion() { + return cloudRegion; + } + + public void setCloudRegion(CloudRegion cloudRegion) { + this.cloudRegion = cloudRegion; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof Pnf)) { + return false; + } + Pnf castOther = (Pnf) other; + return new EqualsBuilder().append(pnfId, castOther.pnfId).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(pnfId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Project.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Project.java new file mode 100644 index 0000000000..a815f6af1a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Project.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("project") +public class Project implements Serializable, ShallowCopy<Project> { + + private static final long serialVersionUID = 2449880559554533585L; + + @Id + @JsonProperty("project-name") + private String projectName; + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof Project)) { + return false; + } + Project castOther = (Project) other; + return new EqualsBuilder().append(projectName, castOther.projectName).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(projectName).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/RouteTableReference.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/RouteTableReference.java new file mode 100644 index 0000000000..0d8c3201bc --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/RouteTableReference.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +public class RouteTableReference implements Serializable, ShallowCopy<RouteTableReference> { + + private static final long serialVersionUID = -698474994443040491L; + + @Id + @JsonProperty("route-table-reference-id") + private String routeTableReferenceId; + @JsonProperty("route-table-reference-fqdn") + private String routeTableReferenceFqdn; + @JsonProperty("resource-version") + private String resourceVersion; + + public String getRouteTableReferenceId() { + return routeTableReferenceId; + } + public void setRouteTableReferenceId(String routeTableReferenceId) { + this.routeTableReferenceId = routeTableReferenceId; + } + public String getRouteTableReferenceFqdn() { + return routeTableReferenceFqdn; + } + public void setRouteTableReferenceFqdn(String routeTableReferenceFqdn) { + this.routeTableReferenceFqdn = routeTableReferenceFqdn; + } + public String getResourceVersion() { + return resourceVersion; + } + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof RouteTableReference)) { + return false; + } + RouteTableReference castOther = (RouteTableReference) other; + return new EqualsBuilder().append(routeTableReferenceId, castOther.routeTableReferenceId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(routeTableReferenceId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/RouteTarget.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/RouteTarget.java new file mode 100644 index 0000000000..fc97306cfe --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/RouteTarget.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("route-target") +public class RouteTarget implements Serializable, ShallowCopy<RouteTarget> { + private static final long serialVersionUID = -4635525992843470461L; + + @Id + @JsonProperty("global-route-target") + protected String globalRouteTarget; + @Id + @JsonProperty("route-target-role") + protected String routeTargetRole; + @JsonProperty("resource-version") + protected String resourceVersion; + + public String getGlobalRouteTarget() { + return globalRouteTarget; + } + + public void setGlobalRouteTarget(String value) { + this.globalRouteTarget = value; + } + + public String getRouteTargetRole() { + return routeTargetRole; + } + + public void setRouteTargetRole(String value) { + this.routeTargetRole = value; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setResourceVersion(String value) { + this.resourceVersion = value; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof RouteTarget)) { + return false; + } + RouteTarget castOther = (RouteTarget) other; + return new EqualsBuilder().append(globalRouteTarget, castOther.globalRouteTarget) + .append(routeTargetRole, castOther.routeTargetRole).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(globalRouteTarget).append(routeTargetRole).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/SegmentationAssignment.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/SegmentationAssignment.java new file mode 100644 index 0000000000..a299f1ef42 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/SegmentationAssignment.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("segmentation-assignment") +public class SegmentationAssignment implements Serializable, ShallowCopy<SegmentationAssignment>{ + + private static final long serialVersionUID = 5751570091375657521L; + + @Id + @JsonProperty("segmentation-id") + private String segmentationId; + + public String getSegmentationId() { + return segmentationId; + } + public void setSegmentationId(String segmentationId) { + this.segmentationId = segmentationId; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof SegmentationAssignment)) { + return false; + } + SegmentationAssignment castOther = (SegmentationAssignment) other; + return new EqualsBuilder().append(segmentationId, castOther.segmentationId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(segmentationId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java new file mode 100644 index 0000000000..259a988262 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java @@ -0,0 +1,206 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.Metadata; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; +import org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo; + +@JsonRootName("service-instance") +public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstance> { + + private static final long serialVersionUID = -1843348234891739356L; + + @Id + @JsonProperty("service-instance-id") + private String serviceInstanceId; + @JsonProperty("service-instance-name") + private String serviceInstanceName; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("owning-entity") + private OwningEntity owningEntity; + @JsonProperty("project") + private Project project; + @JsonProperty("collection") + private Collection collection; + @JsonProperty("vnfs") + private List<GenericVnf> vnfs = new ArrayList<>(); + @JsonProperty("pnfs") + private List<Pnf> pnfs = new ArrayList<>(); + @JsonProperty("allotted-resources") + private List<AllottedResource> allottedResources = new ArrayList<>(); + @JsonProperty("networks") + private List<L3Network> networks = new ArrayList<>(); + @JsonProperty("vpn-bonding-links") + private List<VpnBondingLink> vpnBondingLinks = new ArrayList<>(); + @JsonProperty("vhn-portal-url") + private String vhnPortalUrl; + @JsonProperty("service-instance-location-id") + private String serviceInstanceLocationId; + @JsonProperty("selflink") + private String selflink; + @JsonProperty("metadata") + private Metadata metadata; + @JsonProperty("configurations") + private List<Configuration> configurations = new ArrayList<>(); + @JsonProperty("solution-info") + private SolutionInfo solutionInfo; + @JsonProperty("model-info-service-instance") + private ModelInfoServiceInstance modelInfoServiceInstance; + + public List<GenericVnf> getVnfs() { + return vnfs; + } + public List<AllottedResource> getAllottedResources() { + return allottedResources; + } + public List<L3Network> getNetworks() { + return networks; + } + public ModelInfoServiceInstance getModelInfoServiceInstance() { + return modelInfoServiceInstance; + } + public void setModelInfoServiceInstance(ModelInfoServiceInstance modelInfoServiceInstance) { + this.modelInfoServiceInstance = modelInfoServiceInstance; + } + public List<Configuration> getConfigurations() { + return configurations; + } + public void setConfigurations(List<Configuration> configurations) { + this.configurations = configurations; + } + public String getVhnPortalUrl() { + return vhnPortalUrl; + } + + public void setVhnPortalUrl(String vhnPortalUrl) { + this.vhnPortalUrl = vhnPortalUrl; + } + + public String getServiceInstanceLocationId() { + return serviceInstanceLocationId; + } + + public void setServiceInstanceLocationId(String serviceInstanceLocationId) { + this.serviceInstanceLocationId = serviceInstanceLocationId; + } + + public String getSelflink() { + return selflink; + } + + public void setSelflink(String selflink) { + this.selflink = selflink; + } + + public Metadata getMetadata() { + return metadata; + } + + public void setMetadata(Metadata metadata) { + this.metadata = metadata; + } + + 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 OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + + public OwningEntity getOwningEntity() { + return owningEntity; + } + + public void setOwningEntity(OwningEntity owningEntity) { + this.owningEntity = owningEntity; + } + + public Project getProject() { + return project; + } + + public void setProject(Project project) { + this.project = project; + } + + public Collection getCollection() { + return collection; + } + public void setCollection(Collection collection) { + this.collection = collection; + } + public List<VpnBondingLink> getVpnBondingLinks() { + return vpnBondingLinks; + } + public List<Pnf> getPnfs() { + return pnfs; + } + public SolutionInfo getSolutionInfo() { + return solutionInfo; + } + public void setSolutionInfo(SolutionInfo solutionInfo) { + this.solutionInfo = solutionInfo; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof ServiceInstance)) { + return false; + } + ServiceInstance castOther = (ServiceInstance) other; + return new EqualsBuilder().append(serviceInstanceId, castOther.serviceInstanceId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(serviceInstanceId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceProxy.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceProxy.java new file mode 100644 index 0000000000..fa076770d7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceProxy.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; +import org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionCandidates; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy; + +import java.io.Serializable; +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +@JsonRootName("service-proxy") +public class ServiceProxy extends SolutionCandidates implements Serializable, ShallowCopy<ServiceProxy> { + private static final long serialVersionUID = 1491890223056651430L; + + @Id + @JsonProperty("id") + private String id; + + @JsonProperty("type") + private String type; + + @JsonProperty("service-instance") + private ServiceInstance serviceInstance; + + @JsonProperty("model-info-service-proxy") + private ModelInfoServiceProxy modelInfoServiceProxy; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * Way to identify the type of proxy + * i.e. "infrastructure", "transport", etc. + */ + public String getType() { + return type; + } + + /** + * Way to identify the type of proxy + * i.e. "infrastructure", "transport", etc. + */ + public void setType(String type) { + this.type = type; + } + + public ServiceInstance getServiceInstance() { + return serviceInstance; + } + + public void setServiceInstance(ServiceInstance serviceInstance) { + this.serviceInstance = serviceInstance; + } + + public ModelInfoServiceProxy getModelInfoServiceProxy() { + return modelInfoServiceProxy; + } + + public void setModelInfoServiceProxy(ModelInfoServiceProxy modelInfoServiceProxy) { + this.modelInfoServiceProxy = modelInfoServiceProxy; + } + + @Override + public boolean equals(final Object other){ + if(!(other instanceof ServiceProxy)){ + return false; + } + ServiceProxy castOther = (ServiceProxy) other; + return new EqualsBuilder().append(id, castOther.id).isEquals(); + } + + @Override + public int hashCode(){ + return new HashCodeBuilder().append(id).toHashCode(); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceSubscription.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceSubscription.java new file mode 100644 index 0000000000..56f95516b1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceSubscription.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("service-subscription") +public class ServiceSubscription implements Serializable, ShallowCopy<ServiceSubscription>{ + + private static final long serialVersionUID = 9064449329296611436L; + + @Id + @JsonProperty("service-type") + private String serviceType; + @JsonProperty("temp-ub-sub-account-id") + private String tempUbSubAccountId; + @JsonProperty("service-instances") + private List<ServiceInstance> serviceInstances = new ArrayList<ServiceInstance>(); + + public String getServiceType() { + return serviceType; + } + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + public String getTempUbSubAccountId() { + return tempUbSubAccountId; + } + public void setTempUbSubAccountId(String tempUbSubAccountId) { + this.tempUbSubAccountId = tempUbSubAccountId; + } + public List<ServiceInstance> getServiceInstances() { + return serviceInstances; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof ServiceSubscription)) { + return false; + } + ServiceSubscription castOther = (ServiceSubscription) other; + return new EqualsBuilder().append(serviceType, castOther.serviceType).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(serviceType).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/SriovVf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/SriovVf.java new file mode 100644 index 0000000000..fcea22819e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/SriovVf.java @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("sriov-vf") +public class SriovVf implements Serializable, ShallowCopy<SriovVf>{ + + private static final long serialVersionUID = -7790331637399859914L; + + @Id + @JsonProperty("pci-id") + private String pciId; + @JsonProperty("vf-vlan-filter") + private String vfVlanFilter; + @JsonProperty("vf-mac-filter") + private String vfMacFilter; + @JsonProperty("vf-vlan-strip") + private Boolean vfVlanStrip; + @JsonProperty("vf-vlan-anti-spoof-check") + private Boolean vfVlanAntiSpoofCheck; + @JsonProperty("vf-mac-anti-spoof-check") + private Boolean vfMacAntiSpoofCheck; + @JsonProperty("vf-mirrors") + private String vfMirrors; + @JsonProperty("vf-broadcast-allow") + private Boolean vfBroadcastAllow; + @JsonProperty("vf-unknown-multicast-allow") + private Boolean vfUnknownMulticastAllow; + @JsonProperty("vf-unknown-unicast-allow") + private Boolean vfUnknownUnicastAllow; + @JsonProperty("vf-insert-stag") + private Boolean vfInsertStag; + @JsonProperty("vf-link-status") + private String vfLinkStatus; + @JsonProperty("neutron-network-id") + private String neutronNetworkId; + + public String getPciId() { + return pciId; + } + public void setPciId(String pciId) { + this.pciId = pciId; + } + public String getVfVlanFilter() { + return vfVlanFilter; + } + public void setVfVlanFilter(String vfVlanFilter) { + this.vfVlanFilter = vfVlanFilter; + } + public String getVfMacFilter() { + return vfMacFilter; + } + public void setVfMacFilter(String vfMacFilter) { + this.vfMacFilter = vfMacFilter; + } + public Boolean getVfVlanStrip() { + return vfVlanStrip; + } + public void setVfVlanStrip(Boolean vfVlanStrip) { + this.vfVlanStrip = vfVlanStrip; + } + public Boolean getVfVlanAntiSpoofCheck() { + return vfVlanAntiSpoofCheck; + } + public void setVfVlanAntiSpoofCheck(Boolean vfVlanAntiSpoofCheck) { + this.vfVlanAntiSpoofCheck = vfVlanAntiSpoofCheck; + } + public Boolean getVfMacAntiSpoofCheck() { + return vfMacAntiSpoofCheck; + } + public void setVfMacAntiSpoofCheck(Boolean vfMacAntiSpoofCheck) { + this.vfMacAntiSpoofCheck = vfMacAntiSpoofCheck; + } + public String getVfMirrors() { + return vfMirrors; + } + public void setVfMirrors(String vfMirrors) { + this.vfMirrors = vfMirrors; + } + public Boolean getVfBroadcastAllow() { + return vfBroadcastAllow; + } + public void setVfBroadcastAllow(Boolean vfBroadcastAllow) { + this.vfBroadcastAllow = vfBroadcastAllow; + } + public Boolean getVfUnknownMulticastAllow() { + return vfUnknownMulticastAllow; + } + public void setVfUnknownMulticastAllow(Boolean vfUnknownMulticastAllow) { + this.vfUnknownMulticastAllow = vfUnknownMulticastAllow; + } + public Boolean getVfUnknownUnicastAllow() { + return vfUnknownUnicastAllow; + } + public void setVfUnknownUnicastAllow(Boolean vfUnknownUnicastAllow) { + this.vfUnknownUnicastAllow = vfUnknownUnicastAllow; + } + public Boolean getVfInsertStag() { + return vfInsertStag; + } + public void setVfInsertStag(Boolean vfInsertStag) { + this.vfInsertStag = vfInsertStag; + } + public String getVfLinkStatus() { + return vfLinkStatus; + } + public void setVfLinkStatus(String vfLinkStatus) { + this.vfLinkStatus = vfLinkStatus; + } + public String getNeutronNetworkId() { + return neutronNetworkId; + } + public void setNeutronNetworkId(String neutronNetworkId) { + this.neutronNetworkId = neutronNetworkId; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof SriovVf)) { + return false; + } + SriovVf castOther = (SriovVf) other; + return new EqualsBuilder().append(pciId, castOther.pciId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(pciId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Subnet.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Subnet.java new file mode 100644 index 0000000000..cb23f3a3b9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Subnet.java @@ -0,0 +1,173 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("subnet") +public class Subnet implements Serializable, ShallowCopy<Subnet>{ + + private static final long serialVersionUID = -6789344717555598319L; + + @Id + @JsonProperty("subnet-id") + private String subnetId; + @JsonProperty("subnet-name") + private String subnetName; + @JsonProperty("neutron-subnet-id") + private String neutronSubnetId; + @JsonProperty("gateway-address") + private String gatewayAddress; + @JsonProperty("network-start-address") + private String networkStartAddress; + @JsonProperty("cidr-mask") + private String cidrMask; + @JsonProperty("ip-version") + private String ipVersion; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("dhcp-enabled") + private boolean dhcpEnabled; + @JsonProperty("dhcp-start") + private String dhcpStart; + @JsonProperty("dhcp-end") + private String dhcpEnd; + @JsonProperty("subnet-role") + private String subnetRole; + @JsonProperty("ip-assignment-direction") + private String ipAssignmentDirection; + @JsonProperty("subnet-sequence") + private Integer subnetSequence; + @JsonProperty("host-routes") + private List<HostRoute> hostRoutes = new ArrayList<>(); + + public String getSubnetId() { + return subnetId; + } + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + public String getSubnetName() { + return subnetName; + } + public void setSubnetName(String subnetName) { + this.subnetName = subnetName; + } + public String getNeutronSubnetId() { + return neutronSubnetId; + } + public void setNeutronSubnetId(String neutronSubnetId) { + this.neutronSubnetId = neutronSubnetId; + } + public String getGatewayAddress() { + return gatewayAddress; + } + public void setGatewayAddress(String gatewayAddress) { + this.gatewayAddress = gatewayAddress; + } + public String getNetworkStartAddress() { + return networkStartAddress; + } + public void setNetworkStartAddress(String networkStartAddress) { + this.networkStartAddress = networkStartAddress; + } + public String getCidrMask() { + return cidrMask; + } + public void setCidrMask(String cidrMask) { + this.cidrMask = cidrMask; + } + public String getIpVersion() { + return ipVersion; + } + public void setIpVersion(String ipVersion) { + this.ipVersion = ipVersion; + } + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + public boolean isDhcpEnabled() { + return dhcpEnabled; + } + public void setDhcpEnabled(boolean dhcpEnabled) { + this.dhcpEnabled = dhcpEnabled; + } + public String getDhcpStart() { + return dhcpStart; + } + public void setDhcpStart(String dhcpStart) { + this.dhcpStart = dhcpStart; + } + public String getDhcpEnd() { + return dhcpEnd; + } + public void setDhcpEnd(String dhcpEnd) { + this.dhcpEnd = dhcpEnd; + } + public String getSubnetRole() { + return subnetRole; + } + public void setSubnetRole(String subnetRole) { + this.subnetRole = subnetRole; + } + public String getIpAssignmentDirection() { + return ipAssignmentDirection; + } + public void setIpAssignmentDirection(String ipAssignmentDirection) { + this.ipAssignmentDirection = ipAssignmentDirection; + } + public Integer getSubnetSequence() { + return subnetSequence; + } + public void setSubnetSequence(Integer subnetSequence) { + this.subnetSequence = subnetSequence; + } + public List<HostRoute> getHostRoutes() { + return hostRoutes; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof Subnet)) { + return false; + } + Subnet castOther = (Subnet) other; + return new EqualsBuilder().append(subnetId, castOther.subnetId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(subnetId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VfModule.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VfModule.java new file mode 100644 index 0000000000..fba78d7a87 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VfModule.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("vf-module") +public class VfModule implements Serializable, ShallowCopy<VfModule> { + + private static final long serialVersionUID = 6570087672008609773L; + + @Id + @JsonProperty("vf-module-id") + private String vfModuleId; + @JsonProperty("vf-module-name") + private String vfModuleName; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("cloud-params") + private Map<String, String> cloudParams = new HashMap<>(); + @JsonProperty("cascaded") + private boolean cascaded; + @JsonProperty("heat-stack-id") + private String heatStackId; + @JsonProperty("contrail-service-instance-fqdn") + private String contrailServiceInstanceFqdn; + @JsonProperty("module-index") + private Integer moduleIndex; + @JsonProperty("selflink") + private String selflink; + @JsonProperty("model-info-vf-module") + private ModelInfoVfModule modelInfoVfModule; + + public ModelInfoVfModule getModelInfoVfModule() { + return modelInfoVfModule; + } + public void setModelInfoVfModule(ModelInfoVfModule modelInfoVfModule) { + this.modelInfoVfModule = modelInfoVfModule; + } + public String getHeatStackId() { + return heatStackId; + } + public void setHeatStackId(String heatStackId) { + this.heatStackId = heatStackId; + } + public String getContrailServiceInstanceFqdn() { + return contrailServiceInstanceFqdn; + } + public void setContrailServiceInstanceFqdn(String contrailServiceInstanceFqdn) { + this.contrailServiceInstanceFqdn = contrailServiceInstanceFqdn; + } + public Integer getModuleIndex() { + return moduleIndex; + } + public void setModuleIndex(Integer moduleIndex) { + this.moduleIndex = moduleIndex; + } + public String getSelflink() { + return selflink; + } + public void setSelflink(String selflink) { + this.selflink = selflink; + } + public String getVfModuleId() { + return vfModuleId; + } + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + public String getVfModuleName() { + return vfModuleName; + } + public void setVfModuleName(String vfModuleName) { + this.vfModuleName = vfModuleName; + } + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + public Map<String, String> getCloudParams() { + return cloudParams; + } + public void setCloudParams(Map<String, String> cloudParams) { + this.cloudParams = cloudParams; + } + public boolean isCascaded() { + return cascaded; + } + public void setCascaded(boolean cascaded) { + this.cascaded = cascaded; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof VfModule)) { + return false; + } + VfModule castOther = (VfModule) other; + return new EqualsBuilder().append(vfModuleId, castOther.vfModuleId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(vfModuleId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vlan.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vlan.java new file mode 100644 index 0000000000..65eeedc44c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vlan.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +import javax.persistence.Id; + +@JsonRootName("vlan") +public class Vlan implements Serializable, ShallowCopy<Vlan>{ + + private static final long serialVersionUID = 1260512753640402946L; + + @Id + @JsonProperty("vlan-interface") + private String vlanInterface; + @JsonProperty("vlan-id-inner") + private Long vlanIdInner; + @JsonProperty("vlan-id-outer") + private Long vlanIdOuter; + @JsonProperty("speed-value") + private String speedValue; + @JsonProperty("speed-units") + private String speedUnits; + @JsonProperty("vlan-description") + private String vlanDescription; + @JsonProperty("backdoor-connection") + private String backdoorConnection; + @JsonProperty("vpn-key") + private String vpnKey; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("in-maint") + private boolean inMaint; + @JsonProperty("prov-status") + private String provStatus; + @JsonProperty("is-ip-unnumbered") + private boolean isIpUnnumbered; + @JsonProperty("l3-interface-ipv4-address-list") + private List<L3InterfaceIpv4AddressList> l3InterfaceIpv4AddressList = new ArrayList<L3InterfaceIpv4AddressList>(); + @JsonProperty("l3-interface-ipv6-address-list") + private List<L3InterfaceIpv6AddressList> l3InterfaceIpv6AddressList = new ArrayList<L3InterfaceIpv6AddressList>(); + + public String getVlanInterface() { + return vlanInterface; + } + public void setVlanInterface(String vlanInterface) { + this.vlanInterface = vlanInterface; + } + public Long getVlanIdInner() { + return vlanIdInner; + } + public void setVlanIdInner(Long vlanIdInner) { + this.vlanIdInner = vlanIdInner; + } + public Long getVlanIdOuter() { + return vlanIdOuter; + } + public void setVlanIdOuter(Long vlanIdOuter) { + this.vlanIdOuter = vlanIdOuter; + } + public String getSpeedValue() { + return speedValue; + } + public void setSpeedValue(String speedValue) { + this.speedValue = speedValue; + } + public String getSpeedUnits() { + return speedUnits; + } + public void setSpeedUnits(String speedUnits) { + this.speedUnits = speedUnits; + } + public String getVlanDescription() { + return vlanDescription; + } + public void setVlanDescription(String vlanDescription) { + this.vlanDescription = vlanDescription; + } + public String getBackdoorConnection() { + return backdoorConnection; + } + public void setBackdoorConnection(String backdoorConnection) { + this.backdoorConnection = backdoorConnection; + } + public String getVpnKey() { + return vpnKey; + } + public void setVpnKey(String vpnKey) { + this.vpnKey = vpnKey; + } + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + public boolean isInMaint() { + return inMaint; + } + public void setInMaint(boolean inMaint) { + this.inMaint = inMaint; + } + public String getProvStatus() { + return provStatus; + } + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + public boolean isIpUnnumbered() { + return isIpUnnumbered; + } + public void setIpUnnumbered(boolean isIpUnnumbered) { + this.isIpUnnumbered = isIpUnnumbered; + } + public List<L3InterfaceIpv4AddressList> getL3InterfaceIpv4AddressList() { + return l3InterfaceIpv4AddressList; + } + public List<L3InterfaceIpv6AddressList> getL3InterfaceIpv6AddressList() { + return l3InterfaceIpv6AddressList; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof Vlan)) { + return false; + } + Vlan castOther = (Vlan) other; + return new EqualsBuilder().append(vlanInterface, castOther.vlanInterface).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(vlanInterface).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VolumeGroup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VolumeGroup.java new file mode 100644 index 0000000000..565a151077 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VolumeGroup.java @@ -0,0 +1,121 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import javax.persistence.Id; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; +import org.onap.so.db.catalog.beans.OrchestrationStatus; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("volume-group") +public class VolumeGroup implements Serializable, ShallowCopy<VolumeGroup> { + + private static final long serialVersionUID = 870124265764370922L; + + @Id + @JsonProperty("volume-group-id") + private String volumeGroupId; + @JsonProperty("volume-group-name") + private String volumeGroupName; + @JsonProperty("vnf-type") + private String vnfType; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus; + @JsonProperty("cloud-params") + private Map<String, String> cloudParams = new HashMap<>(); + @JsonProperty("cascaded") + private boolean cascaded; + @JsonProperty("heat-stack-id") + private String heatStackId; + @JsonProperty("model-info-vf-module") + private ModelInfoVfModule modelInfoVfModule; + + public ModelInfoVfModule getModelInfoVfModule() { + return modelInfoVfModule; + } + public void setModelInfoVfModule(ModelInfoVfModule modelInfoVfModule) { + this.modelInfoVfModule = modelInfoVfModule; + } + public String getHeatStackId() { + return heatStackId; + } + public void setHeatStackId(String heatStackId) { + this.heatStackId = heatStackId; + } + public String getVolumeGroupId() { + return volumeGroupId; + } + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + public String getVolumeGroupName() { + return volumeGroupName; + } + public void setVolumeGroupName(String volumeGroupName) { + this.volumeGroupName = volumeGroupName; + } + public String getVnfType() { + return vnfType; + } + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; + } + public Map<String, String> getCloudParams() { + return cloudParams; + } + public void setCloudParams(Map<String, String> cloudParams) { + this.cloudParams = cloudParams; + } + public boolean isCascaded() { + return cascaded; + } + public void setCascaded(boolean cascaded) { + this.cascaded = cascaded; + } + @Override + public boolean equals(final Object other) { + if (!(other instanceof VolumeGroup)) { + return false; + } + VolumeGroup castOther = (VolumeGroup) other; + return new EqualsBuilder().append(volumeGroupId, castOther.volumeGroupId).isEquals(); + } + @Override + public int hashCode() { + return new HashCodeBuilder().append(volumeGroupId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VpnBinding.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VpnBinding.java new file mode 100644 index 0000000000..36e1af443c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VpnBinding.java @@ -0,0 +1,141 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Id; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + + +@JsonRootName("vpn-binding") +public class VpnBinding implements Serializable, ShallowCopy<VpnBinding> { + private static final long serialVersionUID = 3283413795353486924L; + + @Id + @JsonProperty("vpn-id") + private String vpnId; + @JsonProperty("vpn-name") + private String vpnName; + @JsonProperty("vpn-platform") + private String vpnPlatform; + @JsonProperty("vpn-type") + private String vpnType; + @JsonProperty("vpn-region") + private String vpnRegion; + @JsonProperty("customer-vpn-id") + private String customerVpnId; + @JsonProperty("route-distinguisher") + private String routeDistinguisher; + @JsonProperty("resource-version") + private String resourceVersion; + @JsonProperty("route-targets") + private List<RouteTarget> routeTargets = new ArrayList<>(); + + public String getVpnId() { + return vpnId; + } + + public void setVpnId(String value) { + this.vpnId = value; + } + + public String getVpnName() { + return vpnName; + } + + public void setVpnName(String value) { + this.vpnName = value; + } + + public String getVpnPlatform() { + return vpnPlatform; + } + + public void setVpnPlatform(String value) { + this.vpnPlatform = value; + } + + public String getVpnType() { + return vpnType; + } + + public void setVpnType(String value) { + this.vpnType = value; + } + + public String getVpnRegion() { + return vpnRegion; + } + + public void setVpnRegion(String value) { + this.vpnRegion = value; + } + + public String getCustomerVpnId() { + return customerVpnId; + } + + public void setCustomerVpnId(String value) { + this.customerVpnId = value; + } + + public String getRouteDistinguisher() { + return routeDistinguisher; + } + + public void setRouteDistinguisher(String value) { + this.routeDistinguisher = value; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setResourceVersion(String value) { + this.resourceVersion = value; + } + + public List<RouteTarget> getRouteTargets() { + return routeTargets; + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VpnBinding)) { + return false; + } + VpnBinding castOther = (VpnBinding) other; + return new EqualsBuilder().append(vpnId, castOther.vpnId).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(vpnId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VpnBondingLink.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VpnBondingLink.java new file mode 100644 index 0000000000..dec3d48203 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/VpnBondingLink.java @@ -0,0 +1,166 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.bbobjects; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +import javax.persistence.Id; + +import static org.apache.commons.lang3.StringUtils.*; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("vpn-bonding-link") +public class VpnBondingLink implements Serializable, ShallowCopy<VpnBondingLink> { + + private static final long serialVersionUID = -8355973761714642727L; + + @Id + @JsonProperty("vpn-bonding-link-id") + private String vpnBondingLinkId; + + @JsonProperty("configurations") + private List<Configuration> configurations = new ArrayList<Configuration>(); + + @JsonProperty("service-proxies") + private List<ServiceProxy> serviceProxies = new ArrayList<ServiceProxy>(); + + public String getVpnBondingLinkId() { + return vpnBondingLinkId; + } + + public void setVpnBondingLinkId(String vpnBondingLinkId) { + this.vpnBondingLinkId = vpnBondingLinkId; + } + + public List<Configuration> getConfigurations() { + return configurations; + } + + public List<ServiceProxy> getServiceProxies() { + return serviceProxies; + } + + public ServiceProxy getServiceProxy(String id) { + ServiceProxy serviceProxy = null; + for(ServiceProxy s : serviceProxies){ + if(s.getId().equals(id)){ + serviceProxy = s; + } + } + return serviceProxy; + } + + //TODO temp solution until references are updated to use getConfigurationByType + public Configuration getVnrConfiguration() { + Configuration configuration = null; + for(Configuration c:configurations){ + if(containsIgnoreCase(c.getConfigurationType(), "vlan") || containsIgnoreCase(c.getConfigurationType(), "vnr")){ + configuration = c; + } + } + return configuration; + } + + //TODO temp solution until references are updatedd + public void setVnrConfiguration(Configuration vnrConfiguration) { + if(vnrConfiguration.getConfigurationType() == null){ + vnrConfiguration.setConfigurationType("vlan"); + } + configurations.add(vnrConfiguration); + } + + //TODO temp solution until references are updated to use getConfigurationByType + public Configuration getVrfConfiguration() { + Configuration configuration = null; + for(Configuration c:configurations){ + if(containsIgnoreCase(c.getConfigurationType(), "vrf")){ + configuration = c; + } + } + return configuration; + } + + //TODO temp solution until references are updated + public void setVrfConfiguration(Configuration vrfConfiguration) { + if(vrfConfiguration.getConfigurationType() == null){ + vrfConfiguration.setConfigurationType("vrf"); + } + configurations.add(vrfConfiguration); + } + + //TODO temp solution until references are updated to use getServiceProxyByType + public ServiceProxy getInfrastructureServiceProxy() { + ServiceProxy serviceProxy = null; + for(ServiceProxy sp:serviceProxies){ + if(sp.getType().equals("infrastructure")){ + serviceProxy = sp; + } + } + return serviceProxy; + } + + //TODO temp solution until references are updated + public void setInfrastructureServiceProxy(ServiceProxy infrastructureServiceProxy) { + infrastructureServiceProxy.setType("infrastructure"); + serviceProxies.add(infrastructureServiceProxy); + } + + //TODO temp solution until references are updated to use getServiceProxyByType + public ServiceProxy getTransportServiceProxy() { + ServiceProxy serviceProxy = null; + for(ServiceProxy sp:serviceProxies){ + if(sp != null){ + if(sp.getType().equals("transport")){ + serviceProxy = sp; + } + } + } + return serviceProxy; + } + + //TODO temp solution until references are updated + public void setTransportServiceProxy(ServiceProxy transportServiceProxy) { + transportServiceProxy.setType("transport"); + serviceProxies.add(transportServiceProxy); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof VpnBondingLink)) { + return false; + } + VpnBondingLink castOther = (VpnBondingLink) other; + return new EqualsBuilder().append(vpnBondingLinkId, castOther.vpnBondingLinkId).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(vpnBondingLinkId).toHashCode(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlock.java new file mode 100644 index 0000000000..5746dcd586 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/BuildingBlock.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.entities; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("buildingBlock") +public class BuildingBlock implements Serializable{ + + private static final long serialVersionUID = -1144315411128866052L; + + @JsonProperty("mso-id") + private String msoId; + @JsonProperty("bpmn-flow-name") + private String bpmnFlowName; + @JsonProperty("key") + private String key; + @JsonProperty("is-virtual-link") + private boolean isVirtualLink; + + public String getBpmnFlowName() { + return bpmnFlowName; + } + public void setBpmnFlowName(String bpmnFlowName) { + this.bpmnFlowName = bpmnFlowName; + } + public String getMsoId() { + return msoId; + } + public void setMsoId(String msoId) { + this.msoId = msoId; + } + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + public boolean getIsVirtualLink() { + return isVirtualLink; + } + public void setIsVirtualLink(boolean isVirtualLink) { + this.isVirtualLink = isVirtualLink; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java new file mode 100644 index 0000000000..36a24bd1e1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ExecuteBuildingBlock.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.entities; + +import java.io.Serializable; + +import org.onap.so.serviceinstancebeans.RequestDetails; + +public class ExecuteBuildingBlock implements Serializable{ + /** + * + */ + private static final long serialVersionUID = 1L; + private BuildingBlock buildingBlock; + private String requestId; + private String apiVersion; + private String resourceId; + private String requestAction; + private String vnfType; + private boolean aLaCarte; + private boolean homing; + private WorkflowResourceIds workflowResourceIds; + private RequestDetails requestDetails; + + public BuildingBlock getBuildingBlock() { + return buildingBlock; + } + public void setBuildingBlock(BuildingBlock buildingBlock) { + this.buildingBlock = buildingBlock; + } + public String getRequestId() { + return requestId; + } + public void setRequestId(String requestId) { + this.requestId = requestId; + } + public String getApiVersion() { + return apiVersion; + } + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + public String getResourceId() { + return resourceId; + } + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + public String getRequestAction() { + return requestAction; + } + public void setRequestAction(String requestAction) { + this.requestAction = requestAction; + } + public boolean isaLaCarte() { + return aLaCarte; + } + public void setaLaCarte(boolean aLaCarte) { + this.aLaCarte = aLaCarte; + } + public String getVnfType() { + return vnfType; + } + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + public boolean isHoming() { + return homing; + } + public void setHoming(boolean homing) { + this.homing = homing; + } + public WorkflowResourceIds getWorkflowResourceIds() { + return workflowResourceIds; + } + public void setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) { + this.workflowResourceIds = workflowResourceIds; + } + public RequestDetails getRequestDetails() { + return requestDetails; + } + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java new file mode 100644 index 0000000000..adea99c4f3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/GeneralBuildingBlock.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.entities; + +import java.io.Serializable; +import java.util.Map; + +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; + +public class GeneralBuildingBlock implements Serializable { + private static final String INVALID_INPUT_MISSING = "Expected building block input of \"%s\" not found in decomposition"; + private static final String INVALID_INPUT_CLASS_CAST = "Expected building block input of \"%s\" was the wrong object type in the decomposition"; + + private static final long serialVersionUID = -429247436428110843L; + + private RequestContext requestContext; + private OrchestrationContext orchContext; + private Map<String, String> userInput; + private CloudRegion cloudRegion; + + private Customer customer; + private ServiceInstance serviceInstance; + + public CloudRegion getCloudRegion() { + return cloudRegion; + } + + public void setCloudRegion(CloudRegion cloudRegion) { + this.cloudRegion = cloudRegion; + } + + public RequestContext getRequestContext() { + return requestContext; + } + + public void setRequestContext(RequestContext requestContext) { + this.requestContext = requestContext; + } + + public OrchestrationContext getOrchContext() { + return orchContext; + } + + public void setOrchContext(OrchestrationContext orchContext) { + this.orchContext = orchContext; + } + + public Map<String, String> getUserInput() { + return userInput; + } + + public void setUserInput(Map<String, String> userInput) { + this.userInput = userInput; + } + + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + + public ServiceInstance getServiceInstance() { + return serviceInstance; + } + + public void setServiceInstance(ServiceInstance serviceInstance) { + this.serviceInstance = serviceInstance; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java new file mode 100644 index 0000000000..4662db23a1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.entities; + +public enum ResourceKey { + SERVICE_INSTANCE_ID, + GENERIC_VNF_ID, + NETWORK_ID, + VOLUME_GROUP_ID, + VF_MODULE_ID, + ALLOTTED_RESOURCE_ID, + CONFIGURATION_ID, + NETWORK_COLLECTION_ID, + VPN_ID, + VPN_BONDING_LINK_ID; +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java new file mode 100644 index 0000000000..433315b2ed --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.entities; + +import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class WorkflowResourceIds implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8591599114353940105L; + private String serviceInstanceId; + private String vnfId; + private String networkId; + private String volumeGroupId; + private String vfModuleId; + private String networkCollectionId; + private String configurationId; + + @Override + public String toString() { + return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId).append("vnfId", vnfId) + .append("networkId", networkId).append("volumeGroupId", volumeGroupId).append("vfModuleId", vfModuleId) + .append("networkCollectionId", networkCollectionId).append("configurationId", configurationId) + .toString(); + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public void setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getNetworkCollectionId() { + return networkCollectionId; + } + + public void setNetworkCollectionId(String networkCollectionId) { + this.networkCollectionId = networkCollectionId; + } + + public String getConfigurationId() { + return configurationId; + } + + public void setConfigurationId(String configurationId) { + this.configurationId = configurationId; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/exceptions/InvalidBuildingBlockInputException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/exceptions/InvalidBuildingBlockInputException.java new file mode 100644 index 0000000000..21828871db --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/exceptions/InvalidBuildingBlockInputException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.entities.exceptions; + +public class InvalidBuildingBlockInputException extends Exception { + private static final long serialVersionUID = 221404474263656742L; + + public InvalidBuildingBlockInputException() { + super(); + } + + public InvalidBuildingBlockInputException(String message) { + super(message); + } + + public InvalidBuildingBlockInputException(String message, Throwable cause) { + super(message, cause); + } + + public InvalidBuildingBlockInputException(Throwable cause) { + super(cause); + } + + protected InvalidBuildingBlockInputException(String message, Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/License.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/License.java new file mode 100644 index 0000000000..e1a12bbad9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/License.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.generalobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +@JsonRootName("license") +public class License implements Serializable { + + private static final long serialVersionUID = 2345786874755685318L; + + @JsonProperty("entitlement-pool-uuids") + private List<String> entitlementPoolUuids = new ArrayList<String>(); + @JsonProperty("license-key-group-uuids") + private List<String> licenseKeyGroupUuids = new ArrayList<String>(); + + + public List<String> getEntitlementPoolUuids() { + return entitlementPoolUuids; + } + public void setEntitlementPoolUuids(List<String> entitlementPoolUuids) { + this.entitlementPoolUuids = entitlementPoolUuids; + } + public List<String> getLicenseKeyGroupUuids() { + return licenseKeyGroupUuids; + } + public void setLicenseKeyGroupUuids(List<String> licenseKeyGroupUuids) { + this.licenseKeyGroupUuids = licenseKeyGroupUuids; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/OrchestrationContext.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/OrchestrationContext.java new file mode 100644 index 0000000000..d594c73638 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/OrchestrationContext.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.generalobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; + +@JsonRootName("orchestration-context") +public class OrchestrationContext implements Serializable { + + private static final long serialVersionUID = 6843015923244810369L; + + @JsonProperty("is-rollback-enabled") + private boolean isRollbackEnabled; + + public boolean getIsRollbackEnabled() { + return this.isRollbackEnabled; + } + + public void setIsRollbackEnabled(boolean isRollbackEnabled) { + this.isRollbackEnabled = isRollbackEnabled; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java new file mode 100644 index 0000000000..7715651b68 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestContext.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.generalobjects; + +import java.io.Serializable; +import java.util.HashMap; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("request-context") +public class RequestContext implements Serializable{ + + private static final long serialVersionUID = -6482733428879732822L; + + @JsonProperty("product-family-id") + private String productFamilyId; + @JsonProperty("source") + private String source; + @JsonProperty("requestor-id") + private String requestorId; + @JsonProperty("subscription-service-type") + private String subscriptionServiceType; + @JsonProperty("user-params") + private HashMap<String, String> userParams; + @JsonProperty("action") + private String action; + @JsonProperty("callback-url") + private String callbackURL; + @JsonProperty("service-uri") + private String serviceURI; + @JsonProperty("mso-request-id") + private String msoRequestId; + @JsonProperty("requestParameters") + private RequestParameters requestParameters; + + public String getServiceURI() { + return serviceURI; + } + public void setServiceURI(String serviceURI) { + this.serviceURI = serviceURI; + } + public String getProductFamilyId() { + return productFamilyId; + } + public void setProductFamilyId(String productFamilyId) { + this.productFamilyId = productFamilyId; + } + public String getSource() { + return source; + } + public void setSource(String source) { + this.source = source; + } + public String getRequestorId() { + return requestorId; + } + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + public HashMap<String, String> getUserParams() { + return userParams; + } + public void setUserParams(HashMap<String, String> userParams) { + this.userParams = userParams; + } + public String getAction() { + return action; + } + public void setAction(String action) { + this.action = action; + } + public String getCallbackURL() { + return callbackURL; + } + public void setCallbackURL(String callbackURL) { + this.callbackURL = callbackURL; + } + public String getMsoRequestId() { + return msoRequestId; + } + public void setMsoRequestId(String msoRequestId) { + this.msoRequestId = msoRequestId; + } + public RequestParameters getRequestParameters() { + return requestParameters; + } + public void setRequestParameters(RequestParameters requestParameters) { + this.requestParameters = requestParameters; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.java new file mode 100644 index 0000000000..24c0548641 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/generalobjects/RequestParameters.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.onap.so.bpmn.servicedecomposition.generalobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.onap.so.logger.MsoLogger; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "requestParameters") +@JsonInclude(Include.NON_DEFAULT) +public class RequestParameters implements Serializable { + + private static final MsoLogger log = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, RequestParameters.class); + + private static final long serialVersionUID = -5979049912538894930L; + @JsonProperty("subscriptionServiceType") + private String subscriptionServiceType; + @JsonProperty("userParams") + private List<Map<String, Object>> userParams = new ArrayList<>(); + @JsonProperty("aLaCarte") + private Boolean aLaCarte; + + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + @JsonProperty("aLaCarte") + public Boolean getALaCarte() { + return aLaCarte; + } + @JsonProperty("aLaCarte") + public void setaLaCarte(Boolean aLaCarte) { + this.aLaCarte = aLaCarte; + } + + public Boolean isaLaCarte() { + return aLaCarte; + } + + public List<Map<String, Object>> getUserParams() { + return userParams; + } + + public void setUserParams(List<Map<String, Object>> userParams) { + this.userParams = userParams; + } + + public Object getUserParamValue(String name) { + if (userParams != null) { + for (Map<String, Object> param : userParams) { + if (param.get(name) != null) { + return param.get(name); + } + } + } + return null; + } + + + @JsonInclude(Include.NON_NULL) + public String toJsonString(){ + String json = ""; + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + ObjectWriter ow = mapper.writer(); + try{ + json = ow.writeValueAsString(this); + }catch (Exception e){ + log.error("Unable to convert Sniro Manager Request to string", e); + } + return json; + } + + @Override + public String toString() { + return "RequestParameters [subscriptionServiceType=" + + subscriptionServiceType + ", userParams=" + userParams + + ", aLaCarte=" + aLaCarte + "]"; + } +}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java new file mode 100644 index 0000000000..01846681db --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/Candidate.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.homingobjects; + +import java.io.Serializable; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +public class Candidate implements Serializable { + + + private static final long serialVersionUID = -3959572501582849328L; + + @JsonProperty("candidateType") + private CandidateType candidateType; + @JsonProperty("candidates") + private List<String> candidates; + + /** + * list of candidates + * i.e. actual serviceInstanceId, actual vnfName, actual cloudRegionId, etc. + */ + public List<String> getCandidates() { + return candidates; + } + + /** + * list of candidates + * i.e. actual serviceInstanceId, actual vnfName, actual cloudRegionId, etc. + */ + public void setCandidates(List<String> candidates) { + this.candidates = candidates; + } + + /** + * Way to identify the type of candidate + * i.e. "serviceInstanceId", "vnfName", "cloudRegionId", etc. + */ + public CandidateType getCandidateType(){ + return candidateType; + } + + /** + * Way to identify the type of candidate + * i.e. "serviceInstanceId", "vnfName", "cloudRegionId", etc. + */ + public void setCandidateType(CandidateType candidateType){ + this.candidateType = candidateType; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java new file mode 100644 index 0000000000..9540b9148e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/CandidateType.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.homingobjects; + +public enum CandidateType { + SERVICE_INSTANCE_ID("serviceInstanceId"), + CLOUD_REGION_ID("cloudRegionId"), + VNF_ID("vnfId"), + VNF_NAME("vnfName"); + + private final String name; + + private CandidateType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } + + //TODO added to get PojoTest to work + public String getName(){ + return name; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionCandidates.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionCandidates.java new file mode 100644 index 0000000000..0cbd88b665 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionCandidates.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.homingobjects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.onap.so.bpmn.servicedecomposition.homingobjects.Candidate; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class SolutionCandidates implements Serializable{ + + private static final long serialVersionUID = 2188754118148819627L; + + @JsonProperty("requiredCandidates") + private List<Candidate> requiredCandidates = new ArrayList<Candidate>(); + @JsonProperty("excludedCandidates") + private List<Candidate> excludedCandidates = new ArrayList<Candidate>(); + //TODO figure out best way to do this + @JsonProperty("existingCandidates") + private List<Candidate> existingCandidates = new ArrayList<Candidate>(); + + + public List<Candidate> getRequiredCandidates() { + return requiredCandidates; + } + public void addRequiredCandidates(Candidate requiredCandidate) { + this.requiredCandidates.add(requiredCandidate); + } + public List<Candidate> getExcludedCandidates() { + return excludedCandidates; + } + public void addExcludedCandidates(Candidate excludedCandidate) { + this.excludedCandidates.add(excludedCandidate); + } + + public List<Candidate> getExistingCandidates(){ + return existingCandidates; + } + + + + + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionInfo.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionInfo.java new file mode 100644 index 0000000000..17e42b4396 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/homingobjects/SolutionInfo.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.homingobjects; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.onap.so.bpmn.servicedecomposition.ShallowCopy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; + +@JsonRootName("solution") +public class SolutionInfo implements Serializable { + + private static final long serialVersionUID = 6903399488466840832L; + + @JsonProperty("solution-id") //identifies which solution + private int solutionId; + @JsonProperty("homed") + private boolean homed; + @JsonProperty("is-rehome") + private boolean isRehome; + @JsonProperty("targeted-cloud") + private CloudRegion targetedCloudRegion; + + + public boolean isHomed() { + return homed; + } + + public void setHomed(boolean homed) { + this.homed = homed; + } + + public boolean isRehome() { + return isRehome; + } + + public void setRehome(boolean isRehome) { + this.isRehome = isRehome; + } + + /** + * Identifies which solution when multiple solutions exist for a + * given resource or resource pair. + * i.e. 1, 2, 3.... + */ + public int getSolutionId() { + return solutionId; + } + + /** + * Identifies which solution when multiple solutions exist for a + * given resource or resource pair. + * i.e. 1, 2, 3.... + */ + public void setSolutionId(int solutionId) { + this.solutionId = solutionId; + } + + /** + * Identifies where the resource should be created for + * homed equals false scenarios. Will return null if resource + * was homed. + */ + public CloudRegion getTargetedCloudRegion() { + return targetedCloudRegion; + } + + /** + * Identifies where the resource should be created for + * homed equals false scenarios. Will return null if resource + * was homed. + */ + public void setTargetedCloudRegion(CloudRegion targetedCloudRegion) { + this.targetedCloudRegion = targetedCloudRegion; + } + + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoAllottedResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoAllottedResource.java new file mode 100644 index 0000000000..b4f2e85e55 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoAllottedResource.java @@ -0,0 +1,146 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoAllottedResource extends ModelInfoMetadata implements Serializable{ + + private static final long serialVersionUID = -5240932898637922018L; + + @JsonProperty("max-instances") + private String MaxInstances; + @JsonProperty("min-instances") + private String MinInstances; + @JsonProperty("nf-naming-code") + private String NfNamingCode; + @JsonProperty("nf-role") + private String NfRole; + @JsonProperty("nf-type") + private String NfType; + @JsonProperty("nf-function") + private String NfFunction; + @JsonProperty("target-network-role") + private String TarNetworkRole; + @JsonProperty("providing-service-model-invariant-uuid") + private String ProvidingServiceModelInvariantUUID; + @JsonProperty("providing-service-model-name") + private String ProvidingServiceModelName; + @JsonProperty("providing-service-model-uuid") + private String ProvidingServiceModelUUID; + @JsonProperty("description") + private String Description; + @JsonProperty("created") + private String Created; + @JsonProperty("tosca-node-type") + private String ToscaNodeType; + @JsonProperty("subcategory") + private String Subcategory; +// private ModelInfoMetadata modelInfoMetadata; + + + public String getMaxInstances() { + return MaxInstances; + } + public void setMaxInstances(String maxInstances) { + MaxInstances = maxInstances; + } + public String getMinInstances() { + return MinInstances; + } + public void setMinInstances(String minInstances) { + MinInstances = minInstances; + } + public String getNfNamingCode() { + return NfNamingCode; + } + public void setNfNamingCode(String nfNamingCode) { + NfNamingCode = nfNamingCode; + } + public String getNfRole() { + return NfRole; + } + public void setNfRole(String nfRole) { + NfRole = nfRole; + } + public String getNfType() { + return NfType; + } + public void setNfType(String nfType) { + NfType = nfType; + } + public String getNfFunction() { + return NfFunction; + } + public void setNfFunction(String nfFunction) { + NfFunction = nfFunction; + } + public String getTarNetworkRole() { + return TarNetworkRole; + } + public void setTarNetworkRole(String tarNetworkRole) { + TarNetworkRole = tarNetworkRole; + } + public String getProvidingServiceModelInvariantUUID() { + return ProvidingServiceModelInvariantUUID; + } + public void setProvidingServiceModelInvariantUUID(String providingServiceModelInvariantUUID) { + ProvidingServiceModelInvariantUUID = providingServiceModelInvariantUUID; + } + public String getProvidingServiceModelName() { + return ProvidingServiceModelName; + } + public void setProvidingServiceModelName(String providingServiceModelName) { + ProvidingServiceModelName = providingServiceModelName; + } + public String getProvidingServiceModelUUID() { + return ProvidingServiceModelUUID; + } + public void setProvidingServiceModelUUID(String providingServiceModelUUID) { + ProvidingServiceModelUUID = providingServiceModelUUID; + } + public String getDescription() { + return Description; + } + public void setDescription(String description) { + Description = description; + } + public String getCreated() { + return Created; + } + public void setCreated(String created) { + Created = created; + } + public String getToscaNodeType() { + return ToscaNodeType; + } + public void setToscaNodeType(String toscaNodeType) { + ToscaNodeType = toscaNodeType; + } + public String getSubcategory() { + return Subcategory; + } + public void setSubcategory(String subcategory) { + Subcategory = subcategory; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoCollection.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoCollection.java new file mode 100644 index 0000000000..6ceac935f1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoCollection.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoCollection implements Serializable { + + private static final long serialVersionUID = 8380534468706675508L; + + @JsonProperty("model-version-id") + private String modelVersionId; + @JsonProperty("model-invariant-uuid") + private String modelInvariantUUID; + @JsonProperty("collection-function") + private String collectionFunction; + @JsonProperty("collection-role") + private String collectionRole; + @JsonProperty("collection-type") + private String collectionType; + @JsonProperty("description") + private String description; + @JsonProperty("quantity") + private int quantity; + + public String getModelVersionId() { + return modelVersionId; + } + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + public String getModelInvariantUUID() { + return this.modelInvariantUUID; + } + public void setModelInvariantUUID(String modelInvariantUUID) { + this.modelInvariantUUID = modelInvariantUUID; + } + public String getCollectionFunction() { + return collectionFunction; + } + public void setCollectionFunction(String collectionFunction) { + this.collectionFunction = collectionFunction; + } + public String getCollectionRole() { + return collectionRole; + } + public void setCollectionRole(String collectionRole) { + this.collectionRole = collectionRole; + } + public String getCollectionType() { + return collectionType; + } + public void setCollectionType(String collectionType) { + this.collectionType = collectionType; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public int getQuantity() { + return quantity; + } + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoConfiguration.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoConfiguration.java new file mode 100644 index 0000000000..9d3aa5934b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoConfiguration.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoConfiguration implements Serializable{ + + private static final long serialVersionUID = -387242776138157250L; + + @JsonProperty("model-invariant-id") + private String modelInvariantId; + @JsonProperty("model-version-id") + private String modelVersionId; + @JsonProperty("model-customization-id") + private String modelCustomizationId; + + public String getModelInvariantId() { + return modelInvariantId; + } + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + public String getModelVersionId() { + return modelVersionId; + } + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + public String getModelCustomizationId() { + return modelCustomizationId; + } + public void setModelCustomizationId(String modelCustomizationId) { + this.modelCustomizationId = modelCustomizationId; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java new file mode 100644 index 0000000000..6b53272a75 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoGenericVnf.java @@ -0,0 +1,145 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoGenericVnf extends ModelInfoMetadata implements Serializable{ + + private static final long serialVersionUID = -5963022750248280669L; + + @JsonProperty("tosca-node-type") + private String ToscaNodeType; + @JsonProperty("description") + private String Description; + @JsonProperty("orchestration-mode") + private String OrchestrationMode; + @JsonProperty("aic-version-min") + private String AicVersionMin; + @JsonProperty("aic-version-max") + private String AicVersionMax; + @JsonProperty("min-instances") + private String MinInstances; + @JsonProperty("max-instances") + private String MaxInstances; + @JsonProperty("availability-zone-max-count") + private String AvailabilityZoneMaxCount; + @JsonProperty("nf-function") + private String NfFunction; + @JsonProperty("nf-type") + private String NfType; + @JsonProperty("nf-role") + private String NfRole; + @JsonProperty("nf-naming-code") + private String NfNamingCode; + @JsonProperty("multi-stage-design") + private String MultiStageDesign; + @JsonProperty("created") + private String Created; + + + public String getToscaNodeType() { + return ToscaNodeType; + } + public void setToscaNodeType(String toscaNodeType) { + ToscaNodeType = toscaNodeType; + } + public String getDescription() { + return Description; + } + public void setDescription(String description) { + Description = description; + } + public String getOrchestrationMode() { + return OrchestrationMode; + } + public void setOrchestrationMode(String orchestrationMode) { + OrchestrationMode = orchestrationMode; + } + public String getAicVersionMin() { + return AicVersionMin; + } + public void setAicVersionMin(String aicVersionMin) { + AicVersionMin = aicVersionMin; + } + public String getAicVersionMax() { + return AicVersionMax; + } + public void setAicVersionMax(String aicVersionMax) { + AicVersionMax = aicVersionMax; + } + public String getMinInstances() { + return MinInstances; + } + public void setMinInstances(String minInstances) { + MinInstances = minInstances; + } + public String getMaxInstances() { + return MaxInstances; + } + public void setMaxInstances(String maxInstances) { + MaxInstances = maxInstances; + } + public String getAvailabilityZoneMaxCount() { + return AvailabilityZoneMaxCount; + } + public void setAvailabilityZoneMaxCount(String availabilityZoneMaxCount) { + AvailabilityZoneMaxCount = availabilityZoneMaxCount; + } + public String getNfFunction() { + return NfFunction; + } + public void setNfFunction(String nfFunction) { + NfFunction = nfFunction; + } + public String getNfType() { + return NfType; + } + public void setNfType(String nfType) { + NfType = nfType; + } + public String getNfRole() { + return NfRole; + } + public void setNfRole(String nfRole) { + NfRole = nfRole; + } + public String getNfNamingCode() { + return NfNamingCode; + } + public void setNfNamingCode(String nfNamingCode) { + NfNamingCode = nfNamingCode; + } + public String getMultiStageDesign() { + return MultiStageDesign; + } + public void setMultiStageDesign(String multiStageDesign) { + MultiStageDesign = multiStageDesign; + } + public String getCreated() { + return Created; + } + public void setCreated(String created) { + Created = created; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoInstanceGroup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoInstanceGroup.java new file mode 100644 index 0000000000..1f02fea071 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoInstanceGroup.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoInstanceGroup implements Serializable { + + private static final long serialVersionUID = -8279040393230356226L; + + public static final String TYPE_L3_NETWORK = "L3-NETWORK"; + public static final String TYPE_NETWORK_INSTANCE_GROUP = "networkInstanceGroup"; + public static final String TYPE_VNFC = "VNFC"; + + @JsonProperty("model-uuid") + private String ModelUUID; + @JsonProperty("model-invariant-uuid") + private String ModelInvariantUUID; + @JsonProperty("type") + private String type; + @JsonProperty("instance-group-role") + private String instanceGroupRole; + @JsonProperty("function") + private String function; + @JsonProperty("description") + private String description; + + public String getModelUUID() { + return ModelUUID; + } + public void setModelUUID(String modelUUID) { + ModelUUID = modelUUID; + } + public String getModelInvariantUUID() { + return ModelInvariantUUID; + } + public void setModelInvariantUUID(String modelInvariantUUID) { + ModelInvariantUUID = modelInvariantUUID; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getInstanceGroupRole() { + return instanceGroupRole; + } + public void setInstanceGroupRole(String instanceGroupRole) { + this.instanceGroupRole = instanceGroupRole; + } + public String getFunction() { + return function; + } + public void setFunction(String function) { + this.function = function; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoMetadata.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoMetadata.java new file mode 100644 index 0000000000..c873912922 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoMetadata.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoMetadata implements Serializable{ + + private static final long serialVersionUID = -2182850364281359289L; + + @JsonProperty("model-customization-uuid") + private String modelCustomizationUuid; + @JsonProperty("model-invariant-uuid") + private String modelInvariantUuid; + @JsonProperty("model-uuid") + private String modelUuid; + @JsonProperty("model-version") + private String modelVersion; + @JsonProperty("model-instance-name") + private String modelInstanceName; + @JsonProperty("model-name") + private String modelName; + + + public String getModelCustomizationUuid() { + return modelCustomizationUuid; + } + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public String getModelInvariantUuid() { + return modelInvariantUuid; + } + public void setModelInvariantUuid(String modelInvariantUuid) { + this.modelInvariantUuid = modelInvariantUuid; + } + public String getModelUuid() { + return modelUuid; + } + public void setModelUuid(String modelUuid) { + this.modelUuid = modelUuid; + } + public String getModelVersion() { + return modelVersion; + } + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + public String getModelInstanceName() { + return modelInstanceName; + } + public void setModelInstanceName(String modelInstanceName) { + this.modelInstanceName = modelInstanceName; + } + public String getModelName() { + return modelName; + } + public void setModelName(String modelName) { + this.modelName = modelName; + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoNetwork.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoNetwork.java new file mode 100644 index 0000000000..22233e94a5 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoNetwork.java @@ -0,0 +1,169 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; +import java.sql.Timestamp; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoNetwork implements Serializable{ + + private static final long serialVersionUID = -3612850497900637132L; + + @JsonProperty("model-customization-uuid") + private String ModelCustomizationUUID; + @JsonProperty("model-instance-name") + private String ModelInstanceName; + @JsonProperty("network-technology") + private String NetworkTechnology; + @JsonProperty("network-type") + private String NetworkType; + @JsonProperty("network-scope") + private String NetworkScope; + @JsonProperty("network-role") + private String NetworkRole; + @JsonProperty("description") + private String Description; + @JsonProperty("created") + private Timestamp Created; + @JsonProperty("model-version") + private String ModelVersion; + @JsonProperty("model-invariant-uuid") + private String ModelInvariantUUID; + @JsonProperty("model-name") + private String ModelName; + @JsonProperty("model-uuid") + private String ModelUUID; + @JsonProperty("neutron-network-type") + private String NeutronNetworkType; + @JsonProperty("aic-version-min") + private String AicVersionMin; + @JsonProperty("aic-version-max") + private String AicVersionMax; + @JsonProperty("orchestration-mode") + private String OrchestrationMode; + @JsonProperty("tosca-node-type") + private String ToscaNodeType; + + public String getModelCustomizationUUID() { + return ModelCustomizationUUID; + } + public void setModelCustomizationUUID(String modelCustomizationUUID) { + ModelCustomizationUUID = modelCustomizationUUID; + } + public String getModelInstanceName() { + return ModelInstanceName; + } + public void setModelInstanceName(String modelInstanceName) { + ModelInstanceName = modelInstanceName; + } + public String getNetworkTechnology() { + return NetworkTechnology; + } + public void setNetworkTechnology(String networkTechnology) { + NetworkTechnology = networkTechnology; + } + public String getNetworkType() { + return NetworkType; + } + public void setNetworkType(String networkType) { + NetworkType = networkType; + } + public String getNetworkScope() { + return NetworkScope; + } + public void setNetworkScope(String networkScope) { + NetworkScope = networkScope; + } + public String getNetworkRole() { + return NetworkRole; + } + public void setNetworkRole(String networkRole) { + NetworkRole = networkRole; + } + public String getDescription() { + return Description; + } + public void setDescription(String description) { + Description = description; + } + public Timestamp getCreated() { + return Created; + } + public void setCreated(Timestamp created) { + Created = created; + } + public String getModelVersion() { + return ModelVersion; + } + public void setModelVersion(String modelVersion) { + ModelVersion = modelVersion; + } + public String getModelInvariantUUID() { + return ModelInvariantUUID; + } + public void setModelInvariantUUID(String modelInvariantUUID) { + ModelInvariantUUID = modelInvariantUUID; + } + public String getModelName() { + return ModelName; + } + public void setModelName(String modelName) { + ModelName = modelName; + } + public String getModelUUID() { + return ModelUUID; + } + public void setModelUUID(String modelUUID) { + ModelUUID = modelUUID; + } + public String getNeutronNetworkType() { + return NeutronNetworkType; + } + public void setNeutronNetworkType(String neutronNetworkType) { + NeutronNetworkType = neutronNetworkType; + } + public String getAicVersionMin() { + return AicVersionMin; + } + public void setAicVersionMin(String aicVersionMin) { + AicVersionMin = aicVersionMin; + } + public String getAicVersionMax() { + return AicVersionMax; + } + public void setAicVersionMax(String aicVersionMax) { + AicVersionMax = aicVersionMax; + } + public String getOrchestrationMode() { + return OrchestrationMode; + } + public void setOrchestrationMode(String orchestrationMode) { + OrchestrationMode = orchestrationMode; + } + public String getToscaNodeType() { + return ToscaNodeType; + } + public void setToscaNodeType(String toscaNodeType) { + ToscaNodeType = toscaNodeType; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java new file mode 100644 index 0000000000..ac206d3dd0 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceInstance.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoServiceInstance extends ModelInfoMetadata implements Serializable { + + private static final long serialVersionUID = -1812787934683419141L; + + @JsonProperty("description") + private String description; + @JsonProperty("created") + private String created; + @JsonProperty("service-type") + private String serviceType; + @JsonProperty("service-role") + private String serviceRole; + @JsonProperty("environment-context") + private String environmentContext; + @JsonProperty("workload-context") + private String workloadContext; + + + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getCreated() { + return created; + } + public void setCreated(String created) { + this.created = created; + } + public String getServiceType() { + return serviceType; + } + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + public String getServiceRole() { + return serviceRole; + } + public void setServiceRole(String serviceRole) { + this.serviceRole = serviceRole; + } + public String getEnvironmentContext() { + return environmentContext; + } + public void setEnvironmentContext(String environmentContext) { + this.environmentContext = environmentContext; + } + public String getWorkloadContext() { + return workloadContext; + } + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceProxy.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceProxy.java new file mode 100644 index 0000000000..b2494384f4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoServiceProxy.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + + +import java.io.Serializable; + + +public class ModelInfoServiceProxy extends ModelInfoMetadata implements Serializable { + + private static final long serialVersionUID = -6256897576261215926L; + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoVfModule.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoVfModule.java new file mode 100644 index 0000000000..593f8c2532 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoVfModule.java @@ -0,0 +1,136 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoVfModule implements Serializable { + + private static final long serialVersionUID = 636556989022688657L; + + @JsonProperty("model-customization-uuid") + private String ModelCustomizationUUID; + @JsonProperty("model-name") + private String ModelName; + @JsonProperty("model-uuid") + private String ModelUUID; + @JsonProperty("model-invariant-uuid") + private String ModelInvariantUUID; + @JsonProperty("model-version") + private String ModelVersion; + @JsonProperty("description") + private String Description; + @JsonProperty("is-base-boolean") + private Boolean IsBaseBoolean; + @JsonProperty("min-instances") + private String MinInstances; + @JsonProperty("max-instances") + private String MaxInstances; + @JsonProperty("availability-zone-count") + private String AvailabilityZoneCount; + @JsonProperty("label") + private String Label; + @JsonProperty("initial-count") + private String InitialCount; + @JsonProperty("created") + private String Created; + + public String getModelCustomizationUUID() { + return ModelCustomizationUUID; + } + public void setModelCustomizationUUID(String modelCustomizationUUID) { + ModelCustomizationUUID = modelCustomizationUUID; + } + public String getModelName() { + return ModelName; + } + public void setModelName(String modelName) { + ModelName = modelName; + } + public String getModelUUID() { + return ModelUUID; + } + public void setModelUUID(String modelUUID) { + ModelUUID = modelUUID; + } + public String getModelInvariantUUID() { + return ModelInvariantUUID; + } + public void setModelInvariantUUID(String modelInvariantUUID) { + ModelInvariantUUID = modelInvariantUUID; + } + public String getModelVersion() { + return ModelVersion; + } + public void setModelVersion(String modelVersion) { + ModelVersion = modelVersion; + } + public String getDescription() { + return Description; + } + public void setDescription(String description) { + Description = description; + } + public Boolean getIsBaseBoolean() { + return IsBaseBoolean; + } + public void setIsBaseBoolean(Boolean isBaseBoolean) { + IsBaseBoolean = isBaseBoolean; + } + public String getMinInstances() { + return MinInstances; + } + public void setMinInstances(String minInstances) { + MinInstances = minInstances; + } + public String getMaxInstances() { + return MaxInstances; + } + public void setMaxInstances(String maxInstances) { + MaxInstances = maxInstances; + } + public String getAvailabilityZoneCount() { + return AvailabilityZoneCount; + } + public void setAvailabilityZoneCount(String availabilityZoneCount) { + AvailabilityZoneCount = availabilityZoneCount; + } + public String getLabel() { + return Label; + } + public void setLabel(String label) { + Label = label; + } + public String getInitialCount() { + return InitialCount; + } + public void setInitialCount(String initialCount) { + InitialCount = initialCount; + } + public String getCreated() { + return Created; + } + public void setCreated(String created) { + Created = created; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoVolumeGroup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoVolumeGroup.java new file mode 100644 index 0000000000..d3bf99ccb8 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/modelinfo/ModelInfoVolumeGroup.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.modelinfo; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ModelInfoVolumeGroup extends ModelInfoVfModule implements Serializable { + + private static final long serialVersionUID = -1157856848495642223L; +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/AssignFlows.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/AssignFlows.java new file mode 100644 index 0000000000..ac96aceec3 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/AssignFlows.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks; + +public enum AssignFlows { + + SERVICE_INSTANCE("AssignServiceInstanceBB"), + VNF("AssignVnfBB"), + VF_MODULE("AssignVfModuleBB"), + NETWORK_A_LA_CARTE("AssignNetwork1802BB"), + NETWORK_MACRO("AssignNetworkBB"), + VOLUME_GROUP("AssignVolumeGroupBB"), + NETWORK_COLLECTION("CreateNetworkCollectionBB"), + FABRIC_CONFIGURATION("AssignFabricConfigurationBB"); + + private final String flowName; + + private AssignFlows(String flowName) { + this.flowName = flowName; + } + + @Override + public String toString() { + return this.flowName; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java new file mode 100644 index 0000000000..aa68114011 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -0,0 +1,1586 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.javatuples.Pair; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; +import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; +import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.aai.AAICommonObjectMapperProvider; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.Relationships; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionResource; +import org.onap.so.db.catalog.beans.CollectionResourceCustomization; +import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; +import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.OrchestrationStatus; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.logger.MsoLogger; +import org.onap.so.serviceinstancebeans.CloudConfiguration; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.ModelType; +import org.onap.so.serviceinstancebeans.Networks; +import org.onap.so.serviceinstancebeans.RelatedInstance; +import org.onap.so.serviceinstancebeans.RelatedInstanceList; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestParameters; +import org.onap.so.serviceinstancebeans.Resources; +import org.onap.so.serviceinstancebeans.VfModules; +import org.onap.so.serviceinstancebeans.Vnfs; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +@Component("BBInputSetup") +public class BBInputSetup implements JavaDelegate { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, BBInputSetup.class); + private static final String FLOW_VAR_NAME = "flowToBeCalled"; + private static final String LOOKUP_KEY_MAP_VAR_NAME = "lookupKeyMap"; + private static final String GBB_INPUT_VAR_NAME = "gBBInput"; + private static final String EXECUTE_BB_VAR_NAME = "buildingBlock"; + private static final String CLOUD_OWNER = "att-aic"; + private static final String VOLUME_GROUP = "VolumeGroup"; + private static final String VF_MODULE = "VfModule"; + private static final String NETWORK = "Network"; + private static final String VNF = "Vnf"; + private static final String NETWORK_COLLECTION = "NetworkCollection"; + + @Autowired + private BBInputSetupUtils bbInputSetupUtils; + + @Autowired + private BBInputSetupMapperLayer mapperLayer; + + @Autowired + private ExceptionBuilder exceptionUtil; + + private ObjectMapper mapper = new ObjectMapper(); + + public BBInputSetupUtils getBbInputSetupUtils() { + return bbInputSetupUtils; + } + + public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) { + this.bbInputSetupUtils = bbInputSetupUtils; + } + + public BBInputSetupMapperLayer getMapperLayer() { + return mapperLayer; + } + + public void setMapperLayer(BBInputSetupMapperLayer mapperLayer) { + this.mapperLayer = mapperLayer; + } + + @Override + public void execute(DelegateExecution execution) throws Exception { + try { + GeneralBuildingBlock outputBB = null; + ExecuteBuildingBlock executeBB = this.getExecuteBBFromExecution(execution); + String resourceId = executeBB.getResourceId(); + String requestAction = executeBB.getRequestAction(); + String vnfType = executeBB.getVnfType(); + boolean aLaCarte = executeBB.isaLaCarte(); + boolean homing = executeBB.isHoming(); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + outputBB = this.getGBB(executeBB, lookupKeyMap, requestAction, aLaCarte, resourceId, vnfType); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.INDENT_OUTPUT); + msoLogger.debug("GeneralBB: " + mapper.writeValueAsString(outputBB)); + + setHomingFlag(outputBB, homing, lookupKeyMap); + + execution.setVariable(FLOW_VAR_NAME, executeBB.getBuildingBlock().getBpmnFlowName()); + execution.setVariable(GBB_INPUT_VAR_NAME, outputBB); + execution.setVariable(LOOKUP_KEY_MAP_VAR_NAME, lookupKeyMap); + + BuildingBlockExecution gBuildingBlockExecution = new DelegateExecutionImpl(execution); + execution.setVariable("gBuildingBlockExecution", gBuildingBlockExecution); + execution.setVariable("RetryCount", 1); + execution.setVariable("handlingCode", "Success"); + } catch (Exception e) { + msoLogger.error(e); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage()); + } + } + + protected void setHomingFlag(GeneralBuildingBlock outputBB, boolean homing, Map<ResourceKey, String> lookupKeyMap) { + + if (lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID) != null && homing && outputBB != null) { + for (GenericVnf vnf : outputBB.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs()) { + if (vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + vnf.setCallHoming(homing); + } + } + } + } + + protected ExecuteBuildingBlock getExecuteBBFromExecution(DelegateExecution execution) { + return (ExecuteBuildingBlock) execution.getVariable(EXECUTE_BB_VAR_NAME); + } + + protected GeneralBuildingBlock getGBB(ExecuteBuildingBlock executeBB, Map<ResourceKey, String> lookupKeyMap, + String requestAction, boolean aLaCarte, String resourceId, String vnfType) throws Exception { + String requestId = executeBB.getRequestId(); + this.populateLookupKeyMapWithIds(executeBB.getWorkflowResourceIds(), lookupKeyMap); + RequestDetails requestDetails = executeBB.getRequestDetails(); + if(requestDetails == null) { + requestDetails = bbInputSetupUtils.getRequestDetails(requestId); + } + ModelType modelType = requestDetails.getModelInfo().getModelType(); + if (aLaCarte && modelType.equals(ModelType.service)) { + return this.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId); + } else if (aLaCarte && !modelType.equals(ModelType.service)) { + return this.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, + vnfType); + } else { + return this.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); + } + } + + protected void populateLookupKeyMapWithIds(WorkflowResourceIds workflowResourceIds, + Map<ResourceKey, String> lookupKeyMap) { + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, workflowResourceIds.getServiceInstanceId()); + lookupKeyMap.put(ResourceKey.NETWORK_ID, workflowResourceIds.getNetworkId()); + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, workflowResourceIds.getVnfId()); + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, workflowResourceIds.getVfModuleId()); + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, workflowResourceIds.getVolumeGroupId()); + lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, workflowResourceIds.getConfigurationId()); + } + + protected GeneralBuildingBlock getGBBALaCarteNonService(ExecuteBuildingBlock executeBB, + RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, + String resourceId, String vnfType) throws Exception { + String bbName = executeBB.getBuildingBlock().getBpmnFlowName(); + String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID); + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null; + if (serviceInstanceId != null) { + aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); + } + Service service = null; + if (aaiServiceInstance != null) { + service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + } + if (aaiServiceInstance != null && service != null) { + ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance); + serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service)); + this.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, + resourceId, vnfType); + return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); + } else { + msoLogger.debug("Related Service Instance from AAI: " + aaiServiceInstance); + msoLogger.debug("Related Service Instance Model Info from AAI: " + service); + throw new Exception("Could not find relevant information for related Service Instance"); + } + } + + protected void populateObjectsOnAssignAndCreateFlows(RequestDetails requestDetails, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType) + throws Exception { + ModelInfo modelInfo = requestDetails.getModelInfo(); + String instanceName = requestDetails.getRequestInfo().getInstanceName(); + ModelType modelType = modelInfo.getModelType(); + RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList(); + + org.onap.so.serviceinstancebeans.Platform platform = requestDetails.getPlatform(); + org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = requestDetails.getLineOfBusiness(); + + if (modelType.equals(ModelType.network)) { + this.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, null); + } else if (modelType.equals(ModelType.vnf)) { + this.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, + lookupKeyMap, relatedInstanceList, resourceId, vnfType, null); + } else if (modelType.equals(ModelType.volumeGroup)) { + this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, vnfType, null); + } else if (modelType.equals(ModelType.vfModule)) { + this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration()); + } else { + return; + } + } + + protected void populateConfiguration(ModelInfo modelInfo, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String instanceName) { + boolean foundByName = false; + boolean foundById = false; + for (Configuration configuration : serviceInstance.getConfigurations()) { + if (lookupKeyMap.get(ResourceKey.CONFIGURATION_ID) != null + && configuration.getConfigurationId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.CONFIGURATION_ID))) { + foundById = true; + org.onap.aai.domain.yang.Configuration aaiConfiguration = bbInputSetupUtils.getAAIConfiguration(configuration.getConfigurationId()); + if(aaiConfiguration!=null){ + modelInfo.setModelCustomizationUuid(aaiConfiguration.getModelCustomizationId()); + } + this.mapCatalogConfiguration(configuration, modelInfo, service); + } else if (instanceName != null && configuration.getConfigurationName().equalsIgnoreCase(instanceName)) { + foundByName = true; + lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, configuration.getConfigurationId()); + org.onap.aai.domain.yang.Configuration aaiConfiguration = bbInputSetupUtils.getAAIConfiguration(configuration.getConfigurationId()); + if(aaiConfiguration!=null){ + modelInfo.setModelCustomizationUuid(aaiConfiguration.getModelCustomizationId()); + } + this.mapCatalogConfiguration(configuration, modelInfo, service); + } + } + if (!foundByName && !foundById && bbName.equalsIgnoreCase(AssignFlows.FABRIC_CONFIGURATION.toString())) { + Configuration configuration = this.createConfiguration(lookupKeyMap, instanceName, resourceId); + serviceInstance.getConfigurations().add(configuration); + this.mapCatalogConfiguration(configuration, modelInfo, service); + } + } + + protected Configuration createConfiguration(Map<ResourceKey, String> lookupKeyMap, + String instanceName, String resourceId) { + lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, resourceId); + Configuration configuration = new Configuration(); + configuration.setConfigurationId(resourceId); + configuration.setConfigurationName(instanceName); + configuration.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + return configuration; + } + + protected void mapCatalogConfiguration(Configuration configuration, ModelInfo modelInfo, Service service) { + ConfigurationResourceCustomization configurationResourceCustomization = findConfigurationResourceCustomization(modelInfo, service); + if (configurationResourceCustomization != null) { + configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization)); + } + } + + protected ConfigurationResourceCustomization findConfigurationResourceCustomization(ModelInfo modelInfo, Service service) { + for (ConfigurationResourceCustomization resourceCust : service.getConfigurationCustomizations()) { + if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(modelInfo.getModelCustomizationUuid())) { + return resourceCust; + } + } + return null; + } + + protected void populateVfModule(ModelInfo modelInfo, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, + RelatedInstanceList[] relatedInstanceList, String instanceName, List<Map<String, String>> instanceParams, CloudConfiguration cloudConfiguration) throws Exception { + boolean foundByName = false; + boolean foundById = false; + String vnfModelCustomizationUUID = null; + if (relatedInstanceList != null) { + for (RelatedInstanceList relatedInstList : relatedInstanceList) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { + vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) { + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, relatedInstance.getInstanceId()); + } + } + } + GenericVnf vnf = null; + for (GenericVnf tempVnf : serviceInstance.getVnfs()) { + if (tempVnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + vnf = tempVnf; + vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()) + .getModelCustomizationId(); + ModelInfo vnfModelInfo = new ModelInfo(); + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + this.mapCatalogVnf(tempVnf, vnfModelInfo, service); + for(VolumeGroup volumeGroup : tempVnf.getVolumeGroups()) { + String volumeGroupCustId = + this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, + cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()).getModelCustomizationId(); + if(modelInfo.getModelCustomizationId().equalsIgnoreCase(volumeGroupCustId)) { + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); + } + } + break; + } + } + if (vnf != null) { + for (VfModule vfModule : vnf.getVfModules()) { + if (lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null + && vfModule.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) { + foundById = true; + this.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + } else if (instanceName != null && vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) { + foundByName = true; + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId()); + this.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + } + } + if (!foundByName && !foundById && bbName.equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) { + VfModule vfModule = this.createVfModule(lookupKeyMap, + resourceId, instanceName, instanceParams); + this.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + vnf.getVfModules().add(vfModule); + } + } else { + msoLogger.debug("Related VNF instance Id not found: " + lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID)); + throw new Exception("Could not find relevant information for related VNF"); + } + } + + protected void mapCatalogVfModule(VfModule vfModule, ModelInfo modelInfo, Service service, + String vnfModelCustomizationUUID) { + if(modelInfo.getModelCustomizationUuid() != null) { + modelInfo.setModelCustomizationId(modelInfo.getModelCustomizationUuid()); + } + VnfResourceCustomization vnfResourceCustomization = null; + for (VnfResourceCustomization resourceCust : service.getVnfCustomizations()) { + if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(vnfModelCustomizationUUID)) { + vnfResourceCustomization = resourceCust; + break; + } + } + if (vnfResourceCustomization != null) { + VfModuleCustomization vfResourceCustomization = vnfResourceCustomization.getVfModuleCustomizations() + .stream() // Convert to steam + .filter(x -> modelInfo.getModelCustomizationId().equalsIgnoreCase(x.getModelCustomizationUUID()))// find + // what + // we + // want + .findAny() // If 'findAny' then return found + .orElse(null); + if (vfResourceCustomization != null) { + vfModule.setModelInfoVfModule(this.mapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization)); + } + } + } + + protected VfModule createVfModule(Map<ResourceKey, String> lookupKeyMap, String vfModuleId, String instanceName, List<Map<String, String>> instanceParams) { + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModuleId); + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId(vfModuleId); + vfModule.setVfModuleName(instanceName); + vfModule.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + if(instanceParams != null) { + for(Map<String, String> params : instanceParams) { + vfModule.getCloudParams().putAll(params); + } + } + return vfModule; + } + + protected void populateVolumeGroup(ModelInfo modelInfo, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, + RelatedInstanceList[] relatedInstanceList, String instanceName, String vnfType, List<Map<String, String>> instanceParams) throws Exception { + boolean foundByName = false; + boolean foundById = false; + String vnfModelCustomizationUUID = null; + if (relatedInstanceList != null) { + for (RelatedInstanceList relatedInstList : relatedInstanceList) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { + vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationUuid(); + } + } + } + GenericVnf vnf = null; + for (GenericVnf tempVnf : serviceInstance.getVnfs()) { + if (tempVnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + vnf = tempVnf; + vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()) + .getModelCustomizationId(); + ModelInfo vnfModelInfo = new ModelInfo(); + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + this.mapCatalogVnf(tempVnf, vnfModelInfo, service); + break; + } + } + if (vnf != null && vnfModelCustomizationUUID != null) { + for (VolumeGroup volumeGroup : vnf.getVolumeGroups()) { + if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) != null && volumeGroup.getVolumeGroupId() + .equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID))) { + foundById = true; + this.mapCatalogVolumeGroup(volumeGroup, modelInfo, service, vnfModelCustomizationUUID); + } else if (instanceName != null && volumeGroup.getVolumeGroupName().equalsIgnoreCase(instanceName)) { + foundByName = true; + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId()); + this.mapCatalogVolumeGroup(volumeGroup, modelInfo, service, vnfModelCustomizationUUID); + } + } + if (!foundByName && !foundById && bbName.equalsIgnoreCase(AssignFlows.VOLUME_GROUP.toString())) { + if (vnfType == null || vnfType.isEmpty()) { + vnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName(); + } + VolumeGroup volumeGroup = this.createVolumeGroup(lookupKeyMap, resourceId, instanceName, vnfType, instanceParams); + vnf.getVolumeGroups().add(volumeGroup); + this.mapCatalogVolumeGroup(volumeGroup, modelInfo, service, vnfModelCustomizationUUID); + } + } else { + msoLogger.debug("Related VNF instance Id not found: " + lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID)); + throw new Exception("Could not find relevant information for related VNF"); + } + } + + protected VolumeGroup createVolumeGroup(Map<ResourceKey, String> lookupKeyMap, String volumeGroupId, String instanceName, String vnfType, List<Map<String, String>> instanceParams) { + lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupId); + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId(volumeGroupId); + volumeGroup.setVolumeGroupName(instanceName); + volumeGroup.setVnfType(vnfType); + volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + if(instanceParams != null) { + for(Map<String, String> params : instanceParams) { + volumeGroup.getCloudParams().putAll(params); + } + } + return volumeGroup; + } + + protected void mapCatalogVolumeGroup(VolumeGroup volumeGroup, ModelInfo modelInfo, Service service, + String vnfModelCustomizationUUID) { + VfModuleCustomization vfResourceCustomization = getVfResourceCustomization(modelInfo, service, + vnfModelCustomizationUUID); + if (vfResourceCustomization != null) { + volumeGroup.setModelInfoVfModule(this.mapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization)); + } + } + + protected VfModuleCustomization getVfResourceCustomization(ModelInfo modelInfo, Service service, + String vnfModelCustomizationUUID) { + VnfResourceCustomization vnfResourceCustomization = null; + for (VnfResourceCustomization resourceCust : service.getVnfCustomizations()) { + if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(vnfModelCustomizationUUID)) { + vnfResourceCustomization = resourceCust; + break; + } + } + if (vnfResourceCustomization != null) { + for (VfModuleCustomization vfResourceCust : vnfResourceCustomization.getVfModuleCustomizations()) { + if (vfResourceCust.getModelCustomizationUUID() + .equalsIgnoreCase(modelInfo.getModelCustomizationUuid())) { + return vfResourceCust; + } + } + + } + return null; + } + + protected void populateGenericVnf(ModelInfo modelInfo, String instanceName, + org.onap.so.serviceinstancebeans.Platform platform, + org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, + RelatedInstanceList[] relatedInstanceList, String resourceId, String vnfType, List<Map<String, String>> instanceParams) { + boolean foundByName = false; + boolean foundById = false; + ModelInfo instanceGroupModelInfo = null; + String instanceGroupId = null; + if (relatedInstanceList != null) { + for (RelatedInstanceList relatedInstList : relatedInstanceList) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.networkCollection)) { + instanceGroupModelInfo = relatedInstance.getModelInfo(); + instanceGroupId = relatedInstance.getInstanceId(); + } + } + } + for (GenericVnf genericVnf : serviceInstance.getVnfs()) { + if (lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID) != null + && genericVnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + foundById = true; + org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(genericVnf.getVnfId()); + if(vnf!=null){ + modelInfo.setModelCustomizationUuid(vnf.getModelCustomizationId()); + } + this.mapCatalogVnf(genericVnf, modelInfo, service); + } else if (instanceName != null && genericVnf.getVnfName().equalsIgnoreCase(instanceName)) { + foundByName = true; + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId()); + org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(genericVnf.getVnfId()); + if(vnf!=null){ + modelInfo.setModelCustomizationUuid(vnf.getModelCustomizationId()); + } + this.mapCatalogVnf(genericVnf, modelInfo, service); + } + } + if (!foundByName && !foundById && bbName.equalsIgnoreCase(AssignFlows.VNF.toString())) { + if(vnfType == null || vnfType.isEmpty()) { + vnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName(); + } + GenericVnf genericVnf = this.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness, + resourceId, vnfType, instanceParams); + serviceInstance.getVnfs().add(genericVnf); + this.mapCatalogVnf(genericVnf, modelInfo, service); + this.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service); + if (instanceGroupId != null && instanceGroupModelInfo != null) + this.mapNetworkCollectionInstanceGroup(genericVnf, instanceGroupId); + } + } + + protected void mapVnfcCollectionInstanceGroup(GenericVnf genericVnf, ModelInfo modelInfo, Service service) { + VnfResourceCustomization vnfResourceCustomization = getVnfResourceCustomizationFromService(modelInfo, service); + if(vnfResourceCustomization != null) { + List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = vnfResourceCustomization + .getVnfcInstanceGroupCustomizations(); + for (VnfcInstanceGroupCustomization vnfcInstanceGroupCust : vnfcInstanceGroups) { + InstanceGroup instanceGroup = this.createInstanceGroup(); + instanceGroup.setModelInfoInstanceGroup(this.mapperLayer + .mapCatalogInstanceGroupToInstanceGroup(null, vnfcInstanceGroupCust.getInstanceGroup())); + instanceGroup.getModelInfoInstanceGroup().setFunction(vnfcInstanceGroupCust.getFunction()); + instanceGroup.setDescription(vnfcInstanceGroupCust.getDescription()); + genericVnf.getInstanceGroups().add(instanceGroup); + } + } + } + + protected void mapNetworkCollectionInstanceGroup(GenericVnf genericVnf, String instanceGroupId) { + org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = this.bbInputSetupUtils + .getAAIInstanceGroup(instanceGroupId); + InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup); + instanceGroup.setModelInfoInstanceGroup(this.mapperLayer.mapCatalogInstanceGroupToInstanceGroup( + null, this.bbInputSetupUtils.getCatalogInstanceGroup(aaiInstanceGroup.getModelVersionId()))); + genericVnf.getInstanceGroups().add(instanceGroup); + } + + protected GenericVnf createGenericVnf(Map<ResourceKey, String> lookupKeyMap, String instanceName, + org.onap.so.serviceinstancebeans.Platform platform, + org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, String vnfId, String vnfType, List<Map<String, String>> instanceParams) { + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId); + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId(vnfId); + genericVnf.setVnfName(instanceName); + genericVnf.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + genericVnf.setVnfType(vnfType); + if (platform != null) { + genericVnf.setPlatform(this.mapperLayer.mapRequestPlatform(platform)); + } + if (lineOfBusiness != null) { + genericVnf.setLineOfBusiness(this.mapperLayer.mapRequestLineOfBusiness(lineOfBusiness)); + } + if(instanceParams != null) { + for(Map<String, String> params : instanceParams) { + genericVnf.getCloudParams().putAll(params); + } + } + return genericVnf; + } + + protected void mapCatalogVnf(GenericVnf genericVnf, ModelInfo modelInfo, Service service) { + VnfResourceCustomization vnfResourceCustomization = getVnfResourceCustomizationFromService(modelInfo, service); + if (vnfResourceCustomization != null) { + genericVnf.setModelInfoGenericVnf(this.mapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization)); + } + } + + protected VnfResourceCustomization getVnfResourceCustomizationFromService(ModelInfo modelInfo, Service service) { + VnfResourceCustomization vnfResourceCustomization = null; + for (VnfResourceCustomization resourceCust : service.getVnfCustomizations()) { + if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(modelInfo.getModelCustomizationUuid())) { + vnfResourceCustomization = resourceCust; + break; + } + } + return vnfResourceCustomization; + } + + protected void populateL3Network(String instanceName, ModelInfo modelInfo, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, List<Map<String, String>> instanceParams) { + boolean foundByName = false; + boolean foundById = false; + for (L3Network network : serviceInstance.getNetworks()) { + if (lookupKeyMap.get(ResourceKey.NETWORK_ID) != null + && network.getNetworkId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.NETWORK_ID))) { + foundById = true; + this.mapCatalogNetwork(network, modelInfo, service); + } else if (instanceName != null && network.getNetworkName().equalsIgnoreCase(instanceName)) { + foundByName = true; + lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId()); + this.mapCatalogNetwork(network, modelInfo, service); + } + } + if (!foundByName && !foundById + && (bbName.equalsIgnoreCase(AssignFlows.NETWORK_A_LA_CARTE.toString()) + || bbName.equalsIgnoreCase(AssignFlows.NETWORK_MACRO.toString()))) { + L3Network l3Network = this.createNetwork(lookupKeyMap, instanceName, resourceId, instanceParams); + serviceInstance.getNetworks().add(l3Network); + this.mapCatalogNetwork(l3Network, modelInfo, service); + } + } + + protected L3Network createNetwork(Map<ResourceKey, String> lookupKeyMap, String instanceName, + String networkId, List<Map<String, String>> instanceParams) { + lookupKeyMap.put(ResourceKey.NETWORK_ID, networkId); + L3Network network = new L3Network(); + network.setNetworkId(networkId); + network.setNetworkName(instanceName); + network.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + if(instanceParams != null) { + for(Map<String, String> params : instanceParams) { + network.getCloudParams().putAll(params); + } + } + return network; + } + + protected void mapCatalogNetwork(L3Network network, ModelInfo modelInfo, Service service) { + NetworkResourceCustomization networkResourceCustomization = null; + for (NetworkResourceCustomization resourceCust : service.getNetworkCustomizations()) { + if (resourceCust.getModelCustomizationUUID().equalsIgnoreCase(modelInfo.getModelCustomizationUuid())) { + networkResourceCustomization = resourceCust; + break; + } + } + if (networkResourceCustomization != null) { + network.setModelInfoNetwork(this.mapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization)); + } + } + + protected GeneralBuildingBlock getGBBALaCarteService(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, + Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId) throws Exception { + Customer customer = getCustomerAndServiceSubscription(requestDetails, resourceId); + if (customer != null) { + Project project = null; + OwningEntity owningEntity = null; + + if (requestDetails.getProject() != null) + project = mapperLayer.mapRequestProject(requestDetails.getProject()); + if (requestDetails.getOwningEntity() != null) + owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity()); + + + Service service = bbInputSetupUtils + .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId()); + if (service == null) { + service = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID( + requestDetails.getModelInfo().getModelVersion(), + requestDetails.getModelInfo().getModelInvariantId()); + if(service == null) { + throw new Exception("Could not find service for model version Id: " + + requestDetails.getModelInfo().getModelVersionId() + " and for model invariant Id: " + + requestDetails.getModelInfo().getModelInvariantId()); + } + } + ServiceInstance serviceInstance = this.getALaCarteServiceInstance(service, requestDetails, customer, + project, owningEntity, lookupKeyMap, resourceId, executeBB.isaLaCarte(), + executeBB.getBuildingBlock().getBpmnFlowName()); + return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, customer); + } else { + throw new Exception("Could not find customer"); + } + } + + protected Customer getCustomerAndServiceSubscription(RequestDetails requestDetails, String resourceId) { + Customer customer; + if (requestDetails.getSubscriberInfo() != null) { + customer = this.getCustomerFromRequest(requestDetails); + } else { + customer = this.getCustomerFromURI(resourceId); + } + if (customer != null) { + ServiceSubscription serviceSubscription = null; + serviceSubscription = getServiceSubscription(requestDetails, customer); + if (serviceSubscription == null) { + serviceSubscription = getServiceSubscriptionFromURI(resourceId, customer); + } + customer.setServiceSubscription(serviceSubscription); + return customer; + } else { + return null; + } + } + + protected ServiceSubscription getServiceSubscriptionFromURI(String resourceId, Customer customer) { + Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(resourceId); + String subscriptionServiceType = uriKeys.get("service-type"); + org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionAAI = bbInputSetupUtils + .getAAIServiceSubscription(customer.getGlobalCustomerId(), subscriptionServiceType); + if (serviceSubscriptionAAI != null) { + return mapperLayer.mapAAIServiceSubscription(serviceSubscriptionAAI); + } else { + return null; + } + } + + protected Customer getCustomerFromURI(String resourceId) { + Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(resourceId); + String globalCustomerId = uriKeys.get("global-customer-id"); + org.onap.aai.domain.yang.Customer customerAAI = this.bbInputSetupUtils.getAAICustomer(globalCustomerId); + if (customerAAI != null) { + return mapperLayer.mapAAICustomer(customerAAI); + } else { + return null; + } + } + + protected GeneralBuildingBlock populateGBBWithSIAndAdditionalInfo(RequestDetails requestDetails, + ServiceInstance serviceInstance, ExecuteBuildingBlock executeBB, String requestAction, Customer customer) { + GeneralBuildingBlock outputBB = new GeneralBuildingBlock(); + OrchestrationContext orchContext = mapperLayer.mapOrchestrationContext(requestDetails); + RequestContext requestContext = mapperLayer.mapRequestContext(requestDetails); + requestContext.setAction(requestAction); + requestContext.setMsoRequestId(executeBB.getRequestId()); + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils + .getCloudRegion(requestDetails.getCloudConfiguration(), CLOUD_OWNER); + CloudRegion cloudRegion = mapperLayer.mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion, + CLOUD_OWNER); + outputBB.setOrchContext(orchContext); + outputBB.setRequestContext(requestContext); + outputBB.setCloudRegion(cloudRegion); + if(customer == null){ + Map<String, String> uriKeys = bbInputSetupUtils.getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId()); + String globalCustomerId = uriKeys.get("global-customer-id"); + String subscriptionServiceType = uriKeys.get("service-type"); + customer = mapCustomer(globalCustomerId, subscriptionServiceType); + } + outputBB.setServiceInstance(serviceInstance); + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + outputBB.setCustomer(customer); + return outputBB; + } + + protected ServiceSubscription getServiceSubscription(RequestDetails requestDetails, Customer customer) { + org.onap.aai.domain.yang.ServiceSubscription aaiServiceSubscription = bbInputSetupUtils + .getAAIServiceSubscription(customer.getGlobalCustomerId(), + requestDetails.getRequestParameters().getSubscriptionServiceType()); + if (aaiServiceSubscription != null) { + return mapperLayer.mapAAIServiceSubscription(aaiServiceSubscription); + } else { + return null; + } + } + + protected Customer getCustomerFromRequest(RequestDetails requestDetails) { + org.onap.aai.domain.yang.Customer aaiCustomer = bbInputSetupUtils + .getAAICustomer(requestDetails.getSubscriberInfo().getGlobalSubscriberId()); + if (aaiCustomer != null) { + return mapperLayer.mapAAICustomer(aaiCustomer); + } else { + return null; + } + } + + protected ServiceInstance getALaCarteServiceInstance(Service service, RequestDetails requestDetails, + Customer customer, Project project, OwningEntity owningEntity, Map<ResourceKey, String> lookupKeyMap, + String serviceInstanceId, boolean aLaCarte, String bbName) throws Exception { + ServiceInstance serviceInstance = this.getServiceInstanceHelper(requestDetails, customer, project, owningEntity, + lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName); + org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = this.bbInputSetupUtils + .getAAIServiceInstanceById(serviceInstanceId); + if (serviceInstanceAAI != null + && !serviceInstanceAAI.getModelVersionId().equalsIgnoreCase(service.getModelUUID())) { + Service tempService = this.bbInputSetupUtils + .getCatalogServiceByModelUUID(serviceInstanceAAI.getModelVersionId()); + if (tempService != null) { + serviceInstance + .setModelInfoServiceInstance(mapperLayer.mapCatalogServiceIntoServiceInstance(tempService)); + return serviceInstance; + } else { + throw new Exception( + "Could not find model of existing SI. Service Instance in AAI already exists with different model version id: " + + serviceInstanceAAI.getModelVersionId()); + } + } + serviceInstance.setModelInfoServiceInstance(mapperLayer.mapCatalogServiceIntoServiceInstance(service)); + return serviceInstance; + } + + protected GeneralBuildingBlock getGBBMacro(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, + Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId, String vnfType) + throws Exception { + String bbName = executeBB.getBuildingBlock().getBpmnFlowName(); + String key = executeBB.getBuildingBlock().getKey(); + GeneralBuildingBlock gBB = this.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, + resourceId); + RequestParameters requestParams = requestDetails.getRequestParameters(); + Service service = null; + if (gBB != null && gBB.getServiceInstance() != null + && gBB.getServiceInstance().getModelInfoServiceInstance() != null + && gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid() != null) { + service = bbInputSetupUtils.getCatalogServiceByModelUUID( + gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid()); + } else { + throw new Exception("Could not get service instance for macro request"); + } + if (requestParams != null && requestParams.getUserParams() != null) { + for(Map<String, Object> userParams : requestParams.getUserParams()) { + if(userParams.containsKey("service")) { + String input = mapper.writeValueAsString(userParams.get("service")); + return getGBBMacroUserParams(executeBB, requestDetails, lookupKeyMap, vnfType, bbName, key, gBB, + requestParams, service, input); + } + } + } + if (requestAction.equalsIgnoreCase("deactivateInstance")) { + return gBB; + } else if (requestAction.equalsIgnoreCase("createInstance")) { + return getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap, bbName, key, gBB, service); + } else if (requestAction.equalsIgnoreCase("deleteInstance") + || requestAction.equalsIgnoreCase("unassignInstance") + || requestAction.equalsIgnoreCase("activateInstance") + || requestAction.equalsIgnoreCase("activateFabricConfiguration")) { + return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, gBB, service, requestAction, + requestDetails.getCloudConfiguration()); + } else { + throw new IllegalArgumentException( + "No user params on requestAction: assignInstance. Please specify user params."); + } + } + + protected GeneralBuildingBlock getGBBMacroNoUserParamsCreate(ExecuteBuildingBlock executeBB, + Map<ResourceKey, String> lookupKeyMap, String bbName, String key, GeneralBuildingBlock gBB, Service service) + throws Exception { + ServiceInstance serviceInstance = gBB.getServiceInstance(); + if (bbName.contains(NETWORK) && !bbName.contains(NETWORK_COLLECTION)) { + String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID); + ModelInfo networkModelInfo = new ModelInfo(); + if(!executeBB.getBuildingBlock().getIsVirtualLink()) { + NetworkResourceCustomization networkCust = getNetworkCustomizationByKey(key, service); + if (networkCust != null) { + networkModelInfo.setModelCustomizationUuid(networkCust.getModelCustomizationUUID()); + this.populateL3Network(null, networkModelInfo, service, bbName, serviceInstance, lookupKeyMap, + networkId, null); + } else { + msoLogger.debug("Could not find a network customization with key: " + key); + } + } else { + msoLogger.debug("Orchestrating on Collection Network Resource Customization"); + serviceInstance.getNetworks().add(getVirtualLinkL3Network(lookupKeyMap, bbName, key, networkId)); + } + } else if(bbName.contains("Configuration")) { + String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID); + ModelInfo configurationModelInfo = new ModelInfo(); + configurationModelInfo.setModelCustomizationUuid(key); + ConfigurationResourceCustomization configurationCust = findConfigurationResourceCustomization(configurationModelInfo, service); + if(configurationCust != null) { + this.populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, configurationId, null); + } else { + msoLogger.debug("Could not find a configuration customization with key: " + key); + } + } + if (executeBB.getWorkflowResourceIds() != null) { + this.populateNetworkCollectionAndInstanceGroupAssign(service, bbName, serviceInstance, + executeBB.getWorkflowResourceIds().getNetworkCollectionId(), key); + } + return gBB; + } + + protected L3Network getVirtualLinkL3Network(Map<ResourceKey, String> lookupKeyMap, String bbName, String key, + String networkId) { + CollectionNetworkResourceCustomization collectionNetworkResourceCust = bbInputSetupUtils.getCatalogCollectionNetworkResourceCustByID(key); + if(collectionNetworkResourceCust != null && (bbName.equalsIgnoreCase(AssignFlows.NETWORK_A_LA_CARTE.toString()) + || bbName.equalsIgnoreCase(AssignFlows.NETWORK_MACRO.toString()))) { + NetworkResourceCustomization networkResourceCustomization = + mapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust); + L3Network l3Network = createNetwork(lookupKeyMap, null, networkId, null); + l3Network.setModelInfoNetwork(mapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization)); + return l3Network; + } + return null; + } + + protected NetworkResourceCustomization getNetworkCustomizationByKey(String key, Service service) { + for (NetworkResourceCustomization networkCust : service.getNetworkCustomizations()) { + if (networkCust.getModelCustomizationUUID().equalsIgnoreCase(key)) { + return networkCust; + } + } + return null; + } + + protected GeneralBuildingBlock getGBBMacroExistingService(ExecuteBuildingBlock executeBB, + Map<ResourceKey, String> lookupKeyMap, String bbName, GeneralBuildingBlock gBB, Service service, + String requestAction, CloudConfiguration cloudConfiguration) throws Exception { + ServiceInstance serviceInstance = gBB.getServiceInstance(); + if (cloudConfiguration != null && requestAction.equalsIgnoreCase("deleteInstance")) { + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration, + CLOUD_OWNER); + CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion, CLOUD_OWNER); + gBB.setCloudRegion(cloudRegion); + } + if (bbName.contains(VNF)) { + for (GenericVnf genericVnf : serviceInstance.getVnfs()) { + if (lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID) != null + && genericVnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(genericVnf.getVnfId()); + ModelInfo modelInfo = new ModelInfo(); + if (vnf != null) { + modelInfo.setModelCustomizationUuid(vnf.getModelCustomizationId()); + } + this.mapCatalogVnf(genericVnf, modelInfo, service); + } + } + } else if (bbName.contains(VF_MODULE)) { + for (GenericVnf vnf : serviceInstance.getVnfs()) { + for (VfModule vfModule : vnf.getVfModules()) { + if (lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null + && vfModule.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) { + String vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()) + .getModelCustomizationId(); + ModelInfo vnfModelInfo = new ModelInfo(); + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + this.mapCatalogVnf(vnf, vnfModelInfo, service); + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnf.getVnfId()); + String vfModuleCustomizationUUID = this.bbInputSetupUtils + .getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()).getModelCustomizationId(); + ModelInfo vfModuleModelInfo = new ModelInfo(); + vfModuleModelInfo.setModelCustomizationId(vfModuleCustomizationUUID); + this.mapCatalogVfModule(vfModule, vfModuleModelInfo, service, vnfModelCustomizationUUID); + break; + } + } + } + } else if (bbName.contains(VOLUME_GROUP)) { + for (GenericVnf vnf : serviceInstance.getVnfs()) { + for (VolumeGroup volumeGroup : vnf.getVolumeGroups()) { + if (lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID) != null && volumeGroup.getVolumeGroupId() + .equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID))) { + String vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()) + .getModelCustomizationId(); + ModelInfo vnfModelInfo = new ModelInfo(); + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + this.mapCatalogVnf(vnf, vnfModelInfo, service); + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnf.getVnfId()); + if (cloudConfiguration != null) { + String volumeGroupCustomizationUUID = this.bbInputSetupUtils.getAAIVolumeGroup(CLOUD_OWNER, + cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()) + .getModelCustomizationId(); + ModelInfo volumeGroupModelInfo = new ModelInfo(); + volumeGroupModelInfo.setModelCustomizationId(volumeGroupCustomizationUUID); + this.mapCatalogVolumeGroup(volumeGroup, volumeGroupModelInfo, service, + vnfModelCustomizationUUID); + } + break; + } + } + } + } else if (bbName.contains(NETWORK)) { + for (L3Network network : serviceInstance.getNetworks()) { + if (lookupKeyMap.get(ResourceKey.NETWORK_ID) != null + && network.getNetworkId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.NETWORK_ID))) { + String networkCustomizationUUID = this.bbInputSetupUtils.getAAIL3Network(network.getNetworkId()) + .getModelCustomizationId(); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationUuid(networkCustomizationUUID); + this.mapCatalogNetwork(network, modelInfo, service); + break; + } + } + } else if (bbName.contains("Fabric")) { + for(Configuration configuration : serviceInstance.getConfigurations()) { + if(lookupKeyMap.get(ResourceKey.CONFIGURATION_ID) != null + && configuration.getConfigurationId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.CONFIGURATION_ID))) { + String configurationCustUUID = this.bbInputSetupUtils.getAAIConfiguration(configuration.getConfigurationId()) + .getModelCustomizationId(); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationUuid(configurationCustUUID); + this.mapCatalogConfiguration(configuration, modelInfo, service); + break; + } + } + } + if (executeBB.getWorkflowResourceIds() != null) { + this.populateNetworkCollectionAndInstanceGroupAssign(service, bbName, serviceInstance, + executeBB.getWorkflowResourceIds().getNetworkCollectionId(), executeBB.getBuildingBlock().getKey()); + } + return gBB; + } + + protected GeneralBuildingBlock getGBBMacroUserParams(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, + Map<ResourceKey, String> lookupKeyMap, String vnfType, String bbName, String key, GeneralBuildingBlock gBB, + RequestParameters requestParams, Service service, String input) throws Exception { + ServiceInstance serviceInstance = gBB.getServiceInstance(); + org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(input, + org.onap.so.serviceinstancebeans.Service.class); + + Resources resources = serviceMacro.getResources(); + Vnfs vnfs = null; + VfModules vfModules = null; + Networks networks = null; + CloudConfiguration cloudConfiguration = requestDetails.getCloudConfiguration(); + CloudRegion cloudRegion = getCloudRegionFromMacroRequest(cloudConfiguration, resources); + gBB.setCloudRegion(cloudRegion); + if (bbName.contains(VNF)) { + vnfs = findVnfsByKey(key, resources, vnfs); + String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID); + // This stores the vnf id in request db to be retrieved later when + // working on a vf module or volume group + InfraActiveRequests request = this.bbInputSetupUtils.getInfraActiveRequest(executeBB.getRequestId()); + if (request != null) { + this.bbInputSetupUtils.updateInfraActiveRequestVnfId(request, vnfId); + } + this.populateGenericVnf(vnfs.getModelInfo(), vnfs.getInstanceName(), vnfs.getPlatform(), + vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, vnfId, vnfType, vnfs.getInstanceParams()); + } else if (bbName.contains(VF_MODULE) || bbName.contains(VOLUME_GROUP)) { + Pair<Vnfs, VfModules> vnfsAndVfModules = getVfModulesAndItsVnfsByKey(key, resources); + vfModules = vnfsAndVfModules.getValue1(); + vnfs = vnfsAndVfModules.getValue0(); + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, getVnfId(executeBB, lookupKeyMap)); + if (vnfs == null) { + throw new Exception("Could not find Vnf to orchestrate VfModule"); + } + ModelInfo modelInfo = vfModules.getModelInfo(); + if (bbName.contains(VOLUME_GROUP)) { + String volumeGroupId = lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID); + this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, volumeGroupId, null, + vfModules.getVolumeGroupInstanceName(), vnfType, vfModules.getInstanceParams()); + } else { + String vfModuleId = lookupKeyMap.get(ResourceKey.VF_MODULE_ID); + CloudConfiguration cloudConfig = new CloudConfiguration(); + cloudConfig.setLcpCloudRegionId(cloudRegion.getLcpCloudRegionId()); + this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, vfModuleId, null, + vfModules.getInstanceName(), vfModules.getInstanceParams(), cloudConfig); + } + } else if (bbName.contains(NETWORK)) { + networks = findNetworksByKey(key, resources); + String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID); + this.populateL3Network(networks.getInstanceName(), networks.getModelInfo(), service, bbName, + serviceInstance, lookupKeyMap, networkId, networks.getInstanceParams()); + } else if (bbName.contains("Configuration")) { + String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID); + ModelInfo configurationModelInfo = new ModelInfo(); + configurationModelInfo.setModelCustomizationUuid(key); + ConfigurationResourceCustomization configurationCust = findConfigurationResourceCustomization(configurationModelInfo, service); + if(configurationCust != null) { + this.populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, configurationId, null); + } else { + msoLogger.debug("Could not find a configuration customization with key: " + key); + } + } + return gBB; + } + + protected Networks findNetworksByKey(String key, Resources resources) { + for (Networks networks : resources.getNetworks()) { + if (networks.getModelInfo().getModelCustomizationId().equalsIgnoreCase(key)) { + return networks; + } + } + return null; + } + + protected Pair<Vnfs, VfModules> getVfModulesAndItsVnfsByKey(String key, Resources resources) { + for (Vnfs vnfs : resources.getVnfs()) { + for (VfModules vfModules : vnfs.getVfModules()) { + if (vfModules.getModelInfo().getModelCustomizationId().equalsIgnoreCase(key)) { + return new Pair<Vnfs, VfModules>(vnfs, vfModules); + } + } + } + return null; + } + + protected Vnfs findVnfsByKey(String key, Resources resources, Vnfs vnfs) { + for (Vnfs tempVnfs : resources.getVnfs()) { + if (tempVnfs.getModelInfo().getModelCustomizationId().equalsIgnoreCase(key)) { + vnfs = tempVnfs; + break; + } + } + return vnfs; + } + + protected CloudRegion getCloudRegionFromMacroRequest(CloudConfiguration cloudConfiguration, Resources resources) { + if(cloudConfiguration == null) { + for(Vnfs vnfs : resources.getVnfs()) { + if(cloudConfiguration == null) { + cloudConfiguration = vnfs.getCloudConfiguration(); + } else { + break; + } + for(VfModules vfModules : vnfs.getVfModules()) { + if(cloudConfiguration == null) { + cloudConfiguration = vfModules.getCloudConfiguration(); + } else { + break; + } + } + } + for(Networks networks : resources.getNetworks()) { + if(cloudConfiguration == null) { + cloudConfiguration = networks.getCloudConfiguration(); + } else { + break; + } + } + } + if(cloudConfiguration != null) { + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration, + CLOUD_OWNER); + return mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion, CLOUD_OWNER); + } else { + msoLogger.debug("Could not find any cloud configuration for this request."); + return null; + } + } + + protected String getVnfId(ExecuteBuildingBlock executeBB, Map<ResourceKey, String> lookupKeyMap) { + String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID); + if (vnfId == null) { + InfraActiveRequests request = this.bbInputSetupUtils.getInfraActiveRequest(executeBB.getRequestId()); + vnfId = request.getVnfId(); + } + + return vnfId; + } + + protected String generateRandomUUID() { + return UUID.randomUUID().toString(); + } + + protected ServiceInstance getServiceInstanceHelper(RequestDetails requestDetails, Customer customer, + Project project, OwningEntity owningEntity, Map<ResourceKey, String> lookupKeyMap, String serviceInstanceId, + boolean aLaCarte, Service service, String bbName) throws Exception { + if (requestDetails.getRequestInfo().getInstanceName() == null && aLaCarte + && bbName.equalsIgnoreCase(AssignFlows.SERVICE_INSTANCE.toString())) { + throw new Exception("Request invalid missing: RequestInfo:InstanceName"); + } else { + org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = null; + if (aLaCarte && bbName.equalsIgnoreCase(AssignFlows.SERVICE_INSTANCE.toString())) { + serviceInstanceAAI = bbInputSetupUtils + .getAAIServiceInstanceByName(requestDetails.getRequestInfo().getInstanceName(), customer); + } + if (serviceInstanceId != null && serviceInstanceAAI == null) { + serviceInstanceAAI = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); + } + if (serviceInstanceAAI != null) { + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId); + return this.getExistingServiceInstance(serviceInstanceAAI); + } else { + return createServiceInstance(requestDetails, project, owningEntity, lookupKeyMap, + serviceInstanceId); + } + } + } + + protected ServiceInstance createServiceInstance(RequestDetails requestDetails, Project project, + OwningEntity owningEntity, Map<ResourceKey, String> lookupKeyMap, String serviceInstanceId) { + ServiceInstance serviceInstance = new ServiceInstance(); + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId); + serviceInstance.setServiceInstanceId(serviceInstanceId); + if(requestDetails.getRequestInfo() != null) { + serviceInstance.setServiceInstanceName(requestDetails.getRequestInfo().getInstanceName()); + } + serviceInstance.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + serviceInstance.setProject(project); + serviceInstance.setOwningEntity(owningEntity); + return serviceInstance; + } + + public ServiceInstance getExistingServiceInstance(org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI) + throws Exception { + ServiceInstance serviceInstance = mapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI); + if (serviceInstanceAAI.getRelationshipList() != null + && serviceInstanceAAI.getRelationshipList().getRelationship() != null + && !serviceInstanceAAI.getRelationshipList().getRelationship().isEmpty()) { + addRelationshipsToSI(serviceInstanceAAI, serviceInstance); + } + return serviceInstance; + } + + protected void populateNetworkCollectionAndInstanceGroupAssign(Service service, String bbName, + ServiceInstance serviceInstance, String resourceId, String key) throws Exception { + if (serviceInstance.getCollection() == null + && bbName.equalsIgnoreCase(AssignFlows.NETWORK_COLLECTION.toString())) { + Collection collection = this.createCollection(resourceId); + serviceInstance.setCollection(collection); + this.mapCatalogCollection(service, serviceInstance.getCollection(), key); + if(isVlanTagging(service, key)) { + InstanceGroup instanceGroup = this.createInstanceGroup(); + serviceInstance.getCollection().setInstanceGroup(instanceGroup); + this.mapCatalogNetworkCollectionInstanceGroup(service, + serviceInstance.getCollection().getInstanceGroup(), key); + } + } + } + + protected CollectionResourceCustomization findCatalogNetworkCollection(Service service, String key) { + for(CollectionResourceCustomization collectionCust : service.getCollectionResourceCustomizations()){ + if(collectionCust.getModelCustomizationUUID().equalsIgnoreCase(key)) { + return collectionCust; + } + } + return null; + } + + protected boolean isVlanTagging(Service service, String key) { + CollectionResourceCustomization collectionCust = findCatalogNetworkCollection(service, key); + if (collectionCust != null) { + CollectionResource collectionResource = collectionCust.getCollectionResource(); + if (collectionResource != null + && collectionResource.getInstanceGroup() != null + && collectionResource.getInstanceGroup().getToscaNodeType() != null + && collectionResource.getInstanceGroup().getToscaNodeType().contains("NetworkCollection")) { + return true; + } + } + return false; + } + + protected void mapCatalogNetworkCollectionInstanceGroup(Service service, InstanceGroup instanceGroup, String key) { + CollectionResourceCustomization collectionCust = this.findCatalogNetworkCollection(service, key); + org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = collectionCust.getCollectionResource().getInstanceGroup(); + instanceGroup.setModelInfoInstanceGroup( + mapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionCust, catalogInstanceGroup)); + } + + protected void mapCatalogCollection(Service service, Collection collection, String key) { + CollectionResourceCustomization collectionCust = findCatalogNetworkCollection(service, key); + if (collectionCust != null) { + CollectionResource collectionResource = collectionCust.getCollectionResource(); + if (collectionResource != null) { + collection.setModelInfoCollection( + mapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource)); + } + } + } + + protected Collection createCollection(String collectionId) { + Collection collection = new Collection(); + collection.setId(collectionId); + collection.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + return collection; + } + + protected InstanceGroup createInstanceGroup() { + InstanceGroup instanceGroup = new InstanceGroup(); + String instanceGroupId = this.generateRandomUUID(); + instanceGroup.setId(instanceGroupId); + return instanceGroup; + } + + protected void addRelationshipsToSI(org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI, + ServiceInstance serviceInstance) throws Exception { + AAIResultWrapper serviceInstanceWrapper = new AAIResultWrapper( + new AAICommonObjectMapperProvider().getMapper().writeValueAsString(serviceInstanceAAI)); + Optional<Relationships> relationshipsOp = serviceInstanceWrapper.getRelationships(); + Relationships relationships = null; + if (relationshipsOp.isPresent()) { + relationships = relationshipsOp.get(); + } else { + return; + } + + this.mapProject(relationships.getByType(AAIObjectType.PROJECT), serviceInstance); + this.mapOwningEntity(relationships.getByType(AAIObjectType.OWNING_ENTITY), serviceInstance); + this.mapL3Networks(relationships.getRelatedAAIUris(AAIObjectType.L3_NETWORK), serviceInstance.getNetworks()); + this.mapGenericVnfs(relationships.getRelatedAAIUris(AAIObjectType.GENERIC_VNF), serviceInstance.getVnfs()); + this.mapCollection(relationships.getByType(AAIObjectType.COLLECTION), serviceInstance); + this.mapConfigurations(relationships.getRelatedAAIUris(AAIObjectType.CONFIGURATION), serviceInstance.getConfigurations()); + } + + protected void mapConfigurations(List<AAIResourceUri> relatedAAIUris, List<Configuration> configurations) { + for (AAIResourceUri aaiResourceUri : relatedAAIUris) { + configurations.add(mapConfiguration(aaiResourceUri)); + } + } + + protected Configuration mapConfiguration(AAIResourceUri aaiResourceUri) { + AAIResultWrapper aaiConfigurationWrapper = this.bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri); + Optional<org.onap.aai.domain.yang.Configuration> aaiConfigurationOp = aaiConfigurationWrapper + .asBean(org.onap.aai.domain.yang.Configuration.class); + if (!aaiConfigurationOp.isPresent()) { + return null; + } + + return this.mapperLayer.mapAAIConfiguration(aaiConfigurationOp.get()); + } + + protected void mapGenericVnfs(List<AAIResourceUri> list, List<GenericVnf> genericVnfs) { + for (AAIResourceUri aaiResourceUri : list) { + genericVnfs.add(this.mapGenericVnf(aaiResourceUri)); + } + } + + protected GenericVnf mapGenericVnf(AAIResourceUri aaiResourceUri) { + AAIResultWrapper aaiGenericVnfWrapper = this.bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri); + Optional<org.onap.aai.domain.yang.GenericVnf> aaiGenericVnfOp = aaiGenericVnfWrapper + .asBean(org.onap.aai.domain.yang.GenericVnf.class); + if (!aaiGenericVnfOp.isPresent()) { + return null; + } + + GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnfOp.get()); + + Optional<Relationships> relationshipsOp = aaiGenericVnfWrapper.getRelationships(); + if (relationshipsOp.isPresent()) { + Relationships relationships = relationshipsOp.get(); + this.mapPlatform(relationships.getByType(AAIObjectType.PLATFORM), genericVnf); + this.mapLineOfBusiness(relationships.getByType(AAIObjectType.LINE_OF_BUSINESS), genericVnf); + genericVnf.getVolumeGroups().addAll(mapVolumeGroups(relationships.getByType(AAIObjectType.VOLUME_GROUP))); + genericVnf.getInstanceGroups().addAll(mapInstanceGroups(relationships.getByType(AAIObjectType.INSTANCE_GROUP))); + } + + return genericVnf; + } + + protected List<InstanceGroup> mapInstanceGroups(List<AAIResultWrapper> instanceGroups) { + List<InstanceGroup> instanceGroupsList = new ArrayList<>(); + for (AAIResultWrapper volumeGroupWrapper : instanceGroups) { + instanceGroupsList.add(this.mapInstanceGroup(volumeGroupWrapper)); + } + return instanceGroupsList; + } + + protected InstanceGroup mapInstanceGroup(AAIResultWrapper instanceGroupWrapper) { + Optional<org.onap.aai.domain.yang.InstanceGroup> aaiInstanceGroupOp = instanceGroupWrapper + .asBean(org.onap.aai.domain.yang.InstanceGroup.class); + org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = null; + + if (!aaiInstanceGroupOp.isPresent()) { + return null; + } + + aaiInstanceGroup = aaiInstanceGroupOp.get(); + InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup); + instanceGroup.setModelInfoInstanceGroup(this.mapperLayer.mapCatalogInstanceGroupToInstanceGroup(null, + this.bbInputSetupUtils.getCatalogInstanceGroup(aaiInstanceGroup.getModelVersionId()))); + return instanceGroup; + } + + protected List<VolumeGroup> mapVolumeGroups(List<AAIResultWrapper> volumeGroups) { + List<VolumeGroup> volumeGroupsList = new ArrayList<>(); + for (AAIResultWrapper volumeGroupWrapper : volumeGroups) { + volumeGroupsList.add(this.mapVolumeGroup(volumeGroupWrapper)); + } + return volumeGroupsList; + } + + protected VolumeGroup mapVolumeGroup(AAIResultWrapper volumeGroupWrapper) { + Optional<org.onap.aai.domain.yang.VolumeGroup> aaiVolumeGroupOp = volumeGroupWrapper + .asBean(org.onap.aai.domain.yang.VolumeGroup.class); + org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = null; + + if (!aaiVolumeGroupOp.isPresent()) { + return null; + } + + aaiVolumeGroup = aaiVolumeGroupOp.get(); + return this.mapperLayer.mapAAIVolumeGroup(aaiVolumeGroup); + } + + protected void mapLineOfBusiness(List<AAIResultWrapper> lineOfBusinesses, GenericVnf genericVnf) { + if (!lineOfBusinesses.isEmpty()) { + AAIResultWrapper lineOfBusinessWrapper = lineOfBusinesses.get(0); + Optional<org.onap.aai.domain.yang.LineOfBusiness> aaiLineOfBusinessOp = lineOfBusinessWrapper + .asBean(org.onap.aai.domain.yang.LineOfBusiness.class); + org.onap.aai.domain.yang.LineOfBusiness aaiLineOfBusiness = null; + if (!aaiLineOfBusinessOp.isPresent()) { + return; + } + aaiLineOfBusiness = aaiLineOfBusinessOp.get(); + + LineOfBusiness lineOfBusiness = this.mapperLayer.mapAAILineOfBusiness(aaiLineOfBusiness); + genericVnf.setLineOfBusiness(lineOfBusiness); + } + } + + protected void mapPlatform(List<AAIResultWrapper> platforms, GenericVnf genericVnf) { + if (!platforms.isEmpty()) { + AAIResultWrapper platformWrapper = platforms.get(0); + Optional<org.onap.aai.domain.yang.Platform> aaiPlatformOp = platformWrapper + .asBean(org.onap.aai.domain.yang.Platform.class); + org.onap.aai.domain.yang.Platform aaiPlatform = null; + if (!aaiPlatformOp.isPresent()) { + return; + } + aaiPlatform = aaiPlatformOp.get(); + + Platform platform = this.mapperLayer.mapAAIPlatform(aaiPlatform); + genericVnf.setPlatform(platform); + } + } + + protected void mapCollection(List<AAIResultWrapper> collections, ServiceInstance serviceInstance) { + if (!collections.isEmpty()) { + AAIResultWrapper collectionWrapper = collections.get(0); + Optional<org.onap.aai.domain.yang.Collection> aaiCollectionOp = collectionWrapper + .asBean(org.onap.aai.domain.yang.Collection.class); + org.onap.aai.domain.yang.Collection aaiCollection = null; + if (!aaiCollectionOp.isPresent()) { + return; + } + aaiCollection = aaiCollectionOp.get(); + + Collection collection = this.mapperLayer.mapAAICollectionIntoCollection(aaiCollection); + + Optional<Relationships> relationshipsOp = collectionWrapper.getRelationships(); + Relationships relationships = null; + if (relationshipsOp.isPresent()) { + relationships = relationshipsOp.get(); + } else { + serviceInstance.setCollection(collection); + return; + } + List<InstanceGroup> instanceGroupsList = mapInstanceGroups(relationships.getByType(AAIObjectType.INSTANCE_GROUP)); + if(!instanceGroupsList.isEmpty()) { + collection.setInstanceGroup(instanceGroupsList.get(0)); + } + serviceInstance.setCollection(collection); + } + } + + protected void mapL3Networks(List<AAIResourceUri> list, List<L3Network> l3Networks) { + for (AAIResourceUri aaiResourceUri : list) { + l3Networks.add(this.mapL3Network(aaiResourceUri)); + } + } + + protected L3Network mapL3Network(AAIResourceUri aaiResourceUri) { + AAIResultWrapper aaiNetworkWrapper = this.bbInputSetupUtils.getAAIResourceDepthTwo(aaiResourceUri); + Optional<org.onap.aai.domain.yang.L3Network> aaiL3NetworkOp = aaiNetworkWrapper + .asBean(org.onap.aai.domain.yang.L3Network.class); + org.onap.aai.domain.yang.L3Network aaiL3Network = null; + + if (!aaiL3NetworkOp.isPresent()) { + return null; + } + + aaiL3Network = aaiL3NetworkOp.get(); + L3Network network = this.mapperLayer.mapAAIL3Network(aaiL3Network); + + Optional<Relationships> relationshipsOp = aaiNetworkWrapper.getRelationships(); + if (relationshipsOp.isPresent()) { + Relationships relationships = relationshipsOp.get(); + this.mapNetworkPolicies(relationships.getByType(AAIObjectType.NETWORK_POLICY), + network.getNetworkPolicies()); + this.mapRouteTableReferences(relationships.getByType(AAIObjectType.ROUTE_TABLE_REFERENCE), + network.getContrailNetworkRouteTableReferences()); + } + + return network; + } + + protected void mapNetworkPolicies(List<AAIResultWrapper> aaiNetworkPolicies, List<NetworkPolicy> networkPolicies) { + for (AAIResultWrapper networkPolicyWrapper : aaiNetworkPolicies) { + networkPolicies.add(this.mapNetworkPolicy(networkPolicyWrapper)); + } + } + + protected NetworkPolicy mapNetworkPolicy(AAIResultWrapper networkPolicyWrapper) { + Optional<org.onap.aai.domain.yang.NetworkPolicy> aaiNetworkPolicyOp = networkPolicyWrapper + .asBean(org.onap.aai.domain.yang.NetworkPolicy.class); + org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = null; + + if (!aaiNetworkPolicyOp.isPresent()) { + return null; + } + + aaiNetworkPolicy = aaiNetworkPolicyOp.get(); + return this.mapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy); + } + + protected void mapRouteTableReferences(List<AAIResultWrapper> routeTableReferences, + List<RouteTableReference> contrailNetworkRouteTableReferences) { + for (AAIResultWrapper routeTableReferenceWrapper : routeTableReferences) { + contrailNetworkRouteTableReferences.add(this.mapRouteTableReference(routeTableReferenceWrapper)); + } + } + + protected RouteTableReference mapRouteTableReference(AAIResultWrapper routeTableReferenceWrapper) { + Optional<org.onap.aai.domain.yang.RouteTableReference> aaiRouteTableReferenceOp = routeTableReferenceWrapper + .asBean(org.onap.aai.domain.yang.RouteTableReference.class); + org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference = null; + + if (!aaiRouteTableReferenceOp.isPresent()) { + return null; + } + + aaiRouteTableReference = aaiRouteTableReferenceOp.get(); + return this.mapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference); + } + + protected void mapOwningEntity(List<AAIResultWrapper> owningEntities, ServiceInstance serviceInstance) { + if (!owningEntities.isEmpty()) { + AAIResultWrapper owningEntityWrapper = owningEntities.get(0); + Optional<org.onap.aai.domain.yang.OwningEntity> aaiOwningEntityOp = owningEntityWrapper + .asBean(org.onap.aai.domain.yang.OwningEntity.class); + org.onap.aai.domain.yang.OwningEntity aaiOwningEntity = null; + if (!aaiOwningEntityOp.isPresent()) { + return; + } + aaiOwningEntity = aaiOwningEntityOp.get(); + + OwningEntity owningEntity = this.mapperLayer.mapAAIOwningEntity(aaiOwningEntity); + serviceInstance.setOwningEntity(owningEntity); + } + } + + protected void mapProject(List<AAIResultWrapper> projects, ServiceInstance serviceInstance) { + if (!projects.isEmpty()) { + AAIResultWrapper projectWrapper = projects.get(0); + Optional<org.onap.aai.domain.yang.Project> aaiProjectOp = projectWrapper + .asBean(org.onap.aai.domain.yang.Project.class); + org.onap.aai.domain.yang.Project aaiProject = null; + if (!aaiProjectOp.isPresent()) { + return; + } + aaiProject = aaiProjectOp.get(); + + Project project = this.mapperLayer.mapAAIProject(aaiProject); + serviceInstance.setProject(project); + } + } + protected Customer mapCustomer(String globalCustomerId, String subscriptionServiceType) { + org.onap.aai.domain.yang.Customer aaiCustomer = this.bbInputSetupUtils.getAAICustomer(globalCustomerId); + org.onap.aai.domain.yang.ServiceSubscription aaiServiceSubscription = this.bbInputSetupUtils + .getAAIServiceSubscription(globalCustomerId, subscriptionServiceType); + Customer customer = this.mapperLayer.mapAAICustomer(aaiCustomer); + ServiceSubscription serviceSubscription = this.mapperLayer.mapAAIServiceSubscription(aaiServiceSubscription); + if(serviceSubscription != null){ + customer.setServiceSubscription(serviceSubscription); + } + return customer; + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java new file mode 100644 index 0000000000..04f9cdcb86 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -0,0 +1,464 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.modelmapper.ModelMapper; +import org.modelmapper.convention.MatchingStrategies; +import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CtagAssignment; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Entitlement; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Evc; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ForwarderEvc; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.LagInterface; +import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; +import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; +import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.License; +import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionResource; +import org.onap.so.db.catalog.beans.CollectionResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; +import org.onap.so.db.catalog.beans.InstanceGroup; +import org.onap.so.db.catalog.beans.InstanceGroupType; +import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.OrchestrationStatus; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.logger.MsoLogger; +import org.onap.so.serviceinstancebeans.CloudConfiguration; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.springframework.stereotype.Component; + +@Component("BBInputSetupMapperLayer") +public class BBInputSetupMapperLayer { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, + BBInputSetupMapperLayer.class); + + private ModelMapper modelMapper = new ModelMapper(); + + public Customer mapAAICustomer(org.onap.aai.domain.yang.Customer customerAAI) { + return modelMapper.map(customerAAI, Customer.class); + } + + public ServiceSubscription mapAAIServiceSubscription( + org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionAAI) { + return modelMapper.map(serviceSubscriptionAAI, ServiceSubscription.class); + } + + protected Project mapAAIProject(org.onap.aai.domain.yang.Project aaiProject) { + return modelMapper.map(aaiProject, Project.class); + } + + protected OwningEntity mapAAIOwningEntity(org.onap.aai.domain.yang.OwningEntity aaiOwningEntity) { + return modelMapper.map(aaiOwningEntity, OwningEntity.class); + } + + protected Platform mapAAIPlatform(org.onap.aai.domain.yang.Platform aaiPlatform) { + return modelMapper.map(aaiPlatform, Platform.class); + } + + protected LineOfBusiness mapAAILineOfBusiness(org.onap.aai.domain.yang.LineOfBusiness aaiLineOfBusiness) { + return modelMapper.map(aaiLineOfBusiness, LineOfBusiness.class); + } + + protected SegmentationAssignment mapAAISegmentationAssignment( + org.onap.aai.domain.yang.SegmentationAssignment aaiSegmentationAssignment) { + return modelMapper.map(aaiSegmentationAssignment, SegmentationAssignment.class); + } + + protected CtagAssignment mapAAICtagAssignment(org.onap.aai.domain.yang.CtagAssignment aaiCtagAssignment) { + return modelMapper.map(aaiCtagAssignment, CtagAssignment.class); + } + + protected Subnet mapAAISubnet(org.onap.aai.domain.yang.Subnet aaiSubnet) { + return modelMapper.map(aaiSubnet, Subnet.class); + } + + protected License mapAAILicense(org.onap.aai.domain.yang.License aaiLicense) { + return modelMapper.map(aaiLicense, License.class); + } + + protected Entitlement mapAAIEntitlement(org.onap.aai.domain.yang.Entitlement aaiEntitlement) { + return modelMapper.map(aaiEntitlement, Entitlement.class); + } + + protected LagInterface mapAAILagInterface(org.onap.aai.domain.yang.LagInterface aaiLagInterface) { + return modelMapper.map(aaiLagInterface, LagInterface.class); + } + + protected VfModule mapAAIVfModule(org.onap.aai.domain.yang.VfModule aaiVfModule) { + VfModule vfModule = modelMapper.map(aaiVfModule, VfModule.class); + vfModule.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiVfModule.getOrchestrationStatus())); + return vfModule; + } + + public NetworkPolicy mapAAINetworkPolicy(org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy) { + return modelMapper.map(aaiNetworkPolicy, NetworkPolicy.class); + } + + protected VolumeGroup mapAAIVolumeGroup(org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup) { + VolumeGroup volumeGroup = modelMapper.map(aaiVolumeGroup, VolumeGroup.class); + volumeGroup.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiVolumeGroup.getOrchestrationStatus())); + return volumeGroup; + } + + protected void setPlatformAndLOBIntoServiceInstance(Platform platformMSO, LineOfBusiness lineOfBusinessMSO, + ServiceInstance serviceInstance, Map<ResourceKey, String> resourcesToBeOrchestrated) { + String vnfId = resourcesToBeOrchestrated.get(ResourceKey.GENERIC_VNF_ID); + if (vnfId != null && !serviceInstance.getVnfs().isEmpty()) { + for (GenericVnf vnf : serviceInstance.getVnfs()) { + if (vnf.getVnfId().equalsIgnoreCase(vnfId)) { + vnf.setPlatform(platformMSO); + vnf.setLineOfBusiness(lineOfBusinessMSO); + break; + } + } + } + } + + public ModelInfoServiceInstance mapCatalogServiceIntoServiceInstance(Service service) { + return modelMapper.map(service, ModelInfoServiceInstance.class); + } + + protected ModelInfoInstanceGroup mapCatalogInstanceGroupToInstanceGroup(CollectionResourceCustomization collectionCust, InstanceGroup instanceGroup) { + ModelInfoInstanceGroup modelInfoInstanceGroup = modelMapper.map(instanceGroup, ModelInfoInstanceGroup.class); + if(instanceGroup.getType().equals(InstanceGroupType.L3_NETWORK)) + modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_L3_NETWORK); + else + modelInfoInstanceGroup.setType(ModelInfoInstanceGroup.TYPE_VNFC); + if(collectionCust != null) { + List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList = instanceGroup.getCollectionInstanceGroupCustomizations(); + for(CollectionResourceInstanceGroupCustomization collectionInsatnceGroupCust : instanceGroupCustList) { + if(collectionInsatnceGroupCust.getModelCustomizationUUID().equalsIgnoreCase(collectionCust.getModelCustomizationUUID())) { + modelInfoInstanceGroup.setFunction(collectionInsatnceGroupCust.getFunction()); + modelInfoInstanceGroup.setDescription(collectionInsatnceGroupCust.getDescription()); + break; + } + } + } + return modelInfoInstanceGroup; + } + + protected ModelInfoCollection mapCatalogCollectionToCollection(CollectionResourceCustomization collectionCust, + CollectionResource collectionResource) { + ModelInfoCollection modelInfoCollection = new ModelInfoCollection(); + modelInfoCollection.setCollectionFunction(collectionCust.getFunction()); + modelInfoCollection.setCollectionRole(collectionCust.getRole()); + modelInfoCollection.setCollectionType(collectionCust.getType()); + modelInfoCollection.setDescription(collectionResource.getDescription()); + modelInfoCollection.setModelInvariantUUID(collectionResource.getModelInvariantUUID()); + modelInfoCollection.setModelVersionId(collectionResource.getModelUUID()); + return modelInfoCollection; + } + + public ServiceInstance mapAAIServiceInstanceIntoServiceInstance( + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance) { + ServiceInstance serviceInstance = modelMapper.map(aaiServiceInstance, ServiceInstance.class); + if (aaiServiceInstance.getAllottedResources() != null) { + for (org.onap.aai.domain.yang.AllottedResource allottedResource : aaiServiceInstance.getAllottedResources() + .getAllottedResource()) { + serviceInstance.getAllottedResources().add(mapAAIAllottedResource(allottedResource)); + } + } + serviceInstance.setOrchestrationStatus( + this.mapOrchestrationStatusFromAAI(aaiServiceInstance.getOrchestrationStatus())); + return serviceInstance; + } + + protected AllottedResource mapAAIAllottedResource(org.onap.aai.domain.yang.AllottedResource aaiAllottedResource) { + AllottedResource allottedResource = modelMapper.map(aaiAllottedResource, AllottedResource.class); + return allottedResource; + } + + protected L3Network mapAAIL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network) { + L3Network network = modelMapper.map(aaiL3Network, L3Network.class); + mapAllSubnetsIntoL3Network(aaiL3Network, network); + mapAllCtagAssignmentsIntoL3Network(aaiL3Network, network); + mapAllSegmentationAssignmentsIntoL3Network(aaiL3Network, network); + network.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiL3Network.getOrchestrationStatus())); + return network; + } + + protected void mapAllSegmentationAssignmentsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network, + L3Network network) { + if (aaiL3Network.getSegmentationAssignments() != null) { + for (org.onap.aai.domain.yang.SegmentationAssignment aaiSegmentationAssignment : aaiL3Network + .getSegmentationAssignments().getSegmentationAssignment()) { + network.getSegmentationAssignments().add(mapAAISegmentationAssignment(aaiSegmentationAssignment)); + } + } + } + + protected void mapAllCtagAssignmentsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network, + L3Network network) { + if (aaiL3Network.getCtagAssignments() != null) { + for (org.onap.aai.domain.yang.CtagAssignment aaiCtagAssignment : aaiL3Network.getCtagAssignments() + .getCtagAssignment()) { + network.getCtagAssignments().add(mapAAICtagAssignment(aaiCtagAssignment)); + } + } + } + + protected void mapAllSubnetsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network, L3Network network) { + if (aaiL3Network.getSubnets() != null) { + for (org.onap.aai.domain.yang.Subnet aaiSubnet : aaiL3Network.getSubnets().getSubnet()) { + network.getSubnets().add(mapAAISubnet(aaiSubnet)); + } + } + } + + protected GenericVnf mapAAIGenericVnfIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf) { + GenericVnf genericVnf = modelMapper.map(aaiGenericVnf, GenericVnf.class); + mapAllVfModulesIntoGenericVnf(aaiGenericVnf, genericVnf); + mapAllLagInterfacesIntoGenericVnf(aaiGenericVnf, genericVnf); + mapAllEntitlementsIntoGenericVnf(aaiGenericVnf, genericVnf); + mapAllLicensesIntoGenericVnf(aaiGenericVnf, genericVnf); + genericVnf.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiGenericVnf.getOrchestrationStatus())); + return genericVnf; + } + + protected void mapAllLicensesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf, + GenericVnf genericVnf) { + if (aaiGenericVnf.getLicenses() != null) { + for (org.onap.aai.domain.yang.License aaiLicense : aaiGenericVnf.getLicenses().getLicense()) { + genericVnf.setLicense(mapAAILicense(aaiLicense)); + } + } + } + + protected void mapAllEntitlementsIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf, + GenericVnf genericVnf) { + if (aaiGenericVnf.getEntitlements() != null) { + for (org.onap.aai.domain.yang.Entitlement aaiEntitlement : aaiGenericVnf.getEntitlements() + .getEntitlement()) { + genericVnf.getEntitlements().add(mapAAIEntitlement(aaiEntitlement)); + } + } + } + + protected void mapAllLagInterfacesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf, + GenericVnf genericVnf) { + if (aaiGenericVnf.getLagInterfaces() != null) { + for (org.onap.aai.domain.yang.LagInterface aaiLagInterface : aaiGenericVnf.getLagInterfaces() + .getLagInterface()) { + genericVnf.getLagInterfaces().add(mapAAILagInterface(aaiLagInterface)); + } + } + } + + protected void mapAllVfModulesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf, + GenericVnf genericVnf) { + if (aaiGenericVnf.getVfModules() != null) { + for (org.onap.aai.domain.yang.VfModule aaiVfModule : aaiGenericVnf.getVfModules().getVfModule()) { + VfModule vfModule = mapAAIVfModule(aaiVfModule); + genericVnf.getVfModules().add(vfModule); + } + } + } + + public OrchestrationStatus mapOrchestrationStatusFromAAI(String orchestrationStatus) { + + Optional<OrchestrationStatus> result = Arrays.asList(OrchestrationStatus.values()).stream() + .filter(item -> item.fuzzyMap(orchestrationStatus)) + .findFirst(); + + return result.orElse(null); + + } + + public RequestContext mapRequestContext(RequestDetails requestDetails) { + RequestContext context = new RequestContext(); + modelMapper.map(requestDetails.getRequestInfo(), context); + org.onap.so.serviceinstancebeans.RequestParameters requestParameters = requestDetails.getRequestParameters(); + if (null != requestParameters) { + context.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType()); + context.setRequestParameters(this.mapRequestParameters(requestDetails.getRequestParameters())); + } + return context; + } + + protected RequestParameters mapRequestParameters(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) { + RequestParameters requestParams = new RequestParameters(); + requestParams.setaLaCarte(requestParameters.getALaCarte()); + requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType()); + requestParams.setUserParams(requestParameters.getUserParams()); + return requestParams; + } + + protected OrchestrationContext mapOrchestrationContext(RequestDetails requestDetails) { + OrchestrationContext context = new OrchestrationContext(); + context.setIsRollbackEnabled((requestDetails.getRequestInfo().getSuppressRollback())); + return context; + } + + protected CloudRegion mapCloudRegion(CloudConfiguration cloudConfiguration, org.onap.aai.domain.yang.CloudRegion aaiCloudRegion, String cloudOwner) { + CloudRegion cloudRegion = new CloudRegion(); + if(cloudConfiguration != null) + cloudRegion = modelMapper.map(cloudConfiguration, CloudRegion.class); + if(aaiCloudRegion != null) + modelMapper.map(aaiCloudRegion, cloudRegion); + if(cloudOwner != null) + cloudRegion.setCloudOwner(cloudOwner); + return cloudRegion; + } + + protected Collection mapAAICollectionIntoCollection(org.onap.aai.domain.yang.Collection aaiCollection) { + Collection collection = new Collection(); + collection.setId(aaiCollection.getCollectionId()); + collection.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiCollection.getOrchestrationStatus())); + return collection; + } + + protected org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup mapAAIInstanceGroupIntoInstanceGroup( + org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup) { + return modelMapper.map(aaiInstanceGroup, + org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class); + } + + public RouteTableReference mapAAIRouteTableReferenceIntoRouteTableReference( + org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference) { + return modelMapper.map(aaiRouteTableReference, RouteTableReference.class); + } + + protected ModelInfoNetwork mapCatalogNetworkToNetwork(NetworkResourceCustomization networkResourceCustomization) { + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + ModelInfoNetwork modelInfoNetwork = modelMapper.map(networkResourceCustomization, ModelInfoNetwork.class); + modelMapper.map(networkResourceCustomization.getNetworkResource(), modelInfoNetwork); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STANDARD); + return modelInfoNetwork; + } + + protected ModelInfoGenericVnf mapCatalogVnfToVnf(VnfResourceCustomization vnfResourceCustomization) { + ModelInfoGenericVnf modelInfoVnf = modelMapper.map(vnfResourceCustomization, ModelInfoGenericVnf.class); + modelMapper.map(vnfResourceCustomization.getVnfResources(), modelInfoVnf); + return modelInfoVnf; + } + + protected ModelInfoVfModule mapCatalogVfModuleToVfModule(VfModuleCustomization vfResourceCustomization) { + ModelInfoVfModule modelInfoVfModule = modelMapper.map(vfResourceCustomization, ModelInfoVfModule.class); + modelMapper.map(vfResourceCustomization.getVfModule(), modelInfoVfModule); + return modelInfoVfModule; + } + + protected Platform mapRequestPlatform(org.onap.so.serviceinstancebeans.Platform platform) { + return modelMapper.map(platform, Platform.class); + } + + protected LineOfBusiness mapRequestLineOfBusiness( + org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness) { + return modelMapper.map(lineOfBusiness, LineOfBusiness.class); + } + + public Configuration mapAAIConfiguration(org.onap.aai.domain.yang.Configuration configurationAAI) { + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + Configuration configuration = modelMapper.map(configurationAAI, Configuration.class); + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STANDARD); + configuration.getForwarderEvcs().addAll(mapAllForwarderEvcs(configurationAAI)); + configuration.getEvcs().addAll(mapAllEvcs(configurationAAI)); + configuration.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(configurationAAI.getOrchestrationStatus())); + return configuration; + } + + protected List<Evc> mapAllEvcs(org.onap.aai.domain.yang.Configuration configurationAAI) { + List<Evc> listOfEvcs = new ArrayList<>(); + if (configurationAAI.getEvcs() != null) { + for (org.onap.aai.domain.yang.Evc aaiEvc : configurationAAI.getEvcs().getEvc()) { + listOfEvcs.add(mapEvc(aaiEvc)); + } + } + return listOfEvcs; + } + + protected Evc mapEvc(org.onap.aai.domain.yang.Evc aaiEvc) { + return modelMapper.map(aaiEvc, Evc.class); + } + + protected List<ForwarderEvc> mapAllForwarderEvcs(org.onap.aai.domain.yang.Configuration configurationAAI) { + List<ForwarderEvc> listOfForwarderEvcs = new ArrayList<>(); + if (configurationAAI.getForwarderEvcs() != null) { + for (org.onap.aai.domain.yang.ForwarderEvc aaiForwarderEvc : configurationAAI.getForwarderEvcs().getForwarderEvc()) { + listOfForwarderEvcs.add(mapForwarderEvc(aaiForwarderEvc)); + } + } + return listOfForwarderEvcs; + } + + protected ForwarderEvc mapForwarderEvc(org.onap.aai.domain.yang.ForwarderEvc aaiForwarderEvc) { + return modelMapper.map(aaiForwarderEvc, ForwarderEvc.class); + } + + protected OwningEntity mapRequestOwningEntity(org.onap.so.serviceinstancebeans.OwningEntity owningEntity) { + return modelMapper.map(owningEntity, OwningEntity.class); + } + + protected Project mapRequestProject(org.onap.so.serviceinstancebeans.Project project) { + return modelMapper.map(project, Project.class); + } + + protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration( + ConfigurationResourceCustomization configurationResourceCustomization) { + ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); + modelInfoConfiguration.setModelVersionId(configurationResourceCustomization.getConfigurationResource().getModelUUID()); + modelInfoConfiguration.setModelCustomizationId(configurationResourceCustomization.getModelCustomizationUUID()); + modelInfoConfiguration.setModelInvariantId(configurationResourceCustomization.getConfigurationResource().getModelInvariantUUID()); + return modelInfoConfiguration; + } + + public NetworkResourceCustomization mapCollectionNetworkResourceCustToNetworkResourceCust( + CollectionNetworkResourceCustomization collectionNetworkResourceCust) { + return modelMapper.map(collectionNetworkResourceCust, NetworkResourceCustomization.class); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java new file mode 100644 index 0000000000..14c162935a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -0,0 +1,409 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import org.onap.aai.domain.yang.CloudRegion; +import org.onap.aai.domain.yang.Configuration; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.GenericVnfs; +import org.onap.aai.domain.yang.InstanceGroup; +import org.onap.aai.domain.yang.L3Network; +import org.onap.aai.domain.yang.L3Networks; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceInstances; +import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aai.domain.yang.VfModule; +import org.onap.aai.domain.yang.VolumeGroup; +import org.onap.aai.domain.yang.VolumeGroups; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.client.aai.AAIObjectPlurals; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.aai.entities.uri.AAIUriFactory; +import org.onap.so.client.db.request.RequestsDbClient; +import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.logger.MsoLogger; +import org.onap.so.serviceinstancebeans.CloudConfiguration; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +@Component("BBInputSetupUtils") +public class BBInputSetupUtils { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, BBInputSetupUtils.class); + private ObjectMapper objectMapper = new ObjectMapper(); + private static final String REQUEST_ERROR = "Could not find request."; + + @Autowired + protected CatalogDbClient catalogDbClient; + + @Autowired + protected RequestsDbClient requestsDbClient; + + @Autowired + protected InjectionHelper injectionHelper; + + public void updateInfraActiveRequestVnfId(InfraActiveRequests request, String vnfId) { + if(request != null) { + request.setVnfId(vnfId); + this.requestsDbClient.updateInfraActiveRequests(request); + } else { + msoLogger.debug(REQUEST_ERROR); + } + } + + public void updateInfraActiveRequestVfModuleId(InfraActiveRequests request, String vfModuleId) { + if(request != null) { + request.setVfModuleId(vfModuleId); + this.requestsDbClient.updateInfraActiveRequests(request); + } else { + msoLogger.debug(REQUEST_ERROR); + } + } + + public void updateInfraActiveRequestVolumeGroupId(InfraActiveRequests request, String volumeGroupId) { + if(request != null) { + request.setVolumeGroupId(volumeGroupId); + this.requestsDbClient.updateInfraActiveRequests(request); + } else { + msoLogger.debug(REQUEST_ERROR); + } + } + + public void updateInfraActiveRequestNetworkId(InfraActiveRequests request, String networkId) { + if(request != null) { + request.setNetworkId(networkId); + this.requestsDbClient.updateInfraActiveRequests(request); + } else { + msoLogger.debug(REQUEST_ERROR); + } + } + + public Service getCatalogServiceByModelUUID(String modelUUID) { + return catalogDbClient.getServiceByID(modelUUID); + } + + public Service getCatalogServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) { + return catalogDbClient.getServiceByModelVersionAndModelInvariantUUID(modelVersion, modelInvariantUUID); + } + + public CollectionNetworkResourceCustomization getCatalogCollectionNetworkResourceCustByID(String key) { + return catalogDbClient.getCollectionNetworkResourceCustomizationByID(key); + } + + public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroups(String modelCustomizationUUID) { + return catalogDbClient.getVnfcInstanceGroupsByVnfResourceCust(modelCustomizationUUID); + } + + public Map<String, String> getURIKeysFromServiceInstance(String serviceInstanceId) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + return uri.getURIKeys(); + } + + protected RequestDetails getRequestDetails(String requestId) throws IOException { + if (requestId != null && !requestId.isEmpty()) { + InfraActiveRequests activeRequest = this.getInfraActiveRequest(requestId); + String requestBody = activeRequest.getRequestBody().replaceAll("\\\\", ""); + objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); + return objectMapper.readValue(requestBody, RequestDetails.class); + } else { + return null; + } + } + + protected InfraActiveRequests getInfraActiveRequest(String requestId) { + if (requestId != null && !requestId.isEmpty()) { + return requestsDbClient.getInfraActiveRequestbyRequestId(requestId); + } else { + return null; + } + } + + protected CloudRegion getCloudRegion(CloudConfiguration cloudConfiguration, String cloudOwner) { + if (cloudConfiguration != null) { + String cloudRegionId = cloudConfiguration.getLcpCloudRegionId(); + if (cloudRegionId != null && !cloudRegionId.isEmpty()) { + return injectionHelper.getAaiClient().get(CloudRegion.class, + AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, + cloudConfiguration.getLcpCloudRegionId())).orElse(null); + + } else { + return null; + } + } else { + return null; + } + } + + protected InstanceGroup getAAIInstanceGroup(String instanceGroupId) { + return injectionHelper.getAaiClient().get(InstanceGroup.class, + AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId)) + .orElse(null); + } + + public org.onap.aai.domain.yang.Customer getAAICustomer(String globalSubscriberId) { + return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Customer.class, + AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId)) + .orElse(null); + } + + public ServiceSubscription getAAIServiceSubscription(String globalSubscriberId, String subscriptionServiceType) { + + if(globalSubscriberId == null || globalSubscriberId.equals("") || subscriptionServiceType == null || subscriptionServiceType.equals("")) { + return null; + } else { + return injectionHelper.getAaiClient().get(ServiceSubscription.class, AAIUriFactory.createResourceUri( + AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId, subscriptionServiceType)) + .orElse(null); + } + + } + + public ServiceInstance getAAIServiceInstanceById(String serviceInstanceId) { + return injectionHelper.getAaiClient().get(ServiceInstance.class, + AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId).depth(Depth.TWO)) + .orElse(null); + } + + protected ServiceInstance getAAIServiceInstanceByIdAndCustomer(String globalCustomerId, String serviceType, + String serviceInstanceId) { + return injectionHelper.getAaiClient().get(ServiceInstance.class, AAIUriFactory.createResourceUri( + AAIObjectType.SERVICE_INSTANCE, globalCustomerId, serviceType, serviceInstanceId).depth(Depth.TWO)) + .orElse(null); + } + + protected org.onap.aai.domain.yang.ServiceInstances getAAIServiceInstancesByName(String serviceInstanceName, + Customer customer) { + + return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.ServiceInstances.class, + AAIUriFactory + .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(), + customer.getServiceSubscription().getServiceType()) + .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO)) + .orElseGet(() -> { + msoLogger.debug("No Service Instance matched by name"); + return null; + }); + } + + public org.onap.aai.domain.yang.ServiceInstance getAAIServiceInstanceByName(String serviceInstanceName, + Customer customer) throws Exception { + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null; + org.onap.aai.domain.yang.ServiceInstances aaiServiceInstances = null; + aaiServiceInstances = getAAIServiceInstancesByName(serviceInstanceName, customer); + + if (aaiServiceInstances == null) { + return null; + } else if (aaiServiceInstances.getServiceInstance().size() > 1) { + throw new Exception("Multiple Service Instances Returned"); + } else { + aaiServiceInstance = aaiServiceInstances.getServiceInstance().get(0); + } + return aaiServiceInstance; + } + + protected ServiceInstances getAAIServiceInstancesByName(String globalCustomerId, String serviceType, + String serviceInstanceName) { + + return injectionHelper.getAaiClient().get(ServiceInstances.class, + AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, globalCustomerId, serviceType) + .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO)) + .orElseGet(() -> { + msoLogger.debug("No Service Instance matched by name"); + return null; + }); + } + + public Optional<ServiceInstance> getAAIServiceInstanceByName(String globalCustomerId, String serviceType, + String serviceInstanceName) throws Exception { + ServiceInstance aaiServiceInstance = null; + ServiceInstances aaiServiceInstances = null; + aaiServiceInstances = getAAIServiceInstancesByName(globalCustomerId, serviceType, serviceInstanceName); + + if (aaiServiceInstances == null) { + return Optional.empty(); + } else if (aaiServiceInstances.getServiceInstance().size() > 1) { + throw new Exception("Multiple Service Instances Returned"); + } else { + aaiServiceInstance = aaiServiceInstances.getServiceInstance().get(0); + } + return Optional.of(aaiServiceInstance); + } + + public org.onap.so.db.catalog.beans.InstanceGroup getCatalogInstanceGroup(String modelUUID) { + return this.catalogDbClient.getInstanceGroupByModelUUID(modelUUID); + } + + public List<CollectionResourceInstanceGroupCustomization> getCollectionResourceInstanceGroupCustomization( + String modelCustomizationUUID) { + return this.catalogDbClient + .getCollectionResourceInstanceGroupCustomizationByModelCustUUID(modelCustomizationUUID); + } + + public AAIResultWrapper getAAIResourceDepthOne(AAIResourceUri aaiResourceUri) { + AAIResourceUri clonedUri = aaiResourceUri.clone(); + return this.injectionHelper.getAaiClient().get(clonedUri.depth(Depth.ONE)); + } + + public AAIResultWrapper getAAIResourceDepthTwo(AAIResourceUri aaiResourceUri) { + AAIResourceUri clonedUri = aaiResourceUri.clone(); + return this.injectionHelper.getAaiClient().get(clonedUri.depth(Depth.TWO)); + } + + public Configuration getAAIConfiguration(String configurationId) { + return this.injectionHelper.getAaiClient().get(Configuration.class, + AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId).depth(Depth.ONE)) + .orElseGet(() -> { + msoLogger.debug("No Configuration matched by id"); + return null; + }); + } + + public GenericVnf getAAIGenericVnf(String vnfId) { + + return this.injectionHelper.getAaiClient().get(GenericVnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)) + .orElseGet(() -> { + msoLogger.debug("No Generic Vnf matched by id"); + return null; + }); + } + + public VolumeGroup getAAIVolumeGroup(String cloudOwnerId, String cloudRegionId, String volumeGroupId) { + return this.injectionHelper.getAaiClient().get(VolumeGroup.class, + AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwnerId, cloudRegionId, volumeGroupId).depth(Depth.ONE)) + .orElseGet(() -> { + msoLogger.debug("No Generic Vnf matched by id"); + return null; + }); + } + + public VfModule getAAIVfModule(String vnfId, String vfModuleId) { + return this.injectionHelper.getAaiClient().get(VfModule.class, + AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE)) + .orElseGet(() -> { + msoLogger.debug("No Generic Vnf matched by id"); + return null; + }); + } + + public L3Network getAAIL3Network(String networkId) { + + return this.injectionHelper.getAaiClient().get(L3Network.class, + AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE)) + .orElseGet(() -> { + msoLogger.debug("No Generic Vnf matched by id"); + return null; + }); + + } + + public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName) throws Exception{ + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + uri.relatedTo(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); + Optional<L3Networks> networks = injectionHelper.getAaiClient().get(L3Networks.class, uri); + L3Network network = null; + if (!networks.isPresent()) { + msoLogger.debug("No Networks matched by name"); + return Optional.empty(); + } else { + if (networks.get().getL3Network().size() > 1) { + throw new Exception("Multiple Networks Returned"); + } else { + network = networks.get().getL3Network().get(0); + } + return Optional.of(network); + } + } + + public Optional<GenericVnf> getRelatedVnfByNameFromServiceInstance(String serviceInstanceId, String vnfName) throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); + uri.relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName); + Optional<GenericVnfs> vnfs = injectionHelper.getAaiClient().get(GenericVnfs.class, uri); + GenericVnf vnf = null; + if (!vnfs.isPresent()) { + msoLogger.debug("No Vnfs matched by name"); + return Optional.empty(); + } else { + if (vnfs.get().getGenericVnf().size() > 1) { + throw new Exception("Multiple Vnfs Returned"); + } else { + vnf = vnfs.get().getGenericVnf().get(0); + } + return Optional.of(vnf); + } + } + + public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVnf(String vnfId, String volumeGroupName) throws Exception{ + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName); + Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri); + VolumeGroup volumeGroup = null; + if (!volumeGroups.isPresent()) { + msoLogger.debug("No VolumeGroups matched by name"); + return Optional.empty(); + } else { + if (volumeGroups.get().getVolumeGroup().size() > 1) { + throw new Exception("Multiple VolumeGroups Returned"); + } else { + volumeGroup = volumeGroups.get().getVolumeGroup().get(0); + } + return Optional.of(volumeGroup); + } + } + + public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVfModule(String vfModuleId, String volumeGroupName) throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vfModuleId); + uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName); + Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri); + VolumeGroup volumeGroup = null; + if (!volumeGroups.isPresent()) { + msoLogger.debug("No VolumeGroups matched by name"); + return Optional.empty(); + } else { + if (volumeGroups.get().getVolumeGroup().size() > 1) { + throw new Exception("Multiple VolumeGroups Returned"); + } else { + volumeGroup = volumeGroups.get().getVolumeGroup().get(0); + } + return Optional.of(volumeGroup); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java new file mode 100644 index 0000000000..7a56ab88ab --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks; + +import java.util.Map; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.MsoLogger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class ExecuteBuildingBlockRainyDay { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExecuteBuildingBlockRainyDay.class); + + @Autowired + private CatalogDbClient catalogDbClient; + private static final String ASTERISK = "ASTERISK"; + + public void setRetryTimer(DelegateExecution execution) { + try { + int retryCount = (int) execution.getVariable("retryCount"); + int retryTimeToWait = (int) Math.pow(5, retryCount); + String RetryDuration = "PT" + retryTimeToWait + "M"; + execution.setVariable("RetryDuration", RetryDuration); + } catch (Exception e) { + msoLogger.error(e); + throw new BpmnError("Unknown error incrementing retry counter"); + } + } + + public void queryRainyDayTable(DelegateExecution execution) { + try { + ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); + String bbName = ebb.getBuildingBlock().getBpmnFlowName(); + GeneralBuildingBlock gBBInput = (GeneralBuildingBlock) execution.getVariable("gBBInput"); + Map<ResourceKey, String> lookupKeyMap = (Map<ResourceKey, String>) execution.getVariable("lookupKeyMap"); + String serviceType = ASTERISK; + try { + serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getModelInfoServiceInstance().getServiceType(); + } catch (Exception ex) { + // keep default serviceType value + } + String vnfType = ASTERISK; + try { + for(GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs()) { + if(vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + vnfType = vnf.getVnfType(); + } + } + } catch (Exception ex) { + // keep default vnfType value + } + WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); + String errorCode = ASTERISK; + try { + errorCode = "" + workflowException.getErrorCode(); + } catch (Exception ex) { + // keep default errorCode value + } + String workStep = ASTERISK; + try { + workStep = workflowException.getWorkStep(); + } catch (Exception ex) { + // keep default workStep value + } + //Extract error data to be returned to WorkflowAction + execution.setVariable("WorkflowExceptionErrorMessage", workflowException.getErrorMessage()); + RainyDayHandlerStatus rainyDayHandlerStatus; + String handlingCode = ""; + rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,serviceType,vnfType,errorCode,workStep); + if(rainyDayHandlerStatus==null){ + rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName,ASTERISK,ASTERISK,ASTERISK,ASTERISK); + if(rainyDayHandlerStatus==null){ + handlingCode = "Abort"; + }else{ + handlingCode = rainyDayHandlerStatus.getPolicy(); + } + }else{ + handlingCode = rainyDayHandlerStatus.getPolicy(); + } + msoLogger.debug("RainyDayHandler Status Code is: " + handlingCode); + execution.setVariable("handlingCode", handlingCode); + } catch (Exception e) { + msoLogger.debug("RainyDayHandler Status Code is: Abort"); + execution.setVariable("handlingCode", "Abort"); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java new file mode 100644 index 0000000000..a212668fec --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Optional; + +import javax.persistence.Id; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.logger.MsoLogger; +import org.springframework.stereotype.Component; + +import com.google.common.base.CaseFormat; + +@Component +public class ExtractPojosForBB { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExtractPojosForBB.class); + + public <T> T extractByKey(BuildingBlockExecution execution, ResourceKey key, String value) + throws BBObjectNotFoundException { + + Optional<T> result = Optional.empty(); + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + try { + ServiceInstance serviceInstance; + GenericVnf vnf; + switch (key) { + case SERVICE_INSTANCE_ID: + result = lookupObjectInList(gBBInput.getCustomer().getServiceSubscription().getServiceInstances(), value); + break; + case GENERIC_VNF_ID: + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + result = lookupObjectInList(serviceInstance.getVnfs(), value); + break; + case NETWORK_ID: + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + result = lookupObjectInList(serviceInstance.getNetworks(), value); + break; + case VOLUME_GROUP_ID: + vnf = extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + result = lookupObjectInList(vnf.getVolumeGroups(), value); + break; + case VF_MODULE_ID: + vnf = extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + result = lookupObjectInList(vnf.getVfModules(), value); + break; + case ALLOTTED_RESOURCE_ID: + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + result = lookupObjectInList(serviceInstance.getAllottedResources(), value); + break; + case CONFIGURATION_ID: + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + result = lookupObjectInList(serviceInstance.getConfigurations(), value); + break; + case VPN_ID: + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + result = lookupObjectInList(gBBInput.getCustomer().getVpnBindings(), value); + break; + case VPN_BONDING_LINK_ID: + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + result = lookupObjectInList(serviceInstance.getVpnBondingLinks(),value); + break; + default: + throw new BBObjectNotFoundException(key, value); + } + } catch (BBObjectNotFoundException e) { // re-throw parent object not found + throw e; + } catch (Exception e) { // convert all other exceptions to object not found + msoLogger.warnSimple("BBObjectNotFoundException in ExtractPojosForBB", "BBObject " + key + " was not found in gBBInput using reference value: " + value); + throw new BBObjectNotFoundException(key, value); + } + + if (result.isPresent()) { + return result.get(); + } else { + throw new BBObjectNotFoundException(key, value); + } + } + + protected <T> Optional<T> lookupObject(Object obj, String value) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + return findValue(obj, value); + } + + protected <T> Optional<T> lookupObjectInList(List<?> list, String value) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + Optional<T> result = Optional.empty(); + for (Object obj : list) { + result = findValue(obj, value); + if (result.isPresent()) { + break; + } + } + return result; + + } + + protected <T> Optional<T> findValue(Object obj, String value) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + for (Field field : obj.getClass().getDeclaredFields()) { + if (field.isAnnotationPresent(Id.class)) { + String fieldName = field.getName(); + fieldName = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, fieldName); + String fieldValue = (String) obj.getClass().getMethod("get" + fieldName).invoke(obj); + if (fieldValue.equals(value)) { + return Optional.of((T)obj); + } + } + } + + return Optional.empty(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java new file mode 100644 index 0000000000..9feee14640 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerAction.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.appc; + +import java.util.HashMap; +import java.util.List; +import java.util.Optional; + +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.bpmn.appc.payload.PayloadClient; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.client.appc.ApplicationControllerSupport.StatusCategory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + + +public class ApplicationControllerAction { + protected ApplicationControllerOrchestrator client = new ApplicationControllerOrchestrator(); + private String errorCode = "1002"; + private String errorMessage = "Unable to reach App C Servers"; + private static Logger logger = LoggerFactory.getLogger(ApplicationControllerAction.class); + + public void runAppCCommand(Action action, String msoRequestId, String vnfId, Optional<String> payload, HashMap<String, String> payloadInfo, String controllerType){ + Status appCStatus = null; + try{ + String vnfName = payloadInfo.getOrDefault("vnfName", ""); + String aicIdentity = payloadInfo.getOrDefault("vnfName",""); + String vnfHostIpAddress = payloadInfo.getOrDefault("vnfHostIpAddress",""); + String vmIdList = payloadInfo.getOrDefault("vmIdList", ""); + String vserverIdList = payloadInfo.getOrDefault("vserverIdList", ""); + String identityUrl = payloadInfo.getOrDefault("identityUrl", ""); + switch(action){ + case ResumeTraffic: + appCStatus = resumeTrafficAction(msoRequestId, vnfId, vnfName, controllerType); + break; + case Start: + case Stop: + appCStatus = startStopAction(action, msoRequestId, vnfId, aicIdentity, controllerType); + break; + case Unlock: + case Lock: + appCStatus = client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), Optional.empty(), controllerType); + break; + case QuiesceTraffic: + appCStatus = quiesceTrafficAction(msoRequestId, vnfId, payload, vnfName, controllerType); + break; + case HealthCheck: + appCStatus = healthCheckAction(msoRequestId, vnfId, vnfName, vnfHostIpAddress, controllerType); + break; + case Snapshot: + String vmIds = JsonUtils.getJsonValue(vmIdList, "vmIds"); + String vserverIds = JsonUtils.getJsonValue(vserverIdList, "vserverIds"); + String vmId = ""; + String vserverId = ""; + ObjectMapper mapper = new ObjectMapper(); + List<String> vmIdJsonList = mapper.readValue(vmIds, new TypeReference<List<String>>(){}); + List<String> vserverIdJsonList = mapper.readValue(vserverIds, new TypeReference<List<String>>(){}); + int i = 0; + while(i < vmIdJsonList.size()){ + vmId = vmIdJsonList.get(i); + vserverId = vserverIdJsonList.get(i); + Optional<String> vserverIdString = Optional.of(vserverId); + appCStatus = snapshotAction(msoRequestId, vnfId, vmId, vserverIdString, identityUrl, controllerType); + i++; + } + break; + case ConfigModify: + case ConfigScaleOut: + appCStatus = payloadAction(action, msoRequestId, vnfId, payload, controllerType); + break; + case UpgradePreCheck: + case UpgradePostCheck: + case UpgradeSoftware: + case UpgradeBackup: + appCStatus = upgradeAction(action,msoRequestId, vnfId, payload, vnfName, controllerType); + break; + default: + errorMessage = "Unable to idenify Action request for AppCClient"; + break; + } + if(appCStatus != null){ + errorCode = Integer.toString(appCStatus.getCode()); + errorMessage = appCStatus.getMessage(); + + } + if(ApplicationControllerSupport.getCategoryOf(appCStatus).equals(StatusCategory.NORMAL)){ + errorCode = "0"; + } + } + catch(JsonProcessingException e){ + logger.error("Incorrect Payload format for action request: {}", action.toString(),e); + errorMessage = e.getMessage(); + } + catch(ApplicationControllerOrchestratorException e){ + logger.error("Error building Appc request: {}",e.getMessage(), e); + errorCode = "1002"; + errorMessage = e.getMessage(); + } + catch (NoSuchMethodError e) { + logger.error( "Error building Appc request: {}", e.getMessage(), e); + errorMessage = e.getMessage(); + } + catch(Exception e){ + logger.error("Error building Appc request: {}", e.getMessage(), e); + errorMessage = e.getMessage(); + } + } + + private Status payloadAction(Action action, String msoRequestId, String vnfId, Optional<String> payload, String controllerType) throws JsonProcessingException, IllegalArgumentException,ApplicationControllerOrchestratorException{ + if(!(payload.isPresent())){ + throw new IllegalArgumentException("Payload is not present for " + action.toString()); + } + return client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), payload, controllerType); + } + + private Status quiesceTrafficAction(String msoRequestId, String vnfId, Optional<String> payload, String vnfName, String controllerType) throws JsonProcessingException, IllegalArgumentException,ApplicationControllerOrchestratorException{ + if(!(payload.isPresent())){ + throw new IllegalArgumentException("Payload is not present for " + Action.QuiesceTraffic.toString()); + } + payload = PayloadClient.quiesceTrafficFormat(payload, vnfName); + return client.vnfCommand(Action.QuiesceTraffic, msoRequestId, vnfId, Optional.empty(), payload, controllerType); + } + + private Status upgradeAction(Action action, String msoRequestId, String vnfId, Optional<String> payload, String vnfName, String controllerType) throws JsonProcessingException, IllegalArgumentException,ApplicationControllerOrchestratorException{ + if(!(payload.isPresent())){ + throw new IllegalArgumentException("Payload is not present for " + action.toString()); + } + payload = PayloadClient.upgradeFormat(payload, vnfName); + return client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), payload, controllerType); + } + + private Status resumeTrafficAction(String msoRequestId, String vnfId, String vnfName, String controllerType)throws JsonProcessingException, ApplicationControllerOrchestratorException{ + Optional<String> payload = PayloadClient.resumeTrafficFormat(vnfName); + return client.vnfCommand(Action.ResumeTraffic, msoRequestId, vnfId, Optional.empty(), payload, controllerType); + } + + private Status startStopAction(Action action, String msoRequestId, String vnfId, String aicIdentity, String controllerType)throws JsonProcessingException, ApplicationControllerOrchestratorException{ + Optional<String> payload = PayloadClient.startStopFormat(aicIdentity); + return client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), payload, controllerType); + } + + private Status healthCheckAction(String msoRequestId, String vnfId, String vnfName, String vnfHostIpAddress, String controllerType)throws JsonProcessingException, ApplicationControllerOrchestratorException{ + Optional<String> payload = PayloadClient.healthCheckFormat(vnfName, vnfHostIpAddress); + return client.vnfCommand(Action.HealthCheck, msoRequestId, vnfId, Optional.empty(), payload, controllerType); + } + + private Status snapshotAction(String msoRequestId, String vnfId, String vmId, Optional<String> vserverId, String identityUrl, String controllerType) throws JsonProcessingException, ApplicationControllerOrchestratorException{ + Optional<String> payload = PayloadClient.snapshotFormat(vmId, identityUrl); + return client.vnfCommand(Action.Snapshot, msoRequestId, vnfId, vserverId, payload, controllerType); + } + + public String getErrorMessage(){ + return errorMessage; + } + + public String getErrorCode(){ + return errorCode; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerCallback.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerCallback.java new file mode 100644 index 0000000000..cb3f144cd1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerCallback.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.appc; + +import org.onap.appc.client.lcm.api.ResponseHandler; +import org.onap.appc.client.lcm.exceptions.AppcClientException; + +public class ApplicationControllerCallback<T> implements ResponseHandler<T> { + + @Override + public void onResponse(T response) { + + + } + + @Override + public void onException(AppcClientException exception) { + + + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java new file mode 100644 index 0000000000..f87ec91440 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClient.java @@ -0,0 +1,206 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.appc; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.time.Instant; +import java.util.Properties; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider; +import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; +import org.onap.appc.client.lcm.api.ApplicationContext; +import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.ActionIdentifiers; +import org.onap.appc.client.lcm.model.CommonHeader; +import org.onap.appc.client.lcm.model.Flags; +import org.onap.appc.client.lcm.model.Flags.Force; +import org.onap.appc.client.lcm.model.Flags.Mode; +import org.onap.appc.client.lcm.model.Payload; +import org.onap.appc.client.lcm.model.Status; +import org.onap.appc.client.lcm.model.ZULU; + +public class ApplicationControllerClient { + + public static final String DEFAULT_CONTROLLER_TYPE = "APPC"; + + private static final String CLIENT_NAME = "MSO"; + + private static final String API_VER = "2.00"; + private static final String ORIGINATOR_ID = "MSO"; + private static final int FLAGS_TTL = 65000; + private static Logger logger = LoggerFactory.getLogger(ApplicationControllerClient.class); + + private ApplicationControllerSupport appCSupport; + + // APPC gave us an API where the controllerType is configured in the + // client object, which is not what we asked for. We asked for an API + // in which the client would have additional methods that could take + // the controllerType as a parameter, so that we would not need to + // maintain multiple client objects. This map should be removed when + // the (hopefully short-term) controllerType becomes obsolete. + + private final String controllerType; + + private static ConcurrentHashMap<String, LifeCycleManagerStateful> appCClients = new ConcurrentHashMap<>(); + + /** + * Creates an ApplicationControllerClient for communication with APP-C. + */ + public ApplicationControllerClient() { + this(DEFAULT_CONTROLLER_TYPE); + } + + /** + * Creates an ApplicationControllerClient for the specified controller type. + * @param controllerType the controller type: "appc" or "sdnc". + */ + public ApplicationControllerClient(String controllerType) { + if (controllerType == null) { + controllerType = DEFAULT_CONTROLLER_TYPE; + } + this.controllerType = controllerType.toUpperCase(); + appCSupport = new ApplicationControllerSupport(); + } + + /** + * Gets the controller type. + * @return the controllertype + */ + public String getControllerType() { + return controllerType; + } + + /** + * Returns the AppC client object associated with this ApplicationControllerClient. + * AppC client objects are shared objects. One is created if it does not exist. + * @return the client object, or null if creation failed + */ + public LifeCycleManagerStateful getAppCClient() { + return appCClients.computeIfAbsent(controllerType, k -> createAppCClient(k)); + } + + protected LifeCycleManagerStateful createAppCClient(String controllerType) { + try { + if (controllerType == null) { + controllerType = DEFAULT_CONTROLLER_TYPE; + } + controllerType = controllerType.toUpperCase(); + return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) + .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); + } catch (AppcClientException e) { + logger.error("Error in getting LifeCycleManagerStateful: {}",e.getMessage(), e); + // This null value will cause NullPointerException when used later. + // Error handling could certainly be improved here. + return null; + } + } + + public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, + org.onap.appc.client.lcm.model.Payload payload, String requestID) + throws ApplicationControllerOrchestratorException { + Object requestObject; + requestObject = createRequest(action, actionIdentifiers, payload, requestID); + appCSupport.logLCMMessage(requestObject); + LifeCycleManagerStateful client = getAppCClient(); + Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false); + try { + Object response = lcmMethod.invoke(client, requestObject); + return appCSupport.getStatusFromGenericResponse(response); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e); + } + } + + protected Properties getLCMProperties() { + return getLCMProperties("appc"); + } + + protected Properties getLCMProperties(String controllerType) { + Properties properties = new Properties(); + + properties.put("topic.read", UrnPropertiesReader.getVariable("appc.client.topic.read.name")); + properties.put("topic.write", UrnPropertiesReader.getVariable("appc.client.topic.write")); + properties.put("SDNC-topic.read", UrnPropertiesReader.getVariable("appc.client.topic.sdnc.read")); + properties.put("SDNC-topic.write", UrnPropertiesReader.getVariable("appc.client.topic.sdnc.write")); + properties.put("topic.read.timeout", UrnPropertiesReader.getVariable("appc.client.topic.read.timeout")); + properties.put("client.response.timeout", UrnPropertiesReader.getVariable("appc.client.response.timeout")); + properties.put("poolMembers", UrnPropertiesReader.getVariable("appc.client.poolMembers")); + properties.put("controllerType", controllerType); + properties.put("client.key", UrnPropertiesReader.getVariable("appc.client.key")); + properties.put("client.secret", UrnPropertiesReader.getVariable("appc.client.secret")); + properties.put("client.name", CLIENT_NAME); + properties.put("service", UrnPropertiesReader.getVariable("appc.client.service")); + return properties; + } + + public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { + Object requestObject = appCSupport.getInput(action.name()); + try { + CommonHeader commonHeader = buildCommonHeader(requestId); + requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, + commonHeader); + requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); + requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class) + .invoke(requestObject, identifier); + if (payload != null) { + requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload); + } + } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + logger.error("Error building Appc request", e); + } + return requestObject; + } + + private CommonHeader buildCommonHeader(String requestId) { + CommonHeader commonHeader = new CommonHeader(); + commonHeader.setApiVer(API_VER); + commonHeader.setOriginatorId(ORIGINATOR_ID); + commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); + commonHeader.setSubRequestId(requestId); + Flags flags = new Flags(); + String flagsMode = "NORMAL"; + Mode mode = Mode.valueOf(flagsMode); + flags.setMode(mode); + String flagsForce = "FALSE"; + Force force = Force.valueOf(flagsForce); + flags.setForce(force); + flags.setTtl(FLAGS_TTL); + commonHeader.setFlags(flags); + Instant timestamp = Instant.now(); + ZULU zulu = new ZULU(timestamp.toString()); + commonHeader.setTimestamp(zulu); + return commonHeader; + } + + public Flags createRequestFlags() { + Flags flags = new Flags(); + flags.setTtl(6000); + return flags; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java new file mode 100644 index 0000000000..d4599a5248 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerClientV2.java @@ -0,0 +1,154 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.appc; + +import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider; +import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; +import org.onap.appc.client.lcm.api.ApplicationContext; +import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.*; +import org.onap.appc.client.lcm.model.Flags.Force; +import org.onap.appc.client.lcm.model.Flags.Mode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.time.Instant; +import java.util.Properties; +import java.util.UUID; + +@Component +@Deprecated +public class ApplicationControllerClientV2 { + + private static final String CLIENT_NAME = "MSO"; + private static final String API_VER = "2.00"; + private static final String ORIGINATOR_ID = "MSO"; + private static final int FLAGS_TTL = 65000; + private static Logger logger = LoggerFactory.getLogger(ApplicationControllerClientV2.class); + + //@Autowired + ApplicationControllerConfiguration applicationControllerConfiguration; + + //@Autowired + private ApplicationControllerSupport appCSupport; + + private static LifeCycleManagerStateful client; + + //@PostConstruct + public void buildClient() { + client = this.getAppCClient(""); + } + + //@PostConstruct + public void buildClient(String controllerType) { + client = this.getAppCClient(controllerType); + } + + public Status runCommand(Action action, ActionIdentifiers actionIdentifiers, Payload payload, String requestID) + throws ApplicationControllerOrchestratorException { + Object requestObject; + requestObject = createRequest(action, actionIdentifiers, payload, requestID); + appCSupport.logLCMMessage(requestObject); + Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false); + try { + Object response = lcmMethod.invoke(client, requestObject); + return appCSupport.getStatusFromGenericResponse(response); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e); + } + } + + public LifeCycleManagerStateful getAppCClient(String controllerType) { + if (client == null) + try { + client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) + .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); + } catch (AppcClientException e) { + logger.error("Error in getting LifeCycleManagerStateful Client", e); + } + return client; + } + + protected Properties getLCMProperties(String controllerType) { + Properties properties = new Properties(); + properties.put("topic.read", applicationControllerConfiguration.getReadTopic()); + properties.put("topic.read.timeout", applicationControllerConfiguration.getReadTimeout()); + properties.put("client.response.timeout", applicationControllerConfiguration.getResponseTimeout()); + properties.put("topic.write", applicationControllerConfiguration.getWrite()); + properties.put("poolMembers", applicationControllerConfiguration.getPoolMembers()); + properties.put("client.key", applicationControllerConfiguration.getClientKey()); + properties.put("client.secret", applicationControllerConfiguration.getClientSecret()); + properties.put("client.name", CLIENT_NAME); + properties.put("service", applicationControllerConfiguration.getService()); + return properties; + } + + public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { + Object requestObject = appCSupport.getInput(action.name()); + try { + CommonHeader commonHeader = buildCommonHeader(requestId); + requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, + commonHeader); + requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); + requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class) + .invoke(requestObject, identifier); + if (payload != null) { + requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload); + } + } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + logger.error("Error building Appc request", e); + } + return requestObject; + } + + private CommonHeader buildCommonHeader(String requestId) { + CommonHeader commonHeader = new CommonHeader(); + commonHeader.setApiVer(API_VER); + commonHeader.setOriginatorId(ORIGINATOR_ID); + commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); + commonHeader.setSubRequestId(requestId); + Flags flags = new Flags(); + String flagsMode = "NORMAL"; + Mode mode = Mode.valueOf(flagsMode); + flags.setMode(mode); + String flagsForce = "FALSE"; + Force force = Force.valueOf(flagsForce); + flags.setForce(force); + flags.setTtl(FLAGS_TTL); + commonHeader.setFlags(flags); + Instant timestamp = Instant.now(); + ZULU zulu = new ZULU(timestamp.toString()); + commonHeader.setTimestamp(zulu); + return commonHeader; + } + + public Flags createRequestFlags() { + Flags flags = new Flags(); + flags.setTtl(6000); + return flags; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java new file mode 100644 index 0000000000..430767f24a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerConfiguration.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.appc; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Service; + +@Configuration +public class ApplicationControllerConfiguration { + @Value("${appc.client.topic.read.name}") + private String readTopic; + + @Value("${appc.client.topic.read.timeout}") + private String readTimeout; + + @Value("${appc.client.response.timeout}") + private String responseTimeout; + + @Value("${appc.client.topic.write}") + private String write; + + @Value("${appc.client.poolMembers}") + private String poolMembers; + + @Value("${appc.client.key}") + private String clientKey; + + @Value("${appc.client.secret}") + private String clientSecret; + + @Value("${appc.client.service}") + private String service; + + public String getClientKey() { + return clientKey; + } + + public String getClientSecret() { + return clientSecret; + } + + public String getPoolMembers() { + return poolMembers; + } + + public String getReadTimeout() { + return readTimeout; + } + + public String getResponseTimeout() { + return responseTimeout; + } + + public String getReadTopic() { + return readTopic; + } + + public String getService() { + return service; + } + + public String getWrite() { + return write; + } +} + diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerOrchestrator.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerOrchestrator.java new file mode 100644 index 0000000000..84e0f93294 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerOrchestrator.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.appc; + +import java.util.Optional; + +import org.onap.so.client.appc.ApplicationControllerSupport.StatusCategory; + +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.ActionIdentifiers; +import org.onap.appc.client.lcm.model.Payload; +import org.onap.appc.client.lcm.model.Status; + +public class ApplicationControllerOrchestrator { + + public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId, Optional<String> request, String controllerType) throws ApplicationControllerOrchestratorException { + ApplicationControllerClient client = new ApplicationControllerClient(controllerType); + Status status; + ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); + actionIdentifiers.setVnfId(vnfId); + if (vserverId.isPresent()) { + actionIdentifiers.setVserverId(vserverId.get()); + } + Payload payload = null; + if (request.isPresent()) { + payload = new Payload(request.get()); + } + status = client.runCommand(action, actionIdentifiers, payload, requestId); + if (ApplicationControllerSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) { + throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode()); + } else { + return status; + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerOrchestratorException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerOrchestratorException.java new file mode 100644 index 0000000000..2532e485ed --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerOrchestratorException.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.appc; + +public class ApplicationControllerOrchestratorException extends Exception { + + private final int appcCode; + + public ApplicationControllerOrchestratorException(String message, int code) { + super(message); + appcCode = code; + } + + public int getAppcCode() + { + return appcCode; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerSupport.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerSupport.java new file mode 100644 index 0000000000..ef8749ece9 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/appc/ApplicationControllerSupport.java @@ -0,0 +1,215 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.appc; + +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.springframework.stereotype.Component; + +import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; +import org.onap.appc.client.lcm.api.ResponseHandler; +import org.onap.appc.client.lcm.model.Status; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; +import org.springframework.stereotype.Service; + +public class ApplicationControllerSupport { + + private static final int ACCEPT_SERIES = 100; + private static final int ERROR_SERIES = 200; + private static final int REJECT_SERIES = 300; + private static final int SUCCESS_SERIES = 400; + private static final int SUCCESS_STATUS = SUCCESS_SERIES; + private static final int PARTIAL_SERIES = 500; + private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES; + private static final int PARTIAL_FAILURE_STATUS = PARTIAL_SERIES + 1; + + private static Logger logger = LoggerFactory.getLogger(ApplicationControllerSupport.class); + private String lcmModelPackage = "org.onap.appc.client.lcm.model"; + + /** + * @param action + * @return + * @throws ClassNotFoundException + * @throws InstantiationException + * @throws IllegalAccessException + */ + public Object getInput(String action) { + try { + return getInputClass(action).newInstance(); + } catch (IllegalAccessException | InstantiationException e) { + throw new RuntimeException( + String.format("%s : %s", "Unable to instantiate viable LCM Kit input class for action", action), e); + } + } + + /** + * @param action + * @return + * @throws ClassNotFoundException + */ + public Method getAPIMethod(String action, LifeCycleManagerStateful lcmStateful, boolean async) { + Method[] methods = lcmStateful.getClass().getMethods(); + for (Method method : methods) { + if (method.getName().equalsIgnoreCase(action)) { + Class<?>[] methodParameterTypes = method.getParameterTypes(); + if (methodParameterTypes.length > 0) { + if (getInputClass(action).equals(methodParameterTypes[0])) { + if (async) { + if (methodParameterTypes.length == 2 + && ResponseHandler.class.isAssignableFrom(methodParameterTypes[1])) { + return method; + } + } else if (methodParameterTypes.length == 1) { + return method; + } + } + } + } + } + throw new RuntimeException(String.format("%s : %s, async=%b", + "Unable to derive viable LCM Kit API method for action", action, async)); + } + + public Status getStatusFromGenericResponse(Object response) { + Method statusReader = getBeanPropertyMethodFor(response.getClass(), "status", false); + if (statusReader != null) { + try { + return (Status) statusReader.invoke(response); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + logger.error("Unable to obtain status from LCM Kit response", e); + } + } + return new Status(); + } + + public static StatusCategory getCategoryOf(Status status) { + int codeSeries = status.getCode() - (status.getCode() % 100); + switch (codeSeries) { + case ACCEPT_SERIES: + return StatusCategory.NORMAL; + case ERROR_SERIES: + case REJECT_SERIES: + return StatusCategory.ERROR; + case SUCCESS_SERIES: + return status.getCode() == SUCCESS_STATUS ? StatusCategory.NORMAL : StatusCategory.ERROR; + case PARTIAL_SERIES: + switch (status.getCode()) { + case PARTIAL_SUCCESS_STATUS: + return StatusCategory.NORMAL; + case PARTIAL_FAILURE_STATUS: + return StatusCategory.ERROR; + default: + return StatusCategory.WARNING; + } + default: + return StatusCategory.WARNING; + } + } + + public static boolean getFinalityOf(Status status) { + int codeSeries = status.getCode() - (status.getCode() % 100); + switch (codeSeries) { + case ACCEPT_SERIES: + case PARTIAL_SERIES: + return false; + case ERROR_SERIES: + case REJECT_SERIES: + case SUCCESS_SERIES: + return true; + default: + return true; + } + } + + private Method getBeanPropertyMethodFor(Class<?> clazz, String propertyName, boolean isWriter) { + BeanInfo beanInfo; + try { + beanInfo = Introspector.getBeanInfo(clazz, Object.class); + } catch (IntrospectionException e) { + throw new RuntimeException( + String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b", + clazz.getName(), propertyName, isWriter), + e); + } + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { + if (propertyDescriptor.getName().equals(propertyName)) { + return isWriter ? propertyDescriptor.getWriteMethod() : propertyDescriptor.getReadMethod(); + } + } + throw new RuntimeException( + String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b", + clazz.getName(), propertyName, isWriter)); + } + + /** + * @param action + * @return + * @throws ClassNotFoundException + */ + private Class<?> getInputClass(String action) { + try { + return Class.forName(lcmModelPackage + '.' + action + "Input"); + } catch (ClassNotFoundException e) { + throw new RuntimeException(String.format("%s : %s using package : %s", + "Unable to identify viable LCM Kit input class for action", action, lcmModelPackage), e); + } + } + + public enum StatusCategory { + NORMAL("normal"), WARNING("warning"), ERROR("error"); + + private final String category; + + private StatusCategory(final String category) { + this.category = category; + } + + @Override + public String toString() { + return category; + } + } + + public void logLCMMessage(Object message) { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(Include.NON_NULL); + ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter(); + String inputAsJSON; + try { + inputAsJSON = writer.writeValueAsString(message); + logger.info("LCM Kit input message follows: {}" , inputAsJSON); + } catch (JsonProcessingException e) { + logger.error("Error in logging LCM Message", e); + } + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBean.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBean.java new file mode 100644 index 0000000000..fff818f09b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBean.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.avpn.dmaap.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class AVPNDmaapBean { + + @JsonProperty("asyncRequestStatus") + private AsyncRequestStatus asyncRequestStatus; + + public AsyncRequestStatus getAsyncRequestStatus() { + return asyncRequestStatus; + } + + public void setAsyncRequestStatus(AsyncRequestStatus asyncRequestStatus) { + this.asyncRequestStatus = asyncRequestStatus; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/AsyncRequestStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/AsyncRequestStatus.java new file mode 100644 index 0000000000..13206e8c92 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/AsyncRequestStatus.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.avpn.dmaap.beans; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "asyncRequestStatus") +public class AsyncRequestStatus { + + @JsonProperty("requestId") + private String requestId; + @JsonProperty("clientSource") + private String clientSource; + @JsonProperty("correlator") + private String correlator; + @JsonProperty("instanceReferences") + private InstanceReferences instanceReferences; + @JsonProperty("startTime") + private String startTime; + @JsonProperty("finishTime") + private String finishTime; + @JsonProperty("requestScope") + private String requestScope; + @JsonProperty("requestType") + private String requestType; + @JsonProperty("requestStatus") + private RequestStatus requestStatus; + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getClientSource() { + return clientSource; + } + + public void setClientSource(String clientSource) { + this.clientSource = clientSource; + } + + public String getCorrelator() { + return correlator; + } + + public void setCorrelator(String correlator) { + this.correlator = correlator; + } + + public InstanceReferences getInstanceReferences() { + return instanceReferences; + } + + public void setInstanceReferences(InstanceReferences instanceReferences) { + this.instanceReferences = instanceReferences; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getFinishTime() { + return finishTime; + } + + public void setFinishTime(String finishTime) { + this.finishTime = finishTime; + } + + 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; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/InstanceReferences.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/InstanceReferences.java new file mode 100644 index 0000000000..322f41bf75 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/InstanceReferences.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.avpn.dmaap.beans; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "instanceReferences") +public class InstanceReferences { + + @JsonProperty("serviceInstanceId") + private String serviceInstanceId; + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/RequestStatus.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/RequestStatus.java new file mode 100644 index 0000000000..edc8be7bfe --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/avpn/dmaap/beans/RequestStatus.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.avpn.dmaap.beans; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "requestStatus") +public class RequestStatus { + + @JsonProperty("timestamp") + private String timestamp; + @JsonProperty("requestState") + private String requestState; + @JsonProperty("statusMessage") + private String statusMessage; + @JsonProperty("percentProgress") + private String percentProgress; + @JsonProperty("wasRolledBack") + private Boolean wasRolledBack; + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public String getRequestState() { + return requestState; + } + + public void setRequestState(String requestState) { + this.requestState = requestState; + } + + public String getStatusMessage() { + return statusMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + public String getPercentProgress() { + return percentProgress; + } + + public void setPercentProgress(String percentProgress) { + this.percentProgress = percentProgress; + } + + public Boolean isWasRolledBack() { + return wasRolledBack; + } + + public void setWasRolledBack(Boolean wasRolledBack) { + this.wasRolledBack = wasRolledBack; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/db/request/RequestsDbClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/db/request/RequestsDbClient.java new file mode 100644 index 0000000000..61869ca322 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/db/request/RequestsDbClient.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.db.request; + +import java.io.IOException; +import java.net.URI; + +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpRequest; +import org.springframework.http.client.ClientHttpRequestExecution; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import uk.co.blackpepper.bowman.Client; +import uk.co.blackpepper.bowman.ClientFactory; +import uk.co.blackpepper.bowman.Configuration; +import uk.co.blackpepper.bowman.RestTemplateConfigurer; + +@Component("RequestDbClient") +public class RequestsDbClient { + + private Client<InfraActiveRequests> infraActiveRequestClient; + + @Value("${mso.adapters.db.spring.endpoint}") + private String endpoint; + + @Value("${mso.db.auth}") + private String msoAdaptersAuth; + + public RequestsDbClient() { + ClientFactory clientFactory = Configuration.builder().setRestTemplateConfigurer(new RestTemplateConfigurer() { + + public void configure(RestTemplate restTemplate) { + + restTemplate.getInterceptors().add(new ClientHttpRequestInterceptor() { + + public ClientHttpResponse intercept(HttpRequest request, byte[] body, + ClientHttpRequestExecution execution) throws IOException { + + request.getHeaders().add("Authorization", msoAdaptersAuth); + return execution.execute(request, body); + } + }); + } + }).build().buildClientFactory(); + infraActiveRequestClient = clientFactory.create(InfraActiveRequests.class); + + } + + public InfraActiveRequests getInfraActiveRequestbyRequestId(String requestId) { + return this.getSingleInfraActiveRequests(this.getUri(endpoint + "/infraActiveRequests/" + requestId)); + } + + protected InfraActiveRequests getSingleInfraActiveRequests(URI uri) { + return infraActiveRequestClient.get(uri); + } + + public void updateInfraActiveRequests(InfraActiveRequests request) { + infraActiveRequestClient.put(request); + } + + protected URI getUri(String uri) { + return URI.create(uri); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DefaultDmaapPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DefaultDmaapPropertiesImpl.java new file mode 100644 index 0000000000..c5f08d4809 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DefaultDmaapPropertiesImpl.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.dmaapproperties; + +import org.onap.so.client.dmaap.DmaapProperties; + +import java.util.Map; + +public class DefaultDmaapPropertiesImpl implements DmaapProperties { + + private final Map<String, String> properties; + + public DefaultDmaapPropertiesImpl() { + this.properties = new DmaapPropertiesMap(); + } + + @Override + public Map<String, String> getProperties() { + return properties; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClient.java new file mode 100644 index 0000000000..af7c608fee --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClient.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.dmaapproperties; + +import javax.inject.Provider; + +import org.onap.so.client.avpn.dmaap.beans.AVPNDmaapBean; +import org.onap.so.client.avpn.dmaap.beans.AsyncRequestStatus; +import org.onap.so.client.avpn.dmaap.beans.InstanceReferences; +import org.onap.so.client.avpn.dmaap.beans.RequestStatus; +import org.onap.so.client.exception.MapperException; +import org.onap.so.logger.MsoLogger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class DmaapPropertiesClient { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DmaapPropertiesClient.class); + + @Autowired + private Provider<GlobalDmaapPublisher> dmaapPublisher; + + protected AVPNDmaapBean buildRequestJson(String requestId, String clientSource, String correlator, String serviceInstanceId, String startTime, String finishTime, + String requestScope, String requestType, String timestamp, String requestState, String statusMessage, String percentProgress, Boolean wasRolledBack) { + + RequestStatus requestStatus = buildRequestStatus(timestamp, requestState, statusMessage, percentProgress, wasRolledBack); + + InstanceReferences instanceReferences = buildInstanceReferences(serviceInstanceId); + + AsyncRequestStatus asyncRequestStatus = buildAsyncRequestStatus(requestId, clientSource, correlator, startTime, finishTime, + requestScope, requestType, requestStatus, instanceReferences); + + AVPNDmaapBean dmaapBean = new AVPNDmaapBean(); + dmaapBean.setAsyncRequestStatus(asyncRequestStatus); + + return dmaapBean; + } + + private String jsonToString(AVPNDmaapBean dmaapBean) throws JsonProcessingException, MapperException { + try { + return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(dmaapBean); + } catch (JsonProcessingException e) { + msoLogger.error(e); + throw new MapperException(e.getMessage()); + } + } + + private AsyncRequestStatus buildAsyncRequestStatus(String requestId, String clientSource, String correlator, String startTime, + String finishTime, String requestScope, String requestType, + RequestStatus requestStatus, InstanceReferences instanceReferences) { + + AsyncRequestStatus asyncRequestStatus = new AsyncRequestStatus(); + asyncRequestStatus.setRequestId(requestId); + asyncRequestStatus.setClientSource(clientSource); + asyncRequestStatus.setCorrelator(correlator); + asyncRequestStatus.setStartTime(startTime); + asyncRequestStatus.setFinishTime(finishTime); + asyncRequestStatus.setRequestScope(requestScope); + asyncRequestStatus.setRequestType(requestType); + asyncRequestStatus.setInstanceReferences(instanceReferences); + asyncRequestStatus.setRequestStatus(requestStatus); + + return asyncRequestStatus; + } + + private InstanceReferences buildInstanceReferences(String serviceInstanceId) { + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(serviceInstanceId); + return instanceReferences; + } + + private RequestStatus buildRequestStatus(String timestamp, String requestState, String statusMessage, + String percentProgress, Boolean wasRolledBack) { + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setTimestamp(timestamp); + requestStatus.setRequestState(requestState); + requestStatus.setStatusMessage(statusMessage); + requestStatus.setPercentProgress(percentProgress); + requestStatus.setWasRolledBack(wasRolledBack); + return requestStatus; + } + + public void dmaapPublishRequest(String requestId, String clientSource, String correlator, String serviceInstanceId, String startTime, + String finishTime, String requestScope, String requestType, String timestamp, String requestState, + String statusMessage, String percentProgress, Boolean wasRolledBack) throws MapperException, JsonProcessingException { + + AVPNDmaapBean bean = this.buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime, + requestScope, requestType, timestamp, requestState, statusMessage, percentProgress, wasRolledBack); + + String request = jsonToString(bean); + dmaapPublisher.get().send(request); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesMap.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesMap.java new file mode 100644 index 0000000000..796ccf18b7 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/DmaapPropertiesMap.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.dmaapproperties; + +import org.onap.so.bpmn.core.UrnPropertiesReader; + +import java.util.HashMap; + +/** + * This class is used when Dmaap Properties are to be accessed from + * application.yaml and it delegates get calls to UrnPropertyReader class + * for reading the value from active configuration + * @param <K> Key for Map Entry + * @param <V> Value for Map Entry + */ +public class DmaapPropertiesMap<K,V> extends HashMap<K,V> { + + @Override + public V get(Object key) { + return (V)UrnPropertiesReader.getVariable((String)key); + } + + @Override + public V getOrDefault(Object key, V defaultValue) { + String str = UrnPropertiesReader.getVariable((String)key); + return str ==null ? defaultValue : (V)str; + } + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisher.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisher.java new file mode 100644 index 0000000000..382852886e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisher.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.client.dmaapproperties; + +import java.io.IOException; +import java.util.Optional; + +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.dmaap.DmaapPublisher; + +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +@Component +@Scope("prototype") +public class GlobalDmaapPublisher extends DmaapPublisher { + + + public GlobalDmaapPublisher() throws IOException { + super(); + } + + @Override + public String getUserName() { + + return UrnPropertiesReader.getVariable("mso.global.dmaap.username"); + } + + + + @Override + public String getPassword() { + + return UrnPropertiesReader.getVariable("mso.global.dmaap.password"); + } + + @Override + public String getTopic() { + + return UrnPropertiesReader.getVariable("mso.global.dmaap.publisher.topic"); + } + + @Override + public Optional<String> getHost() { + return Optional.ofNullable(UrnPropertiesReader.getVariable("mso.global.dmaap.host")); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BBObjectNotFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BBObjectNotFoundException.java new file mode 100644 index 0000000000..26c8d80075 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BBObjectNotFoundException.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.exception; + +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; + +public class BBObjectNotFoundException extends Exception{ + private ResourceKey resourceKey; + private String resourceValue; + + public BBObjectNotFoundException() {} + + public BBObjectNotFoundException(ResourceKey resourceKey, String resourceValue) + { + super("BBObject" + resourceKey + " was not found in gBBInput using reference value: " + resourceValue); + this.resourceKey = resourceKey; + this.resourceValue = resourceValue; + } + + public ResourceKey getResourceKey() { + return resourceKey; + } + + public String getResourceValue() { + return resourceValue; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BadResponseException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BadResponseException.java new file mode 100644 index 0000000000..ac8ff9efe4 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/BadResponseException.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.exception; + +public class BadResponseException extends Exception{ + + public BadResponseException() {} + + public BadResponseException(String message) + { + super(message); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java new file mode 100644 index 0000000000..c74e81506c --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.exception; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.logger.MessageEnum; +import org.onap.so.logger.MsoLogger; +import org.springframework.stereotype.Component; + +@Component +public class ExceptionBuilder { + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ExceptionBuilder.class); + + public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, Exception exception) { + String msg = "Exception in %s.%s "; + try{ + msoLogger.error(exception); + + String errorVariable = "Error%s%s"; + + StackTraceElement[] trace = Thread.currentThread().getStackTrace(); + for (StackTraceElement traceElement : trace) { + if (!traceElement.getClassName().equals(this.getClass().getName()) && !traceElement.getClassName().equals(Thread.class.getName())) { + msg = String.format(msg, traceElement.getClassName(), traceElement.getMethodName()); + String shortClassName = traceElement.getClassName().substring(traceElement.getClassName().lastIndexOf(".") + 1); + errorVariable = String.format(errorVariable, shortClassName, traceElement.getMethodName()); + break; + } + } + + msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, msg.toString()); + execution.setVariable(errorVariable, exception.getMessage()); + } catch (Exception ex){ + //log trace, allow process to complete gracefully + msoLogger.error(ex); + } + + if (exception.getMessage() != null) + msg = msg.concat(exception.getMessage()); + buildAndThrowWorkflowException(execution, errorCode, msg); + } + + public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, String errorMessage) { + if (execution instanceof DelegateExecutionImpl) { + buildAndThrowWorkflowException(((DelegateExecutionImpl) execution).getDelegateExecution(), errorCode, errorMessage); + } + } + + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) { + String processKey = getProcessKey(execution); + msoLogger.info("Building a WorkflowException for Subflow"); + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage); + execution.setVariable("WorkflowException", exception); + msoLogger.info("Outgoing WorkflowException is " + exception); + msoLogger.info("Throwing MSOWorkflowException"); + throw new BpmnError("MSOWorkflowException"); + } + + public String getProcessKey(DelegateExecution execution) { + String testKey = (String) execution.getVariable("testProcessKey"); + if (testKey != null) { + return testKey; + } + return execution.getProcessEngineServices().getRepositoryService() + .getProcessDefinition(execution.getProcessDefinitionId()).getKey(); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java new file mode 100644 index 0000000000..3f3beadb92 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/MapperException.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.exception; + +public class MapperException extends Exception{ + + public MapperException() {} + + public MapperException(String message) + { + super(message); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/OrchestrationStatusValidationException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/OrchestrationStatusValidationException.java new file mode 100644 index 0000000000..fe7b079568 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/OrchestrationStatusValidationException.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.exception; + +public class OrchestrationStatusValidationException extends Exception{ + public OrchestrationStatusValidationException() {} + + public OrchestrationStatusValidationException(String message) { + super(message); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java new file mode 100644 index 0000000000..b7164e327e --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.restproperties; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.aai.AAIProperties; +import org.onap.so.client.aai.AAIVersion; +import org.springframework.stereotype.Component; + +@Component +public class AAIPropertiesImpl implements AAIProperties { + + public static final String MSO_MSO_KEY = "mso.msoKey"; + public static final String AAI_AUTH = "aai.auth"; + public static final String AAI_ENDPOINT = "aai.endpoint"; + private UrnPropertiesReader reader; + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(reader.getVariable(AAI_ENDPOINT)); + } + + @Override + public String getSystemName() { + return "MSO"; + } + + @Override + public AAIVersion getDefaultVersion() { + return AAIVersion.LATEST; + } + + @Override + public String getAuth() { + return reader.getVariable(AAI_AUTH); + } + + @Override + public String getKey() { + return reader.getVariable(MSO_MSO_KEY); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AaiPropertiesConfiguration.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AaiPropertiesConfiguration.java new file mode 100644 index 0000000000..b7582922b1 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AaiPropertiesConfiguration.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.restproperties; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +@Service +public class AaiPropertiesConfiguration { + + @Value("${aai.endpoint}") + private String endpoint; + + @Value("${aai.auth}") + private String auth; + + public String getEndpoint() { + return endpoint; + } + + public String getAuth() { + return auth; + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/PolicyRestPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/PolicyRestPropertiesImpl.java new file mode 100644 index 0000000000..1e43adceba --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/PolicyRestPropertiesImpl.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.restproperties; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.policy.PolicyRestProperties; + +public class PolicyRestPropertiesImpl implements PolicyRestProperties { + + public static final String POLICY_ENDPOINT = "policy.endpoint"; + public static final String POLICY_ENVIRONMENT = "policy.environment"; + public static final String POLICY_AUTH = "policy.auth"; + public static final String POLICY_CLIENT_AUTH = "policy.client.auth"; + + public PolicyRestPropertiesImpl() { + } + + @Override + public URL getEndpoint() { + try { + return new URL(UrnPropertiesReader.getVariable(POLICY_ENDPOINT)); + } catch (MalformedURLException e) { + return null; + } + } + + @Override + public String getSystemName() { + return "MSO"; + } + + public String getClientAuth() { + return UrnPropertiesReader.getVariable(POLICY_CLIENT_AUTH); + } + + public String getAuth() { + return UrnPropertiesReader.getVariable(POLICY_AUTH); + } + + public String getEnvironment() { + return UrnPropertiesReader.getVariable(POLICY_ENVIRONMENT); + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/UrnPropertiesReaderWrapper.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/UrnPropertiesReaderWrapper.java new file mode 100644 index 0000000000..030eff92e2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/UrnPropertiesReaderWrapper.java @@ -0,0 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.restproperties; + +import org.onap.so.bpmn.core.UrnPropertiesReader; + +public class UrnPropertiesReaderWrapper { + + public String getVariable(String key) { + return UrnPropertiesReader.getVariable(key); + } +} |