summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-requests-db/src/main/java/org/openecomp')
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraActiveRequests.java41
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java448
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java72
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationStatus.java228
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java106
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDb.java196
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java121
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDb.java243
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDBHelper.java71
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java888
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDbConstant.java65
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDbSessionFactoryManager.java47
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/ResourceOperationStatus.java222
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java72
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java80
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDb.java194
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java71
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDb.java197
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java61
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDb.java124
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapter.java42
21 files changed, 0 insertions, 3589 deletions
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraActiveRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraActiveRequests.java
deleted file mode 100644
index 1d62efb18d..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraActiveRequests.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-
-/**
- * InfraActiveRequests
- */
-public class InfraActiveRequests extends InfraRequests {
-
- /**
- * Serialization id.
- */
- private static final long serialVersionUID = 5003555140088137254L;
-
- public InfraActiveRequests() {
- super ();
- }
-
- public InfraActiveRequests(String requestId, String action) {
- super (requestId, action);
- }
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java
deleted file mode 100644
index d2db8fb35b..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/InfraRequests.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-// Generated Jul 27, 2015 3:05:00 PM by Hibernate Tools 3.4.0.CR1
-
-import java.sql.Timestamp;
-
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.openecomp.mso.requestsdb.adapter.TimestampXMLAdapter;
-
-/**
- * InfraActiveRequests generated by hbm2java
- */
-public class InfraRequests implements java.io.Serializable {
-
- /**
- * Serialization id.
- */
- private static final long serialVersionUID = -661307666798018192L;
-
- private String requestId = null;
- private String clientRequestId = null;
- private String action = null;
- private String requestStatus = null;
- private String statusMessage = null;
- private Long progress;
- private Timestamp startTime = null;
- private Timestamp endTime = null;
- private String source = null;
- private String vnfId = null;
- private String vnfName = null;
- private String vnfType = null;
- private String serviceType = null;
- private String aicNodeClli = null;
- private String tenantId = null;
- private String provStatus = null;
- private String vnfParams = null;
- private String vnfOutputs = null;
- private String requestBody = null;
- private String responseBody = null;
- private String lastModifiedBy = null;
- private Timestamp modifyTime = null;
- private String requestType = null;
- private String volumeGroupId = null;
- private String volumeGroupName = null;
- private String vfModuleId = null;
- private String vfModuleName = null;
- private String vfModuleModelName = null;
- private String aaiServiceId = null;
- private String aicCloudRegion = null;
- private String callBackUrl = null;
- private String correlator = null;
- private String serviceInstanceId = null;
- private String serviceInstanceName = null;
- private String requestScope = null;
- private String requestAction = null;
- private String networkId = null;
- private String networkName = null;
- private String networkType = null;
- private String requestorId = null;
- private String configurationId = null;
- private String configurationName = null;
- private String operationalEnvId = null;
- private String operationalEnvName = null;
-
- public InfraRequests() {
- }
-
- public InfraRequests(String requestId, String action) {
- this.requestId = requestId;
- this.action = action;
- }
-
- public String getRequestId() {
- return this.requestId;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- public String getClientRequestId() {
- return clientRequestId;
- }
-
- public void setClientRequestId(String clientRequestId) {
- this.clientRequestId = clientRequestId;
- }
-
- public String getAction() {
- return this.action;
- }
-
- public void setAction(String action) {
- this.action = action;
- }
-
- public String getRequestStatus() {
- return this.requestStatus;
- }
-
- public void setRequestStatus(String requestStatus) {
- this.requestStatus = requestStatus;
- }
-
- public String getStatusMessage() {
- return this.statusMessage;
- }
-
- public void setStatusMessage(String statusMessage) {
- this.statusMessage = statusMessage;
- }
-
- public Long getProgress() {
- return this.progress;
- }
-
- public void setProgress(Long progress) {
- this.progress = progress;
- }
-
- @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
- public Timestamp getStartTime() {
- return this.startTime;
- }
-
- public void setStartTime(Timestamp startTime) {
- this.startTime = startTime;
- }
-
- @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
- public Timestamp getEndTime() {
- return this.endTime;
- }
-
- public void setEndTime(Timestamp endTime) {
- this.endTime = endTime;
- }
-
- public String getSource() {
- return this.source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getVnfId() {
- return this.vnfId;
- }
-
- public void setVnfId(String vnfId) {
- this.vnfId = vnfId;
- }
-
- public String getVnfName() {
- return this.vnfName;
- }
-
- public void setVnfName(String vnfName) {
- this.vnfName = vnfName;
- }
-
- public String getVnfType() {
- return this.vnfType;
- }
-
- public void setVnfType(String vnfType) {
- this.vnfType = vnfType;
- }
-
- public String getServiceType() {
- return this.serviceType;
- }
-
- public void setServiceType(String serviceType) {
- this.serviceType = serviceType;
- }
-
- public String getAicNodeClli() {
- return this.aicNodeClli;
- }
-
- public void setAicNodeClli(String aicNodeClli) {
- this.aicNodeClli = aicNodeClli;
- }
-
- public String getTenantId() {
- return this.tenantId;
- }
-
- public void setTenantId(String tenantId) {
- this.tenantId = tenantId;
- }
-
- public String getProvStatus() {
- return this.provStatus;
- }
-
- public void setProvStatus(String provStatus) {
- this.provStatus = provStatus;
- }
-
- public String getVnfParams() {
- return this.vnfParams;
- }
-
- public void setVnfParams(String vnfParams) {
- this.vnfParams = vnfParams;
- }
-
- public String getVnfOutputs() {
- return this.vnfOutputs;
- }
-
- public void setVnfOutputs(String vnfOutputs) {
- this.vnfOutputs = vnfOutputs;
- }
-
- public String getRequestBody() {
- return this.requestBody;
- }
-
- public void setRequestBody(String requestBody) {
- this.requestBody = requestBody;
- }
-
- public String getResponseBody() {
- return this.responseBody;
- }
-
- public void setResponseBody(String responseBody) {
- this.responseBody = responseBody;
- }
-
- public String getLastModifiedBy() {
- return this.lastModifiedBy;
- }
-
- public void setLastModifiedBy(String lastModifiedBy) {
- this.lastModifiedBy = lastModifiedBy;
- }
-
- @XmlJavaTypeAdapter(TimestampXMLAdapter.class)
- public Timestamp getModifyTime() {
- return this.modifyTime;
- }
-
- public void setModifyTime(Timestamp modifyTime) {
- this.modifyTime = modifyTime;
- }
-
- public String getRequestType() {
- return this.requestType;
- }
-
- public void setRequestType(String requestType) {
- this.requestType = requestType;
- }
-
- public String getVolumeGroupId() {
- return this.volumeGroupId;
- }
-
- public void setVolumeGroupId(String volumeGroupId) {
- this.volumeGroupId = volumeGroupId;
- }
-
- public String getVolumeGroupName() {
- return this.volumeGroupName;
- }
-
- public void setVolumeGroupName(String volumeGroupName) {
- this.volumeGroupName = volumeGroupName;
- }
-
- public String getVfModuleId() {
- return this.vfModuleId;
- }
-
- public void setVfModuleId(String vfModuleId) {
- this.vfModuleId = vfModuleId;
- }
-
- public String getVfModuleName() {
- return this.vfModuleName;
- }
-
- public void setVfModuleName(String vfModuleName) {
- this.vfModuleName = vfModuleName;
- }
-
- public String getVfModuleModelName() {
- return this.vfModuleModelName;
- }
-
- public void setVfModuleModelName(String vfModuleModelName) {
- this.vfModuleModelName = vfModuleModelName;
- }
-
- public String getAaiServiceId() {
- return this.aaiServiceId;
- }
-
- public void setAaiServiceId(String aaiServiceId) {
- this.aaiServiceId = aaiServiceId;
- }
-
- public String getAicCloudRegion() {
- return this.aicCloudRegion;
- }
-
- public void setAicCloudRegion(String aicCloudRegion) {
- this.aicCloudRegion = aicCloudRegion;
- }
-
- public String getCallBackUrl() {
- return callBackUrl;
- }
-
- public void setCallBackUrl(String callBackUrl) {
- this.callBackUrl = callBackUrl;
- }
-
- public String getCorrelator() {
- return correlator;
- }
-
- public void setCorrelator(String correlator) {
- this.correlator = correlator;
- }
-
- public String getServiceInstanceId() {
- return serviceInstanceId;
- }
-
- public void setServiceInstanceId(String serviceInstanceId) {
- this.serviceInstanceId = serviceInstanceId;
- }
-
- public String getServiceInstanceName() {
- return serviceInstanceName;
- }
-
- public void setServiceInstanceName(String serviceInstanceName) {
- this.serviceInstanceName = serviceInstanceName;
- }
-
- public String getRequestScope() {
- return requestScope;
- }
-
- public void setRequestScope(String requestScope) {
- this.requestScope = requestScope;
- }
-
- public String getRequestAction() {
- return requestAction;
- }
-
- public void setRequestAction(String requestAction) {
- this.requestAction = requestAction;
- }
-
- public String getNetworkId() {
- return networkId;
- }
-
- public void setNetworkId(String networkId) {
- this.networkId = networkId;
- }
-
- public String getNetworkName() {
- return networkName;
- }
-
- public void setNetworkName(String networkName) {
- this.networkName = networkName;
- }
-
- public String getNetworkType() {
- return networkType;
- }
-
- public void setNetworkType(String networkType) {
- this.networkType = networkType;
- }
-
- public String getRequestorId() {
- return requestorId;
- }
-
- public void setRequestorId(String requestorId) {
- this.requestorId = requestorId;
- }
-
- public String getConfigurationId() {
- return configurationId;
- }
-
- public void setConfigurationId(String configurationId) {
- this.configurationId = configurationId;
- }
-
- public String getConfigurationName() {
- return configurationName;
- }
-
- public void setConfigurationName(String configurationName) {
- this.configurationName = configurationName;
- }
-
- public String getOperationalEnvId() {
- return operationalEnvId;
- }
-
- public void setOperationalEnvId(String operationalEnvId) {
- this.operationalEnvId = operationalEnvId;
- }
-
- public String getOperationalEnvName() {
- return operationalEnvName;
- }
-
- public void setOperationalEnvName(String operationalEnvName) {
- this.operationalEnvName = operationalEnvName;
- }
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java
deleted file mode 100644
index c88f31c819..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/MockRequestsDatabase.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class MockRequestsDatabase {
-
- private Map<String, InfraActiveRequests> activeRequests;
-
- public MockRequestsDatabase() {
- activeRequests = new HashMap<>();
- }
-
- public void addRecord(InfraActiveRequests record) {
- String serviceType = record.getServiceType();
- String serviceInstanceId = record.getServiceInstanceId();
- String key = serviceType + "::" + serviceInstanceId;
- activeRequests.put(key, record);
- }
-
- public void deleteRecord(String serviceType, String serviceInstanceId) {
- String key = serviceType + "::" + serviceInstanceId;
- activeRequests.remove(key);
- }
-
- public InfraActiveRequests getRecord(String serviceType, String serviceInstanceId) {
- String key = serviceType + "::" + serviceInstanceId;
- InfraActiveRequests record = activeRequests.get(key);
- return record;
- }
-
- public InfraActiveRequests checkDuplicate(String serviceType, String serviceInstanceId) {
- return getRecord(serviceType, serviceInstanceId);
- }
-
- public InfraActiveRequests checkRetry(String serviceType, String serviceInstanceId) {
- InfraActiveRequests record = getRecord(serviceType, serviceInstanceId);
- InfraActiveRequests returnRecord = null;
- if (record != null) {
- String requestAction = record.getRequestAction();
- if (!"GetLayer3ServiceDetailsRequest".equals(requestAction)) {
- String status = record.getRequestStatus();
- if ("COMPLETED".equals(status)) {
- returnRecord = record;
- }
- }
- }
- return returnRecord;
- }
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationStatus.java
deleted file mode 100644
index f61b2729e8..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationStatus.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.requestsdb;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-/**
- * The service operation status
- * <br>
- * <p>
- * </p>
- *
- * @author
- * @version ONAP Amsterdam Release 2017-08-28
- */
-public class OperationStatus implements Serializable{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private String serviceId = null;
-
- private String operationId = null;
-
- private String serviceName = null;
-
- private String operation = null;
-
- private String userId = null;
-
- private String result = null;
-
- private String operationContent = null;
-
- private String progress = "0";
-
- private String reason = null;
-
- private Timestamp operateAt = null;
-
- private Timestamp finishedAt = null;
-
-
- public String getServiceId() {
- return serviceId;
- }
-
-
- public void setServiceId(String serviceId) {
- this.serviceId = serviceId;
- }
-
-
- public String getOperationId() {
- return operationId;
- }
-
-
- public void setOperationId(String operationId) {
- this.operationId = operationId;
- }
-
-
- public String getOperation() {
- return operation;
- }
-
-
- public void setOperation(String operation) {
- this.operation = operation;
- }
-
-
- public String getUserId() {
- return userId;
- }
-
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
-
- public String getResult() {
- return result;
- }
-
-
- public void setResult(String result) {
- this.result = result;
- }
-
-
- public String getOperationContent() {
- return operationContent;
- }
-
-
- public void setOperationContent(String operationContent) {
- this.operationContent = operationContent;
- }
-
-
- public String getProgress() {
- return progress;
- }
-
-
- public void setProgress(String progress) {
- this.progress = progress;
- }
-
-
- public String getReason() {
- return reason;
- }
-
-
- public void setReason(String reason) {
- this.reason = reason;
- }
-
-
- public Timestamp getOperateAt() {
- return operateAt;
- }
-
-
- public void setOperateAt(Timestamp operateAt) {
- this.operateAt = operateAt;
- }
-
-
- public Timestamp getFinishedAt() {
- return finishedAt;
- }
-
-
- public void setFinishedAt(Timestamp finishedAt) {
- this.finishedAt = finishedAt;
- }
-
-
-
- /**
- * @return Returns the serviceName.
- */
- public String getServiceName() {
- return serviceName;
- }
-
-
-
- /**
- * @param serviceName The serviceName to set.
- */
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
-
- /**
- * <br>
- *
- * @return
- * @since ONAP Amsterdam Release
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((operationId == null) ? 0 : operationId.hashCode());
- result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
- return result;
- }
-
-
- /**
- * <br>
- *
- * @param obj
- * @return
- * @since ONAP Amsterdam Release
- */
- @Override
- public boolean equals(Object obj) {
- if(this == obj)
- return true;
- if(obj == null)
- return false;
- if(getClass() != obj.getClass())
- return false;
- OperationStatus other = (OperationStatus)obj;
- if(operationId == null) {
- if(other.operationId != null)
- return false;
- } else if(!operationId.equals(other.operationId))
- return false;
- if(serviceId == null) {
- if(other.serviceId != null)
- return false;
- } else if(!serviceId.equals(other.serviceId))
- return false;
- return true;
- }
-
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java
deleted file mode 100644
index c5df122816..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatus.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-public class OperationalEnvDistributionStatus implements Serializable {
-
- /**
- * Serialization id.
- */
- private static final long serialVersionUID = 7398393659281364650L;
-
- private String distributionId = null;
- private String operationalEnvId = null;
- private String serviceModelVersionId = null;
- private String requestId = null;
- private String distributionIdStatus = null;
- private String distributionIdErrorReason = null;
- private Timestamp createTime = null;
- private Timestamp modifyTime = null;
-
- public String getDistributionId() {
- return distributionId;
- }
-
- public void setDistributionId(String distributionId) {
- this.distributionId = distributionId;
- }
-
- public String getOperationalEnvId() {
- return operationalEnvId;
- }
-
- public void setOperationalEnvId(String operationalEnvId) {
- this.operationalEnvId = operationalEnvId;
- }
-
- public String getServiceModelVersionId() {
- return serviceModelVersionId;
- }
-
- public void setServiceModelVersionId(String serviceModelVersionId) {
- this.serviceModelVersionId = serviceModelVersionId;
- }
-
- public String getRequestId() {
- return requestId;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- public String getDistributionIdStatus() {
- return distributionIdStatus;
- }
-
- public void setDistributionIdStatus(String distributionIdStatus) {
- this.distributionIdStatus = distributionIdStatus;
- }
-
- public String getDistributionIdErrorReason() {
- return distributionIdErrorReason;
- }
-
- public void setDistributionIdErrorReason(String distributionIdErrorReason) {
- this.distributionIdErrorReason = distributionIdErrorReason;
- }
-
- public Timestamp getCreateTime() {
- return createTime;
- }
-
- public void setCreateTime(Timestamp createTime) {
- this.createTime = createTime;
- }
-
- public Timestamp getModifyTime() {
- return modifyTime;
- }
-
- public void setModifyTime(Timestamp modifyTime) {
- this.modifyTime = modifyTime;
- }
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDb.java
deleted file mode 100644
index ce2e1f6906..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvDistributionStatusDb.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-
-import java.sql.Timestamp;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class OperationalEnvDistributionStatusDb {
-
- protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
-
- protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
-
-
- protected static final String DISTRIBUTION_ID = "distributionId";
- protected static final String OPERATIONAL_ENV_ID = "operationalEnvId";
- protected static final String REQUEST_ID = "requestId";
- protected static final String SERVICE_MODEL_VERSION_ID = "serviceModelVersionId";
- protected static final String DISTRIBUTION_ID_STATUS = "distributionIdStatus";
- protected static final String CREATE_TIME = "startTime";
- protected static final String MODIFY_TIME = "modifyTime";
-
-
- public static OperationalEnvDistributionStatusDb getInstance() {
- return new OperationalEnvDistributionStatusDb(new RequestsDbSessionFactoryManager ());
- }
-
- protected OperationalEnvDistributionStatusDb (AbstractSessionFactoryManager sessionFactoryRequest) {
- sessionFactoryRequestDB = sessionFactoryRequest;
- }
-
-
- /**
- * Retrieve OperationalEnvDistributionStatus from getSecgiven distributionId
- * @param distributionId
- * @return
- */
- public OperationalEnvDistributionStatus getOperationalEnvDistributionStatus(String distributionId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Retrieve Operational Environment Distribution Status with distributionId: " + distributionId);
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- OperationalEnvDistributionStatus request = null;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("from OperationalEnvDistributionStatus where distributionId = :distributionId");
- query.setParameter (DISTRIBUTION_ID, distributionId);
- request = (OperationalEnvDistributionStatus) query.uniqueResult ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "OperationalEnvDistributionStatus", "getOperationalEnvDistributionStatus", null);
- }
- return request;
- }
-
- /**
- * Retrieve OperationalEnvDistributionStatus from given distributionId and requestId
- * @param distributionId
- * @param requestId
- * @return OperationalEnvDistributionStatus
- */
- public OperationalEnvDistributionStatus getOperationalEnvDistributionStatusPerReqId(String distributionId, String requestId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Retrieve Operational Environment Distribution Status with distributionId: " + distributionId + ", requestId: " + requestId);
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- OperationalEnvDistributionStatus request = null;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("from OperationalEnvDistributionStatus where distributionId = :distributionId AND requestId = :requestId");
- query.setParameter (DISTRIBUTION_ID, distributionId);
- query.setParameter (REQUEST_ID, requestId);
- request = (OperationalEnvDistributionStatus) query.uniqueResult ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "OperationalEnvDistributionStatus", "getOperationalEnvDistributionStatusPerReqId", null);
- }
- return request;
- }
-
- /**
- * Update OperationalEnvDistributionStatus with distributionIdStatus for given distributionId, serviceModelVersionId, serviceModelVersionId
- * @param asdcStatus
- * @param distributionId
- * @param operationalEnvId
- * @param serviceModelVersionId
- */
- public int updateOperationalEnvDistributionStatus(String asdcStatus, String distributionId,
- String operationalEnvId, String serviceModelVersionId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Update OperationalEnvDistributionStatus DISTRIBUTION_ID_STATUS with asdcStatus: " + asdcStatus);
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- int result = 0;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("update OperationalEnvDistributionStatus set distributionIdStatus = :distributionIdStatus, modifyTime = :modifyTime where distributionId = :distributionId and "
- + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId ");
- query.setParameter (DISTRIBUTION_ID_STATUS, asdcStatus);
- query.setParameter ("distributionId", distributionId);
- query.setParameter ("operationalEnvId", operationalEnvId);
- query.setParameter ("serviceModelVersionId", serviceModelVersionId);
- Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- query.setParameter ("modifyTime", modifyTimeStamp);
- result = query.executeUpdate ();
- session.getTransaction ().commit ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateOperationalEnvDistributionStatus", null);
- }
- return result;
- }
-
- /**
- * Insert into OperationalEnvDistributionStatus with distributionId, operationalEnvId, serviceModelVersionId, distributionIdStatus
- * @param distributionId
- * @param operationalEnvId
- * @param serviceModelVersionId
- * @param distributionIdStatus
- */
- public void insertOperationalEnvDistributionStatus(String distributionId, String operationalEnvId, String serviceModelVersionId,
- String distributionIdStatus, String requestId) {
- long startTime = System.currentTimeMillis ();
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
- msoLogger.debug ("Insert into OperationalEnvDistributionStatus " );
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- OperationalEnvDistributionStatus oed = new OperationalEnvDistributionStatus ();
-
- try {
- session.beginTransaction ();
-
- oed.setDistributionId (distributionId);
- oed.setOperationalEnvId (operationalEnvId);
- oed.setServiceModelVersionId (serviceModelVersionId);
- oed.setDistributionIdStatus (distributionIdStatus);
- oed.setRequestId(requestId);
- oed.setCreateTime (startTimeStamp);
- Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- oed.setModifyTime (modifyTimeStamp);
-
- msoLogger.debug ("About to insert a record into OperationalEnvDistributionStatus");
-
- session.save (oed);
- session.getTransaction ().commit ();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertOperationalEnvDistributionStatus", e);
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "OperationalEnvDistributionStatusDB", "saveRequest", null);
- if (session != null) {
- session.close ();
- }
- // throw an Exception in the event of a DB insert failure so that the calling routine can exit
- throw e;
- }
- finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "OperationalEnvDistributionStatusDB", "insertOperationalEnvDistributionStatus", null);
- }
- }
-
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java
deleted file mode 100644
index fe581de71b..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatus.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-/**
- *
- */
-package org.openecomp.mso.requestsdb;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-/**
- * @author PB6115
- *
- */
-public class OperationalEnvServiceModelStatus implements Serializable {
-
- /**
- * Serialization id.
- */
- private static final long serialVersionUID = 8197084996598869656L;
-
- private String requestId = null;
- private String operationalEnvId = null;
- private String serviceModelVersionId = null;
- private String serviceModelVersionDistrStatus = null;
- private String recoveryAction = null;
- private int retryCount;
- private String workloadContext = null;
- private Timestamp createTime = null;
- private Timestamp modifyTime = null;
-
- public String getRequestId() {
- return requestId;
- }
-
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
- public String getOperationalEnvId() {
- return operationalEnvId;
- }
-
- public void setOperationalEnvId(String operationalEnvId) {
- this.operationalEnvId = operationalEnvId;
- }
-
- public String getServiceModelVersionId() {
- return serviceModelVersionId;
- }
-
- public void setServiceModelVersionId(String serviceModelVersionId) {
- this.serviceModelVersionId = serviceModelVersionId;
- }
-
- public String getServiceModelVersionDistrStatus() {
- return serviceModelVersionDistrStatus;
- }
-
- public void setServiceModelVersionDistrStatus(String serviceModelVersionDistrStatus) {
- this.serviceModelVersionDistrStatus = serviceModelVersionDistrStatus;
- }
-
- public String getRecoveryAction() {
- return recoveryAction;
- }
-
- public void setRecoveryAction(String recoveryAction) {
- this.recoveryAction = recoveryAction;
- }
-
- public int getRetryCount() {
- return retryCount;
- }
-
- public void setRetryCount(int retryCount) {
- this.retryCount = retryCount;
- }
-
- public String getWorkloadContext() {
- return workloadContext;
- }
-
- public void setWorkloadContext(String workloadContext) {
- this.workloadContext = workloadContext;
- }
-
- public Timestamp getCreateTime() {
- return createTime;
- }
- public void setCreateTime(Timestamp createTime) {
- this.createTime = createTime;
- }
-
- public Timestamp getModifyTime() {
- return modifyTime;
- }
-
- public void setModifyTime(Timestamp modifyTime) {
- this.modifyTime = modifyTime;
- }
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDb.java
deleted file mode 100644
index 1c2055ee91..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/OperationalEnvServiceModelStatusDb.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class OperationalEnvServiceModelStatusDb {
-
- protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
-
- protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
-
-
- protected static final String REQUEST_ID = "requestId";
- protected static final String OPERATIONAL_ENV_ID = "operationalEnvId";
- protected static final String SERVICE_MODEL_VERSION_ID = "serviceModelVersionId";
- protected static final String SERVICE_MOD_VER_DISTR_STATUS = "serviceModelVersionDistrStatus";
- protected static final String RECOVERY_ACTION = "recoveryAction";
- protected static final int RETRY_COUNT_LEFT = 0;
- protected static final String CREATE_TIME = "startTime";
- protected static final String MODIFY_TIME = "modifyTime";
-
-
- public static OperationalEnvServiceModelStatusDb getInstance() {
- return new OperationalEnvServiceModelStatusDb(new RequestsDbSessionFactoryManager ());
- }
-
- protected OperationalEnvServiceModelStatusDb (AbstractSessionFactoryManager sessionFactoryRequest) {
- sessionFactoryRequestDB = sessionFactoryRequest;
- }
-
-
- /**
- * Retrieve OperationalEnvServiceModelStatus from given OperationalEnvironmentId and serviceModelVersionId
- * @param operationalEnvId
- * @param serviceModelVersionId
- * @return
- */
- public OperationalEnvServiceModelStatus getOperationalEnvServiceModelStatus(String operationalEnvId, String serviceModelVersionId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Retrieve OperationalEnvironmentServiceModel with operationalEnvironmentId: " + operationalEnvId + ", serviceModelVersionId: " + serviceModelVersionId);
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- OperationalEnvServiceModelStatus request = null;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("FROM OperationalEnvServiceModelStatus WHERE operationalEnvId = :operationalEnvId AND serviceModelVersionId = :serviceModelVersionId");
- query.setParameter ("operationalEnvId", operationalEnvId);
- query.setParameter ("serviceModelVersionId", serviceModelVersionId);
- request = (OperationalEnvServiceModelStatus) query.uniqueResult ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "OperationalEnvServiceModelStatus", "getOperationalEnvServiceModelStatus", null);
- }
- return request;
- }
-
-
- /**
- * Retrieve OperationalEnvServiceModelStatus from given OperationalEnvironmentId and serviceModelVersionId
- * @param operationalEnvId
- * @param serviceModelVersionId
- * @return
- */
- @SuppressWarnings("unchecked")
- public List<OperationalEnvServiceModelStatus> getOperationalEnvIdStatus(String operationalEnvId, String requestId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Retrieve OperationalEnvironmentServiceModel with operationalEnvironmentId: " + operationalEnvId + ", requestId: " + requestId);
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- List<OperationalEnvServiceModelStatus> requests = new ArrayList<OperationalEnvServiceModelStatus>();
-
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("FROM OperationalEnvServiceModelStatus WHERE operationalEnvId = :operationalEnvId AND requestId = :requestId");
- query.setParameter ("operationalEnvId", operationalEnvId);
- query.setParameter ("requestId", requestId);
- requests = query.list();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "OperationalEnvServiceModelStatus", "getOperationalEnvIdStatus", null);
- }
- return requests;
- }
-
-
- /**
- * Update OperationalEnvServiceModelStatus serviceModelVersionDistrStatus with asdcStatus and retryCount for given operationalEnvId, serviceModelVersionId
- * @param operationalEnvId
- * @param serviceModelVersionId
- * @param asdcStatus
- * @param retryCount
- */
- public int updateOperationalEnvRetryCountStatus(String operationalEnvId, String serviceModelVersionId, String asdcStatus, int retryCount) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Update OperationalEnvServiceModelStatus retryCount: " + retryCount + " and serviceModelVersionDistrStatus :" + asdcStatus);
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- int result = 0;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("update OperationalEnvServiceModelStatus set serviceModelVersionDistrStatus = :serviceModelVersionDistrStatus, retryCount = :retryCount, modifyTime = :modifyTime where "
- + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId ");
- query.setParameter ("retryCount", retryCount);
- query.setParameter (SERVICE_MOD_VER_DISTR_STATUS, asdcStatus);
- query.setParameter ("operationalEnvId", operationalEnvId);
- query.setParameter ("serviceModelVersionId", serviceModelVersionId);
- Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- query.setParameter ("modifyTime", modifyTimeStamp);
- result = query.executeUpdate ();
- session.getTransaction ().commit ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "OperationalEnvServiceModelDB", "updateOperationalEnvRetryCountStatus", null);
- }
- return result;
- }
-
- /**
- * Update OperationalEnvServiceModelStatus serviceModelVersionDistrStatus with asdcStatus and retryCount for given operationalEnvId, serviceModelVersionId, requestId
- * @param operationalEnvId
- * @param serviceModelVersionId
- * @param asdcStatus
- * @param retryCount
- * @param requestId
- */
- public int updateOperationalEnvRetryCountStatusPerReqId(String operationalEnvId, String serviceModelVersionId, String asdcStatus, int retryCount, String requestId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Update OperationalEnvServiceModelStatus retryCount: " + retryCount + " and serviceModelVersionDistrStatus :" + asdcStatus);
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- int result = 0;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("update OperationalEnvServiceModelStatus set serviceModelVersionDistrStatus = :asdcStatus, retryCount = :retryCount, modifyTime = :modifyTime where "
- + "operationalEnvId = :operationalEnvId and serviceModelVersionId = :serviceModelVersionId and requestId = :requestId ");
- query.setParameter ("retryCount", retryCount);
- query.setParameter (SERVICE_MOD_VER_DISTR_STATUS, asdcStatus);
- query.setParameter ("operationalEnvId", operationalEnvId);
- query.setParameter ("serviceModelVersionId", serviceModelVersionId);
- query.setParameter ("requestId", requestId);
- Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- query.setParameter ("modifyTime", modifyTimeStamp);
- result = query.executeUpdate ();
- session.getTransaction ().commit ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "OperationalEnvServiceModelDB", "updateOperationalEnvRetryCountStatusPerReqId", null);
- }
- return result;
- }
-
-
- /**
- * Insert into OperationalEnvServiceModelStatus with operationalEnvId, serviceModelVersionId, distributionIdStatus, recoveryAction, retryCount
- * @param operationalEnvId
- * @param serviceModelVersionId
- * @param distributionIdStatus
- * @param distributionId
- * @param recoveryAction
- * @param retryCount
- */
- public void insertOperationalEnvServiceModelStatus(String requestId, String operationalEnvId, String serviceModelVersionId,
- String distributionIdStatus, String recoveryAction, int retryCount, String workloadContext) {
- long startTime = System.currentTimeMillis ();
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
- msoLogger.debug ("Insert into OperationalEnvServiceModelStatus " );
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- OperationalEnvServiceModelStatus oesm = new OperationalEnvServiceModelStatus ();
-
- try {
- session.beginTransaction ();
-
- oesm.setRequestId (requestId);
- oesm.setOperationalEnvId (operationalEnvId);
- oesm.setServiceModelVersionId (serviceModelVersionId);
- oesm.setServiceModelVersionDistrStatus (distributionIdStatus);
- oesm.setRecoveryAction (recoveryAction);
- oesm.setRetryCount (retryCount);
- oesm.setWorkloadContext(workloadContext);
- oesm.setCreateTime (startTimeStamp);
- Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- oesm.setModifyTime (modifyTimeStamp);
-
- msoLogger.debug ("About to insert a record into OperationalEnvServiceModelStatus");
-
- session.save (oesm);
- session.getTransaction ().commit ();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertOperationalEnvServiceModelStatus", e);
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "OperationalEnvServiceModelStatusDB", "saveRequest", null);
- if (session != null) {
- session.close ();
- }
- // throw an Exception in the event of a DB insert failure so that the calling routine can exit
- throw e;
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "OperationalEnvServiceModelStatusDB", "insertOperationalEnvServiceModelStatus", null);
- }
-
- }
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDBHelper.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDBHelper.java
deleted file mode 100644
index 29e55b8042..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDBHelper.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-import org.openecomp.mso.logger.MsoLogger;
-
-public class RequestsDBHelper {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
- private String className = this.getClass().getSimpleName() +" class\'s ";
- private String methodName = "";
- private String classMethodMessage = "";
-
- /**
- * This util method is to update the InfraRequest table to Complete
- * @param msg - string, unique message for each caller
- * @param requestId - string
- * @param operationalEnvironmentId - string
- * @return void - nothing
- * @throws Exception
- */
- public void updateInfraSuccessCompletion(String msg, String requestId, String operationalEnvironmentId) {
- methodName = "updateInfraSuccessCompletion() method.";
- classMethodMessage = className + " " + methodName;
- msoLogger.debug("Begin of " + classMethodMessage);
-
- RequestsDatabase requestDB = RequestsDatabase.getInstance();
- requestDB.updateInfraFinalStatus(requestId, "COMPLETE", "SUCCESSFUL, operationalEnvironmentId - " + operationalEnvironmentId + "; Success Message: " + msg,
- 100L, null, "APIH");
- msoLogger.debug("End of " + classMethodMessage);
-
- }
-
- /**
- * This util method is to update the InfraRequest table to Failure
- * @param msg - string, unique message for each caller
- * @param requestId - string
- * @param operationalEnvironmentId - string
- * @return void - nothing
- * @throws Exception
- */
- public void updateInfraFailureCompletion(String msg, String requestId, String operationalEnvironmentId) {
- methodName = "updateInfraFailureCompletion() method.";
- classMethodMessage = className + " " + methodName;
- msoLogger.debug("Begin of " + classMethodMessage);
-
- RequestsDatabase requestDB = RequestsDatabase.getInstance();
- requestDB.updateInfraFinalStatus(requestId, "FAILED", "FAILURE, operationalEnvironmentId - " + operationalEnvironmentId + "; Error message: " + msg,
- 100L, null, "APIH");
- msoLogger.debug("End of " + classMethodMessage);
-
- }
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
deleted file mode 100644
index 9964b93df4..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
+++ /dev/null
@@ -1,888 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.hibernate.Criteria;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Restrictions;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.requestsdb.RequestsDbConstant.Status;
-import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class RequestsDatabase {
-
- protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
-
- protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
-
- protected static final String SOURCE = "source";
- protected static final String START_TIME = "startTime";
- protected static final String REQUEST_TYPE = "requestType";
- protected static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
- protected static final String SERVICE_INSTANCE_NAME = "serviceInstanceName";
- protected static final String VNF_INSTANCE_NAME = "vnfName";
- protected static final String VNF_INSTANCE_ID = "vnfId";
- protected static final String VOLUME_GROUP_INSTANCE_NAME = "volumeGroupName";
- protected static final String VOLUME_GROUP_INSTANCE_ID = "volumeGroupId";
- protected static final String VFMODULE_INSTANCE_NAME = "vfModuleName";
- protected static final String VFMODULE_INSTANCE_ID = "vfModuleId";
- protected static final String NETWORK_INSTANCE_NAME = "networkName";
- protected static final String CONFIGURATION_INSTANCE_ID = "configurationId";
- protected static final String CONFIGURATION_INSTANCE_NAME= "configurationName";
- protected static final String OPERATIONAL_ENV_ID = "operationalEnvId";
- protected static final String OPERATIONAL_ENV_NAME = "operationalEnvName";
- protected static final String NETWORK_INSTANCE_ID = "networkId";
- protected static final String GLOBAL_SUBSCRIBER_ID = "globalSubscriberId";
- protected static final String SERVICE_NAME_VERSION_ID = "serviceNameVersionId";
- protected static final String SERVICE_ID = "serviceId";
- protected static final String SERVICE_VERSION = "serviceVersion";
- protected static final String REQUEST_ID = "requestId";
- protected static final String REQUESTOR_ID = "requestorId";
-
- protected static MockRequestsDatabase mockDB = null;
-
- public static RequestsDatabase getInstance() {
- return new RequestsDatabase(new RequestsDbSessionFactoryManager ());
- }
-
- protected RequestsDatabase (AbstractSessionFactoryManager sessionFactoryRequest) {
- sessionFactoryRequestDB = sessionFactoryRequest;
- }
-
- public boolean healthCheck () {
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- try {
- Query query = session.createSQLQuery (" show tables ");
-
- List<?> list = query.list();
-
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- }
- return true;
- }
-
-
- public int updateInfraStatus (String requestId, String requestStatus, String lastModifiedBy) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Update infra request record " + requestId + " with status " + requestStatus);
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
-
- int result = 0;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("update InfraActiveRequests set requestStatus = :requestStatus, modifyTime = :modifyTime, lastModifiedBy = :lastModifiedBy where requestId = :requestId ");
- query.setParameter ("requestStatus", requestStatus);
- query.setParameter (REQUEST_ID, requestId);
- query.setParameter ("lastModifiedBy", lastModifiedBy);
- Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- query.setParameter ("modifyTime", modifyTimeStamp);
- result = query.executeUpdate ();
- session.getTransaction ().commit ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateInfraStatus", null);
- }
- return result;
- }
-
- public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Update infra request record " + requestId + " with status " + requestStatus);
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
-
- int result = 0;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("update InfraActiveRequests set requestStatus = :requestStatus, modifyTime = :modifyTime, progress = :progress, lastModifiedBy = :lastModifiedBy where requestId = :requestId ");
- query.setParameter ("requestStatus", requestStatus);
- query.setParameter (REQUEST_ID, requestId);
- query.setParameter ("progress", progress);
- query.setParameter ("lastModifiedBy", lastModifiedBy);
- Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- query.setParameter ("modifyTime", modifyTimeStamp);
- result = query.executeUpdate ();
- session.getTransaction ().commit ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateInfraStatus", null);
- }
- return result;
- }
-
- public int updateInfraFinalStatus (String requestId, String requestStatus, String statusMessage, long progress, String responseBody, String lastModifiedBy) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Update infra request record " + requestId + " with status " + requestStatus);
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
-
- int result = 0;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("update InfraActiveRequests set requestStatus = :requestStatus, statusMessage = :statusMessage, progress = :progress, endTime = :endTime, responseBody = :responseBody, lastModifiedBy = :lastModifiedBy where id.requestId = :requestId ");
- query.setParameter ("requestStatus", requestStatus);
- query.setParameter ("requestId", requestId);
- Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
- query.setParameter ("endTime", endTimeStamp);
- query.setParameter ("statusMessage", statusMessage);
- query.setParameter ("progress", progress);
- query.setParameter ("responseBody", responseBody);
- query.setParameter ("lastModifiedBy", lastModifiedBy);
- result = query.executeUpdate ();
- session.getTransaction ().commit ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateInfraFinalStatus", null);
- }
- return result;
- }
-
-
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
-
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Execute query on infra active request table");
-
- List <InfraActiveRequests> results = new ArrayList<>();
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- try {
- session.beginTransaction ();
- Criteria crit = session.createCriteria (InfraActiveRequests.class);
- for (Criterion criterion : criteria) {
- crit.add (criterion);
- }
- crit.addOrder (order);
-
- // @SuppressWarnings("unchecked")
- results = crit.list ();
-
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getInfraActiveRequest", null);
- }
- return results;
- }
-
- public InfraActiveRequests getRequestFromInfraActive (String requestId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Get request " + requestId + " from InfraActiveRequests DB");
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- InfraActiveRequests ar = null;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("from InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId");
- query.setParameter (REQUEST_ID, requestId);
- ar = (InfraActiveRequests) query.uniqueResult ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "InfraRequestDB", "getRequestFromInfraActive", null);
- }
- return ar;
- }
-
- public InfraActiveRequests checkInstanceNameDuplicate (HashMap<String,String> instanceIdMap, String instanceName, String requestScope) {
-
- List <Criterion> criteria = new LinkedList <> ();
-
- if(instanceName != null && !instanceName.equals("")) {
-
- if("service".equals(requestScope)){
- criteria.add (Restrictions.eq (SERVICE_INSTANCE_NAME, instanceName));
- } else if("vnf".equals(requestScope)){
- criteria.add (Restrictions.eq (VNF_INSTANCE_NAME, instanceName));
- } else if("volumeGroup".equals(requestScope)){
- criteria.add (Restrictions.eq (VOLUME_GROUP_INSTANCE_NAME, instanceName));
- } else if("vfModule".equals(requestScope)){
- criteria.add (Restrictions.eq (VFMODULE_INSTANCE_NAME, instanceName));
- } else if("network".equals(requestScope)){
- criteria.add (Restrictions.eq (NETWORK_INSTANCE_NAME, instanceName));
- } else if(requestScope.equals("configuration")) {
- criteria.add (Restrictions.eq (CONFIGURATION_INSTANCE_NAME, instanceName));
- } else if(requestScope.equals("operationalEnvironment")) {
- criteria.add (Restrictions.eq (OPERATIONAL_ENV_NAME, instanceName));
- }
-
- } else {
- if(instanceIdMap != null){
- if("service".equals(requestScope) && instanceIdMap.get("serviceInstanceId") != null){
- criteria.add (Restrictions.eq (SERVICE_INSTANCE_ID, instanceIdMap.get("serviceInstanceId")));
- }
-
- if("vnf".equals(requestScope) && instanceIdMap.get("vnfInstanceId") != null){
- criteria.add (Restrictions.eq (VNF_INSTANCE_ID, instanceIdMap.get("vnfInstanceId")));
- }
-
- if("vfModule".equals(requestScope) && instanceIdMap.get("vfModuleInstanceId") != null){
- criteria.add (Restrictions.eq (VFMODULE_INSTANCE_ID, instanceIdMap.get("vfModuleInstanceId")));
- }
-
- if("volumeGroup".equals(requestScope) && instanceIdMap.get("volumeGroupInstanceId") != null){
- criteria.add (Restrictions.eq (VOLUME_GROUP_INSTANCE_ID, instanceIdMap.get("volumeGroupInstanceId")));
- }
-
- if("network".equals(requestScope) && instanceIdMap.get("networkInstanceId") != null){
- criteria.add (Restrictions.eq (NETWORK_INSTANCE_ID, instanceIdMap.get("networkInstanceId")));
- }
-
- if(requestScope.equals("configuration") && instanceIdMap.get("configurationInstanceId") != null){
- criteria.add (Restrictions.eq (CONFIGURATION_INSTANCE_ID, instanceIdMap.get("configurationInstanceId")));
- }
-
- if(requestScope.equals("operationalEnvironment") && instanceIdMap.get("operationalEnvironmentId") != null) {
- criteria.add (Restrictions.eq (OPERATIONAL_ENV_ID, instanceIdMap.get("operationalEnvironmentId")));
- }
- }
- }
-
- criteria.add (Restrictions.in ("requestStatus", new String[] { "PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK" }));
-
- Order order = Order.desc (START_TIME);
-
- List<InfraActiveRequests> dupList = executeInfraQuery(criteria, order);
-
- InfraActiveRequests infraActiveRequests = null;
-
- if(dupList != null && !dupList.isEmpty()){
- infraActiveRequests = dupList.get(0);
- }
-
- return infraActiveRequests;
- }
-
- public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive (Map<String, List<String>> orchestrationMap) {
-
-
- List <Criterion> criteria = new LinkedList <> ();
- for (Map.Entry<String, List<String>> entry : orchestrationMap.entrySet())
- {
- String mapKey = entry.getKey();
- if("serviceInstanceId".equalsIgnoreCase(mapKey)) {
- mapKey = "serviceInstanceId";
- } else if("serviceInstanceName".equalsIgnoreCase(mapKey)) {
- mapKey = "serviceInstanceName";
- } else if("vnfInstanceId".equalsIgnoreCase(mapKey)){
- mapKey = "vnfId";
- } else if("vnfInstanceName".equalsIgnoreCase(mapKey)) {
- mapKey = "vnfName";
- } else if("vfModuleInstanceId".equalsIgnoreCase(mapKey)) {
- mapKey = "vfModuleId";
- } else if("vfModuleInstanceName".equalsIgnoreCase(mapKey)) {
- mapKey = "vfModuleName";
- } else if("volumeGroupInstanceId".equalsIgnoreCase(mapKey)) {
- mapKey = "volumeGroupId";
- } else if("volumeGroupInstanceName".equalsIgnoreCase(mapKey)) {
- mapKey = "volumeGroupName";
- } else if("networkInstanceId".equalsIgnoreCase(mapKey)) {
- mapKey = "networkId";
- } else if("networkInstanceName".equalsIgnoreCase(mapKey)) {
- mapKey = "networkName";
- } else if(mapKey.equalsIgnoreCase("configurationInstanceId")) {
- mapKey = "configurationId";
- } else if(mapKey.equalsIgnoreCase("configurationInstanceName")) {
- mapKey = "configurationName";
- } else if("lcpCloudRegionId".equalsIgnoreCase(mapKey)) {
- mapKey = "aicCloudRegion";
- } else if("tenantId".equalsIgnoreCase(mapKey)) {
- mapKey = "tenantId";
- } else if("modelType".equalsIgnoreCase(mapKey)) {
- mapKey = "requestScope";
- } else if("requestorId".equalsIgnoreCase(mapKey)) {
- mapKey = "requestorId";
- } else if("requestExecutionDate".equalsIgnoreCase(mapKey)) {
- mapKey = "startTime";
- }
-
- String propertyValue = entry.getValue().get(1);
- if ("startTime".equals(mapKey)) {
- SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
- try {
- Date thisDate = format.parse(propertyValue);
- Timestamp minTime = new Timestamp(thisDate.getTime());
- Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1));
-
- if("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) {
- criteria.add(Restrictions.or(Restrictions.lt(mapKey, minTime),
- Restrictions.ge(mapKey, maxTime)));
- } else {
- criteria.add(Restrictions.between(mapKey, minTime, maxTime));
- }
- }
- catch (Exception e){
- msoLogger.debug("Exception in getOrchestrationFiltersFromInfraActive(): + " + e.getMessage(), e);
- return null;
- }
- }
- else if("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) {
- criteria.add(Restrictions.ne(mapKey, propertyValue));
- } else {
- criteria.add(Restrictions.eq(mapKey, propertyValue));
- }
-
- }
-
- Order order = Order.asc (START_TIME);
-
- return executeInfraQuery (criteria, order);
- }
-
- // Added this method for Tenant Isolation project ( 1802-295491a) to query the mso_requests DB
- // (infra_active_requests table) for operationalEnvId and OperationalEnvName
- public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive (Map<String, String> orchestrationMap) {
- List <Criterion> criteria = new LinkedList <> ();
-
- // Add criteria on OperationalEnvironment RequestScope when requestorId is only specified in the filter
- // as the same requestorId can also match on different API methods
- String resourceType = orchestrationMap.get("resourceType");
- if(resourceType == null) {
- criteria.add(Restrictions.eq("requestScope", "operationalEnvironment"));
- }
-
- for (Map.Entry<String, String> entry : orchestrationMap.entrySet()) {
- String mapKey = entry.getKey();
- if(mapKey.equalsIgnoreCase("requestorId")) {
- mapKey = "requestorId";
- } else if(mapKey.equalsIgnoreCase("requestExecutionDate")) {
- mapKey = "startTime";
- } else if(mapKey.equalsIgnoreCase("operationalEnvironmentId")) {
- mapKey = "operationalEnvId";
- } else if(mapKey.equalsIgnoreCase("operationalEnvironmentName")) {
- mapKey = "operationalEnvName";
- } else if(mapKey.equalsIgnoreCase("resourceType")) {
- mapKey = "requestScope";
- }
-
- String propertyValue = entry.getValue();
- if (mapKey.equals("startTime")) {
- SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
- try {
- Date thisDate = format.parse(propertyValue);
- Timestamp minTime = new Timestamp(thisDate.getTime());
- Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1));
-
- criteria.add(Restrictions.between(mapKey, minTime, maxTime));
- }
- catch (Exception e){
- msoLogger.debug("Exception in getCloudOrchestrationFiltersFromInfraActive(): + " + e.getMessage());
- return null;
- }
- } else {
- criteria.add(Restrictions.eq(mapKey, propertyValue));
- }
- }
-
- Order order = Order.asc (START_TIME);
- return executeInfraQuery (criteria, order);
- }
-
- public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
- String queryValue,
- String requestType) {
- msoLogger.debug ("Get list of infra requests from DB with " + queryAttributeName + " = " + queryValue);
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- try {
- session.beginTransaction ();
- Criteria crit = session.createCriteria (InfraActiveRequests.class)
- .add (Restrictions.eq (queryAttributeName, queryValue));
- crit.add (Restrictions.eqOrIsNull (REQUEST_TYPE, requestType));
- crit.addOrder (Order.desc (START_TIME));
- crit.addOrder (Order.asc (SOURCE));
-
- @SuppressWarnings("unchecked")
- List <InfraActiveRequests> arList = crit.list ();
- if (arList != null && !arList.isEmpty ()) {
- return arList;
- }
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- // msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getRequestListFromInfraActive", null);
- }
- return null;
- }
-
-
- public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Get infra request from DB with id " + requestId);
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- InfraActiveRequests ar = null;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("from InfraActiveRequests where (requestId = :requestId OR clientRequestId = :requestId) and requestType = :requestType");
- query.setParameter (REQUEST_ID, requestId);
- query.setParameter (REQUEST_TYPE, requestType);
- ar = (InfraActiveRequests) query.uniqueResult ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "getRequestFromInfraActive", null);
- }
- return ar;
- }
-
-
- public InfraActiveRequests checkDuplicateByVnfName (String vnfName, String action, String requestType) {
-
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Get infra request from DB for VNF " + vnfName + " and action " + action + " and requestType " + requestType);
-
- InfraActiveRequests ar = null;
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
-
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("from InfraActiveRequests where vnfName = :vnfName and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC");
- query.setParameter ("vnfName", vnfName);
- query.setParameter ("action", action);
- query.setParameter (REQUEST_TYPE, requestType);
- @SuppressWarnings("unchecked")
- List <InfraActiveRequests> results = query.list ();
- if (!results.isEmpty ()) {
- ar = results.get (0);
- }
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "checkDuplicateByVnfName", null);
- }
-
- return ar;
- }
-
- public InfraActiveRequests checkDuplicateByVnfId (String vnfId, String action, String requestType) {
-
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Get list of infra requests from DB for VNF " + vnfId + " and action " + action);
-
- InfraActiveRequests ar = null;
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
-
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("from InfraActiveRequests where vnfId = :vnfId and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC");
- query.setParameter ("vnfId", vnfId);
- query.setParameter ("action", action);
- query.setParameter (REQUEST_TYPE, requestType);
- @SuppressWarnings("unchecked")
- List <InfraActiveRequests> results = query.list ();
- if (!results.isEmpty ()) {
- ar = results.get (0);
- }
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "checkDuplicateByVnfId", null);
- }
-
- return ar;
- }
-
- public void setMockDB(MockRequestsDatabase mockDB) {
- RequestsDatabase.mockDB = mockDB;
- }
-
- /**
- * Fetch a specific SiteStatus by SiteName.
- *
- * @param siteName The unique name of the site
- * @return SiteStatus object or null if none found
- */
- public SiteStatus getSiteStatus (String siteName) {
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
-
- SiteStatus siteStatus = null;
- msoLogger.debug ("Request database - get Site Status with Site name:" + siteName);
- try {
- String hql = "FROM SiteStatus WHERE siteName = :site_name";
- Query query = session.createQuery (hql);
- query.setParameter ("site_name", siteName);
-
- siteStatus = (SiteStatus) query.uniqueResult ();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.debug ("getSiteStatus - Successfully: " + siteStatus);
- }
- return siteStatus;
- }
-
- /**
- * Fetch a specific SiteStatus by SiteName.
- *
- * @param siteName The unique name of the site
- * @param status The updated status of the Site
- */
- public void updateSiteStatus (String siteName, boolean status) {
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- session.beginTransaction ();
-
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Request database - save Site Status with Site name:" + siteName);
- try {
- String hql = "FROM SiteStatus WHERE siteName = :site_name";
- Query query = session.createQuery (hql);
- query.setParameter ("site_name", siteName);
-
- SiteStatus siteStatus = (SiteStatus) query.uniqueResult ();
- if (siteStatus == null) {
- siteStatus = new SiteStatus ();
- siteStatus.setSiteName (siteName);
- siteStatus.setStatus (status);
- //siteStatus.setCreated(new Timestamp(new Date().getTime()));
- session.save (siteStatus);
- } else {
- siteStatus.setStatus(status);
- //siteStatus.setCreated(new Timestamp(new Date().getTime()));
- session.merge (siteStatus);
- }
- session.getTransaction ().commit ();
- } finally {
- session.close ();
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "updateSiteStatus", null);
- }
- }
-
- /**
- * get the operation progress
- * <br>
- *
- * @param serviceId the serviceId
- * @param operationId the operation id
- * @return current progress of the operation
- * @since ONAP Amsterdam Release
- */
- public OperationStatus getOperationStatus(String serviceId, String operationId) {
-
- long startTime = System.currentTimeMillis();
- msoLogger.debug("Execute query on infra active request table");
-
- OperationStatus operStatus = null;
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- try {
- session.beginTransaction();
- String hql = "FROM OperationStatus WHERE SERVICE_ID = :service_id and OPERATION_ID = :operation_id";
- Query query = session.createQuery(hql);
- query.setParameter("service_id", serviceId);
- query.setParameter("operation_id", operationId);
- operStatus = (OperationStatus)query.uniqueResult();
-
- } finally {
- if(session != null && session.isOpen()) {
- session.close();
- }
- msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "RequestDB", "getOperationStatus", null);
- }
- return operStatus;
- }
-
- /**
- * get the operation progress
- * <br>
- *
- * @param serviceId the serviceId
- * @return current progress of the operation
- * @since ONAP Amsterdam Release
- */
- public OperationStatus getOperationStatusByServiceId(String serviceId) {
-
- long startTime = System.currentTimeMillis();
- msoLogger.debug("Execute query on infra active request table");
-
- OperationStatus operStatus = null;
- List<Object> list = null;
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- try {
- session.beginTransaction();
- String hql = "FROM OperationStatus WHERE SERVICE_ID = :service_id order by OPERATE_AT desc";
- Query query = session.createQuery(hql);
- query.setParameter("service_id", serviceId);
- list = query.list();
- if(list != null && list.size() >= 1) {
- operStatus = (OperationStatus) list.get(0);
- }
-
- } finally {
- if(session != null && session.isOpen()) {
- session.close();
- }
- msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "RequestDB", "getOperationStatus", null);
- }
- return operStatus;
- }
-
- /**
- * get the operation progress
- * <br>
- *
- * @param serviceName the serviceName
- * @return current progress of the operation
- * @since ONAP Amsterdam Release
- */
- public OperationStatus getOperationStatusByServiceName(String serviceName) {
-
- long startTime = System.currentTimeMillis();
- msoLogger.debug("Execute query on infra active request table");
-
- OperationStatus operStatus = null;
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- try {
- session.beginTransaction();
- String hql = "FROM OperationStatus WHERE SERVICE_NAME = :service_name";
- Query query = session.createQuery(hql);
- query.setParameter("service_name", serviceName);
- operStatus = (OperationStatus)query.uniqueResult();
-
- } finally {
- if(session != null && session.isOpen()) {
- session.close();
- }
- msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "RequestDB", "getOperationStatus", null);
- }
- return operStatus;
- }
-
- /**
- * update the operation status
- * <br>
- *
- * @param operstatus the operation object
- * @since ONAP Amsterdam Release
- */
- public void updateOperationStatus(OperationStatus operstatus) {
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- session.beginTransaction();
-
- long startTime = System.currentTimeMillis();
- msoLogger.debug("Request database - save Operation Status with service Id:" + operstatus.getServiceId()
- + ", operationId:" + operstatus.getOperationId());
- try {
- String hql =
- "FROM OperationStatus WHERE SERVICE_ID = :service_id and OPERATION_ID = :operation_id";
- Query query = session.createQuery(hql);
- query.setParameter("service_id", operstatus.getServiceId());
- query.setParameter("operation_id", operstatus.getOperationId());
- OperationStatus exsitingStatus = (OperationStatus)query.uniqueResult();
- if(exsitingStatus == null) {
- session.save(operstatus);
- } else {
- session.merge(operstatus);
- }
- session.getTransaction().commit();
- } finally {
- session.close();
- msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "RequestDB", "updateOperationStatus", null);
- }
- }
-
- /**
- * get a operation status of a resource
- * <br>
- *
- * @param serviceId the service Id
- * @param operationId the operation id
- * @param resourceTemplateUUID the resource template uuid
- * @return the progress status of a resource
- * @since ONAP Amsterdam Release
- */
- public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId,
- String resourceTemplateUUID) {
- long startTime = System.currentTimeMillis();
- msoLogger.debug("Execute query on infra active request table");
-
- ResourceOperationStatus operStatus = null;
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- try {
- session.beginTransaction();
- String hql =
- "FROM ResourceOperationStatus WHERE serviceId = :service_id and operationId = :operation_id and resourceTemplateUUID= :uuid";
- Query query = session.createQuery(hql);
- query.setParameter("service_id", serviceId);
- query.setParameter("operation_id", operationId);
- query.setParameter("uuid", resourceTemplateUUID);
- operStatus = (ResourceOperationStatus)query.uniqueResult();
-
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "RequestDB", "getOperationStatus", null);
- }
- return operStatus;
- }
-
- /**
- * update the resource operation
- * <br>
- *
- * @param operStatus the resource operation object
- * @since ONAP Amsterdam Release
- */
- public void updateResOperStatus(ResourceOperationStatus operStatus) {
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- session.beginTransaction();
-
- long startTime = System.currentTimeMillis();
- msoLogger.debug("Request database - save Resource Operation Status with service Id:" + operStatus.getServiceId()
- + ", operationId:" + operStatus.getOperationId() + ", resourceUUId:"
- + operStatus.getResourceTemplateUUID());
- try {
- String hql =
- "FROM ResourceOperationStatus WHERE SERVICE_ID = :service_id and OPERATION_ID = :operation_id and RESOURCE_TEMPLATE_UUID = :res_uuid";
- Query query = session.createQuery(hql);
- query.setParameter("service_id", operStatus.getServiceId());
- query.setParameter("operation_id", operStatus.getOperationId());
- query.setParameter("res_uuid", operStatus.getResourceTemplateUUID());
- ResourceOperationStatus exsitingStatus = (ResourceOperationStatus)query.uniqueResult();
- if(exsitingStatus == null) {
- session.save(operStatus);
- } else {
- session.merge(operStatus);
- }
- session.getTransaction().commit();
- } finally {
- session.close();
- msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "RequestDB", "updateResOperStatus", null);
- }
- updateOperationStatusBasedOnResourceStatus(operStatus);
- }
-
- /**
- * update service operation status when a operation resource status updated
- * <br>
- *
- * @param operStatus the resource operation status
- * @since ONAP Amsterdam Release
- */
- private void updateOperationStatusBasedOnResourceStatus(ResourceOperationStatus operStatus) {
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- session.beginTransaction();
-
- long startTime = System.currentTimeMillis();
- msoLogger.debug("Request database - query Resource Operation Status with service Id:"
- + operStatus.getServiceId() + ", operationId:" + operStatus.getOperationId());
- try {
- // query all resources of the service
- String hql = "FROM ResourceOperationStatus WHERE SERVICE_ID = :service_id and OPERATION_ID = :operation_id";
- Query query = session.createQuery(hql);
- query.setParameter("service_id", operStatus.getServiceId());
- query.setParameter("operation_id", operStatus.getOperationId());
- @SuppressWarnings("unchecked")
- List<ResourceOperationStatus> lstResourceStatus = (List<ResourceOperationStatus>)query.list();
- // count the total progress
- int resourceCount = lstResourceStatus.size();
- int progress = 0;
- boolean isFinished = true;
- for (ResourceOperationStatus lstResourceStatu : lstResourceStatus) {
- progress = progress + Integer.valueOf(lstResourceStatu.getProgress()) / resourceCount;
- if (Status.PROCESSING.equals(lstResourceStatu.getStatus())) {
- isFinished = false;
- }
- }
- OperationStatus serviceOperStatus =
- getOperationStatus(operStatus.getServiceId(), operStatus.getOperationId());
- progress = progress > 100 ? 100 : progress;
- serviceOperStatus.setProgress(String.valueOf(progress));
- serviceOperStatus.setOperationContent(operStatus.getStatusDescription());
- // if current resource failed. service failed.
- if(RequestsDbConstant.Status.ERROR.equals(operStatus.getStatus())) {
- serviceOperStatus.setResult(RequestsDbConstant.Status.ERROR);
- serviceOperStatus.setReason(operStatus.getStatusDescription());
- } else if(isFinished) {
- // if finished
- serviceOperStatus.setResult(RequestsDbConstant.Status.FINISHED);
- serviceOperStatus.setProgress(RequestsDbConstant.Progress.ONE_HUNDRED);
- }
- updateOperationStatus(serviceOperStatus);
- } finally {
- session.close();
- msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "RequestDB", "updateResOperStatus", null);
- }
- }
-
- public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Get Infra request from DB for OperationalEnvironmentId " + operationalEnvironmentId);
-
- InfraActiveRequests ar = null;
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
-
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("FROM InfraActiveRequests WHERE operationalEnvId = :operationalEnvId AND requestStatus != 'COMPLETE' AND action = 'create' ORDER BY startTime DESC");
- query.setParameter ("operationalEnvId", operationalEnvironmentId);
-
- @SuppressWarnings("unchecked")
- List <InfraActiveRequests> results = query.list ();
- if (!results.isEmpty ()) {
- ar = results.get (0);
- }
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "RequestDB", "checkDuplicateByVnfName", null);
- }
-
- return ar;
- }
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDbConstant.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDbConstant.java
deleted file mode 100644
index 18e51cef16..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDbConstant.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.requestsdb;
-
-/**
- * The constants of the request db
- * <br>
- * <p>
- * </p>
- *
- * @author
- * @version ONAP Amsterdam Release 2017-08-28
- */
-public class RequestsDbConstant {
-
- public static class Progress {
-
- public static final String ONE_HUNDRED = "100";
-
- private Progress() {
-
- }
- }
-
- public static class Status {
-
- public static final String FINISHED = "finished";
-
- public static final String PROCESSING = "processing";
-
- public static final String ERROR = "error";
-
- private Status() {
-
- }
- }
-
- public static class OperationType {
-
- public static final String CREATE = "create";
-
- public static final String DELETE = "delete";
-
- private OperationType() {
-
- }
- }
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDbSessionFactoryManager.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDbSessionFactoryManager.java
deleted file mode 100644
index 674867af65..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDbSessionFactoryManager.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.requestsdb;
-
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import java.net.URL;
-
-public class RequestsDbSessionFactoryManager extends AbstractSessionFactoryManager {
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
-
- @Override
- protected URL getHibernateConfigFile() {
- try {
-
- if ("MYSQL".equals (System.getProperty ("mso.db")) || "MARIADB".equals(System.getProperty("mso.db"))) {
- return this.getClass().getClassLoader().getResource("hibernate-requests-core-mysql.cfg.xml");
- } else {
- LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC", "", "", MsoLogger.ErrorCode.DataError , "DB Connection not specified to the JVM,choose either:-Dmso.db=MARIADB, -Dmso.db=MYSQL or -Dmso.container=AJSC");
- return null;
- }
- } catch (Exception ex) {
- LOGGER.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, ex.getMessage (), "", "", MsoLogger.ErrorCode.DataError , "Problem in getting DB connection type", ex);
- return null;
- }
-
- }
-} \ No newline at end of file
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/ResourceOperationStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/ResourceOperationStatus.java
deleted file mode 100644
index 07650ac417..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/ResourceOperationStatus.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.requestsdb;
-
-import java.io.Serializable;
-
-/**
- * The Resource operation status
- * <br>
- * <p>
- * </p>
- *
- * @author
- * @version ONAP Amsterdam Release 2017-08-28
- */
-public class ResourceOperationStatus implements Serializable{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private String serviceId = null;
-
- private String operationId = null;
-
- private String resourceTemplateUUID = null;
-
- private String operType = null;
-
- private String resourceInstanceID = null;
-
- private String jobId = null;
-
- private String status = null;
-
- private String progress = "0";
-
- private String errorCode = null;
-
- private String statusDescription = null;
-
- public ResourceOperationStatus(){
-
- }
-
- public ResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID)
- {
- this.serviceId = serviceId;
- this.operationId = operationId;
- this.resourceTemplateUUID = resourceTemplateUUID;
- }
-
- public String getServiceId() {
- return serviceId;
- }
-
-
- public void setServiceId(String serviceId) {
- this.serviceId = serviceId;
- }
-
-
- public String getOperationId() {
- return operationId;
- }
-
-
- public void setOperationId(String operationId) {
- this.operationId = operationId;
- }
-
-
- public String getResourceTemplateUUID() {
- return resourceTemplateUUID;
- }
-
-
- public void setResourceTemplateUUID(String resourceTemplateUUId) {
- this.resourceTemplateUUID = resourceTemplateUUId;
- }
-
-
- public String getJobId() {
- return jobId;
- }
-
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
-
- public String getStatus() {
- return status;
- }
-
-
- public void setStatus(String status) {
- this.status = status;
- }
-
-
- public String getProgress() {
- return progress;
- }
-
-
- public void setProgress(String progress) {
- this.progress = progress;
- }
-
-
- public String getErrorCode() {
- return errorCode;
- }
-
-
- public void setErrorCode(String errorCode) {
- this.errorCode = errorCode;
- }
-
-
- public String getStatusDescription() {
- return statusDescription;
- }
-
-
- public void setStatusDescription(String statusDescription) {
- this.statusDescription = statusDescription;
- }
-
-
-
- public String getResourceInstanceID() {
- return resourceInstanceID;
- }
-
-
-
- public void setResourceInstanceID(String resourceInstanceID) {
- this.resourceInstanceID = resourceInstanceID;
- }
-
-
- public String getOperType() {
- return operType;
- }
-
-
- public void setOperType(String operType) {
- this.operType = operType;
- }
-
- /**
- * <br>
- *
- * @return
- * @since ONAP Amsterdam Release
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((operationId == null) ? 0 : operationId.hashCode());
- result = prime * result + ((resourceTemplateUUID == null) ? 0 : resourceTemplateUUID.hashCode());
- result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
- return result;
- }
-
- /**
- * <br>
- *
- * @param obj
- * @return
- * @since ONAP Amsterdam Release
- */
- @Override
- public boolean equals(Object obj) {
- if(this == obj)
- return true;
- if(obj == null)
- return false;
- if(getClass() != obj.getClass())
- return false;
- ResourceOperationStatus other = (ResourceOperationStatus)obj;
- if(operationId == null) {
- if(other.operationId != null)
- return false;
- } else if(!operationId.equals(other.operationId))
- return false;
- if(resourceTemplateUUID == null) {
- if(other.resourceTemplateUUID != null)
- return false;
- } else if(!resourceTemplateUUID.equals(other.resourceTemplateUUID))
- return false;
- if(serviceId == null) {
- if(other.serviceId != null)
- return false;
- } else if(!serviceId.equals(other.serviceId))
- return false;
- return true;
- }
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java
deleted file mode 100644
index 3685093740..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/SiteStatus.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-
-import org.openecomp.mso.logger.MsoLogger;
-
-import java.sql.Timestamp;
-
-
-public class SiteStatus {
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL);
-
- private boolean status;
- private String siteName = null;
- private Timestamp created = null;
-
- public SiteStatus() {
- }
-
- public Timestamp getCreated() {
- return created;
- }
-
- public void setCreated(Timestamp created) {
- this.created = created;
- }
-
- public String getSiteName() {
- return siteName;
- }
-
- public void setSiteName(String siteName) {
- this.siteName = siteName;
- }
-
- public void setStatus(boolean status) {
- this.status = status;
- }
-
- public boolean getStatus() {
- return status;
- }
-
- @Override
- public String toString() {
- return "SiteStatus{" +
- "status=" + status +
- ", siteName='" + siteName + '\'' +
- ", created=" + created +
- '}';
- }
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java
deleted file mode 100644
index 8f2bda3728..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatus.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-public class WatchdogComponentDistributionStatus implements Serializable {
-
-
- /**
- * Serialization id.
- */
- private static final long serialVersionUID = -4344508954204488669L;
-
- private String distributionId = null;
- private String componentName = null;
- private String componentDistributionStatus = null;
- private Timestamp createTime = null;
- private Timestamp modifyTime = null;
-
-
- public String getDistributionId() {
- return distributionId;
- }
-
- public void setDistributionId(String distributionId) {
- this.distributionId = distributionId;
- }
-
- public String getComponentName() {
- return componentName;
- }
-
- public void setComponentName(String componentName) {
- this.componentName = componentName;
- }
-
- public String getComponentDistributionStatus() {
- return componentDistributionStatus;
- }
-
- public void setComponentDistributionStatus(String componentDistributionStatus) {
- this.componentDistributionStatus = componentDistributionStatus;
- }
-
- public Timestamp getCreateTime() {
- return createTime;
- }
- public void setCreateTime(Timestamp createTime) {
- this.createTime = createTime;
- }
-
- public Timestamp getModifyTime() {
- return modifyTime;
- }
-
- public void setModifyTime(Timestamp modifyTime) {
- this.modifyTime = modifyTime;
- }
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDb.java
deleted file mode 100644
index 10114348a0..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogComponentDistributionStatusDb.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class WatchdogComponentDistributionStatusDb {
-
- protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
-
- protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
-
-
- protected static final String DISTRIBUTION_ID = "distributionId";
- protected static final String COMPONENT_NAME = "componentName";
- protected static final String COMPONENT_DISTRIBUTION_STATUS = "componentDistributionIdStatus";
- protected static final String CREATE_TIME = "startTime";
- protected static final String MODIFY_TIME = "modifyTime";
-
-
- public static WatchdogComponentDistributionStatusDb getInstance() {
- return new WatchdogComponentDistributionStatusDb(new RequestsDbSessionFactoryManager ());
- }
-
- protected WatchdogComponentDistributionStatusDb (AbstractSessionFactoryManager sessionFactoryRequest) {
- sessionFactoryRequestDB = sessionFactoryRequest;
- }
-
-
- /**
- * Insert into watchdog_per_component_distribution_status.
- *
- * @param distributionId
- * @param componentName
- * @param componentDistributionStatus
- * @return void
- */
- public void insertWatchdogComponentDistributionStatus(String distributionId, String componentName, String componentDistributionStatus ) {
- long startTime = System.currentTimeMillis ();
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
- msoLogger.debug ("Insert into WatchdogPerComponentDistributionStatus for DistributionId: " + distributionId + " ComponentName: " + componentName + " and ComponentDistributionStatus: " + componentDistributionStatus);
-
- List<WatchdogComponentDistributionStatus> componentList = getWatchdogComponentDistributionStatus(distributionId, componentName);
-
- if((componentList == null) || componentList.isEmpty())
- {
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- WatchdogComponentDistributionStatus wdcds = new WatchdogComponentDistributionStatus ();
-
- try {
- session.beginTransaction ();
-
- wdcds.setDistributionId (distributionId);
- wdcds.setComponentName (componentName);
- wdcds.setComponentDistributionStatus (componentDistributionStatus);
- wdcds.setCreateTime (startTimeStamp);
- Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- wdcds.setModifyTime (modifyTimeStamp);
-
- msoLogger.debug ("About to insert a record into WatchdogPerComponentDistributionStatus");
-
- session.save (wdcds);
- session.getTransaction ().commit ();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertWatchdogComponentDistributionStatus", e);
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "WatchdogComponentDistributionStatusDB", "saveRequest", null);
- if (session != null) {
- session.close ();
- }
- // throw an Exception in the event of a DB insert failure so that the calling routine can exit
- throw e;
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "WatchdogComponentDistributionStatusDB", "insertWatchdogComponentDistributionStatus", null);
- }
- }
-
- }
-
- /**
- * Retrieve records from WatchdogComponentDistributionStatus.
- *
- * @param distributionId
- * @return WatchdogComponentDistributionStatus
- */
- @SuppressWarnings("unchecked")
- public List<WatchdogComponentDistributionStatus> getWatchdogComponentDistributionStatus(String distributionId) {
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- session.beginTransaction();
-
- List<WatchdogComponentDistributionStatus> results = new ArrayList<WatchdogComponentDistributionStatus>();
- msoLogger.debug("Request database - getWatchdogComponentDistributionStatus:" + distributionId);
- try {
- String hql = "FROM WatchdogComponentDistributionStatus WHERE distributionId = :distributionId";
- Query query = session.createQuery(hql);
- query.setParameter("distributionId", distributionId);
- results = query.list();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.debug ("getWatchdogComponentDistributionStatus - Successfully");
- }
- return results;
- }
-
- /**
- * Retrieve records from WatchdogComponentDistributionStatus.
- *
- * @param distributionId
- * @param componentName
- * @return WatchdogComponentDistributionStatus
- */
- @SuppressWarnings("unchecked")
- public List<WatchdogComponentDistributionStatus> getWatchdogComponentDistributionStatus(String distributionId, String componentName) {
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- session.beginTransaction();
-
- List<WatchdogComponentDistributionStatus> results = new ArrayList<WatchdogComponentDistributionStatus>();
- msoLogger.debug("Request database - getWatchdogComponentDistributionStatus:" + distributionId + " and componentName:" + componentName);
- try {
- String hql = "FROM WatchdogComponentDistributionStatus WHERE distributionId = :distributionId AND componentName = :componentName";
- Query query = session.createQuery(hql);
- query.setParameter("distributionId", distributionId);
- query.setParameter("componentName", componentName);
- results = query.list();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.debug ("getWatchdogComponentDistributionStatus by ComponentName - Successfully");
- }
- return results;
- }
-
- /**
- * Retrieve records from getWatchdogComponentNames.
- *
- * @param distributionId
- * @return String
- */
- @SuppressWarnings("unchecked")
- public List<String> getWatchdogComponentNames(String distributionId) {
- Session session = sessionFactoryRequestDB.getSessionFactory().openSession();
- session.beginTransaction();
-
- List<String> results = new ArrayList<String>();
- msoLogger.debug("Request database - getWatchdogComponentNames:" + distributionId);
- try {
- String hql = "Select componentName FROM WatchdogComponentDistributionStatus WHERE distributionId = :distributionId";
- Query query = session.createQuery(hql);
- query.setParameter("distributionId", distributionId);
- results = query.list();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.debug ("getWatchdogComponentNames - Successfully");
- }
- return results;
- }
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java
deleted file mode 100644
index deb2b6824d..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatus.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-public class WatchdogDistributionStatus implements Serializable {
-
- /**
- * Serialization id.
- */
- private static final long serialVersionUID = -4449711060885719079L;
-
-
- private String distributionId = null;
- private String distributionIdStatus = null;
- private Timestamp createTime = null;
- private Timestamp modifyTime = null;
-
-
- public String getDistributionId() {
- return distributionId;
- }
-
- public void setDistributionId(String distributionId) {
- this.distributionId = distributionId;
- }
-
- public String getDistributionIdStatus() {
- return distributionIdStatus;
- }
-
- public void setDistributionIdStatus(String distributionIdStatus) {
- this.distributionIdStatus = distributionIdStatus;
- }
-
- public Timestamp getCreateTime() {
- return createTime;
- }
- public void setCreateTime(Timestamp createTime) {
- this.createTime = createTime;
- }
-
- public Timestamp getModifyTime() {
- return modifyTime;
- }
-
- public void setModifyTime(Timestamp modifyTime) {
- this.modifyTime = modifyTime;
- }
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDb.java
deleted file mode 100644
index f1fab18df0..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogDistributionStatusDb.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-
-import java.sql.Timestamp;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class WatchdogDistributionStatusDb {
-
- protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
-
- protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
-
-
- protected static final String DISTRIBUTION_ID = "distributionId";
- protected static final String DISTRIBUTION_ID_STATUS = "distributionIdStatus";
- protected static final String CREATE_TIME = "startTime";
- protected static final String MODIFY_TIME = "modifyTime";
-
-
- public static WatchdogDistributionStatusDb getInstance() {
- return new WatchdogDistributionStatusDb(new RequestsDbSessionFactoryManager ());
- }
-
- protected WatchdogDistributionStatusDb (AbstractSessionFactoryManager sessionFactoryRequest) {
- sessionFactoryRequestDB = sessionFactoryRequest;
- }
-
-
- /**
- * Insert into WATCHDOG_DISTRIBUTIONID_STATUS.
- *
- * @param distributionId
- * @return void
- */
- public void insertWatchdogDistributionId(String distributionId ) {
- long startTime = System.currentTimeMillis ();
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
- msoLogger.debug ("Insert into WatchdogDistributionStatus - DistributionId: " + distributionId);
-
- if(getWatchdogDistributionId(distributionId) == null){
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- WatchdogDistributionStatus wds = new WatchdogDistributionStatus ();
-
- try {
- session.beginTransaction ();
-
- wds.setDistributionId (distributionId);
- wds.setCreateTime (startTimeStamp);
- Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- wds.setModifyTime (modifyTimeStamp);
-
- msoLogger.debug ("About to insert a record into WatchdogDistributionStatus ");
-
- session.save (wds);
- session.getTransaction ().commit ();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertWatchdogDistributionId", e);
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "WatchdogDistributionStatusDB", "saveRequest", null);
- if (session != null) {
- session.close ();
- }
- // throw an Exception in the event of a DB insert failure so that the calling routine can exit
- throw e;
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "WatchdogDistributionStatusDB", "insertWatchdogDistributionId", null);
- }
-
- }
-
- }
-
-
- /**
- * Update WATCHDOG_DISTRIBUTIONID_STATUS with new status for a given distributionid.
- *
- * @param distributionId
- * @param distributionStatus
- * @return void
- */
- public void updateWatchdogDistributionIdStatus(String distributionId, String distributionIdStatus ) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Update WatchdogDistributionStatus status with distributionId: " + distributionId + " and distributionStatus: " + distributionIdStatus );
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
-
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("update WatchdogDistributionStatus set distributionIdStatus = :distributionIdStatus where "
- + "distributionId = :distributionId ");
-
- query.setParameter ("distributionId", distributionId);
- query.setParameter ("distributionIdStatus", distributionIdStatus);
-
- //Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
- //query.setParameter ("modifyTime", modifyTimeStamp);
- query.executeUpdate ();
- session.getTransaction ().commit ();
-
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in updateWatchdogDistributionStatus", e);
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "WatchdogDistributionStatusDB", "saveRequest", null);
- if (session != null) {
- session.close ();
- }
- // throw an Exception in the event of a DB insert failure so that the calling routine can exit
- throw e;
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "WatchdogDistributionStatusDB", "insertWatchdogDistributionStatus", null);
- }
- }
-
- /**
- * Retrieve records from WatchdogDistributionIdStatus.
- *
- * @param distributionId
- * @return WatchdogDistributionIdStatus
- */
- public String getWatchdogDistributionIdStatus(String distributionId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Retrieve records from WatchdogDistributionStatus for distributionId : " + distributionId );
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- String distributionStatus = null;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("SELECT distributionIdStatus FROM WatchdogDistributionStatus WHERE distributionId = :distributionId ");
- query.setParameter ("distributionId", distributionId);
- distributionStatus = (String) query.uniqueResult();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "WatchdogDistributionStatusDB", "getWatchdogDistributionIdStatus", null);
- }
- return distributionStatus;
- }
-
- /**
- * Retrieve records from WatchdogDistributionId.
- *
- * @param distributionId
- * @return WatchdogDistributionIdStatus
- */
- public String getWatchdogDistributionId(String distributionId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Retrieve distributionId from WatchdogDistributionStatus for distributionId : " + distributionId );
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- String existingDistributionId = null;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("SELECT distributionId FROM WatchdogDistributionStatus WHERE distributionId = :distributionId ");
- query.setParameter ("distributionId", distributionId);
- existingDistributionId = (String) query.uniqueResult();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "WatchdogDistributionStatusDB", "getWatchdogDistributionIdStatus", null);
- }
- return existingDistributionId;
- }
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java
deleted file mode 100644
index ced4f4f0a5..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookup.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-public class WatchdogServiceModVerIdLookup implements Serializable {
-
- /**
- * Serialization id.
- */
- private static final long serialVersionUID = 7783869906430250355L;
-
- private String distributionId = null;
- private String serviceModelVersionId = null;
- private Timestamp createTime = null;
-
-
- public String getDistributionId() {
- return distributionId;
- }
-
- public void setDistributionId(String distributionId) {
- this.distributionId = distributionId;
- }
-
- public String getServiceModelVersionId() {
- return serviceModelVersionId;
- }
-
- public void setServiceModelVersionId(String serviceModelVersionId) {
- this.serviceModelVersionId = serviceModelVersionId;
- }
-
- public Timestamp getCreateTime() {
- return createTime;
- }
- public void setCreateTime(Timestamp createTime) {
- this.createTime = createTime;
- }
-
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDb.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDb.java
deleted file mode 100644
index f081bbf55c..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/WatchdogServiceModVerIdLookupDb.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb;
-
-
-import java.sql.Timestamp;
-
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.openecomp.mso.db.AbstractSessionFactoryManager;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-public class WatchdogServiceModVerIdLookupDb {
-
- protected final AbstractSessionFactoryManager sessionFactoryRequestDB;
-
- protected static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL);
-
- protected static final String DISTRIBUTION_ID = "distributionId";
- protected static final String SERVICE_MODEL_VERSION_ID = "serviceModelVersionId";
- protected static final String CREATE_TIME = "startTime";
-
-
- public static WatchdogServiceModVerIdLookupDb getInstance() {
- return new WatchdogServiceModVerIdLookupDb(new RequestsDbSessionFactoryManager ());
- }
-
- protected WatchdogServiceModVerIdLookupDb (AbstractSessionFactoryManager sessionFactoryRequest) {
- sessionFactoryRequestDB = sessionFactoryRequest;
- }
-
-
- /**
- * Insert into WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP.
- *
- * @param distributionId
- * @param serviceModelVersionId
- * @return void
- */
- public void insertWatchdogServiceModVerIdLookup(String distributionId, String serviceModelVersionId ) {
- long startTime = System.currentTimeMillis ();
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
- msoLogger.debug ("Insert into WatchdogServiceModVerIdLookup for DistributionId: " + distributionId + " and ServiceModelVersionId: " + serviceModelVersionId );
-
- if(getWatchdogServiceModVerId(distributionId) == null){
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- WatchdogServiceModVerIdLookup wdsm = new WatchdogServiceModVerIdLookup ();
-
- try {
- session.beginTransaction ();
-
- wdsm.setDistributionId (distributionId);
- wdsm.setServiceModelVersionId (serviceModelVersionId);
- wdsm.setCreateTime (startTimeStamp);
-
- msoLogger.debug ("About to insert a record into WatchdogServiceModVerIdLookup");
-
- session.save (wdsm);
- session.getTransaction ().commit ();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in insertWatchdogServiceModVerIdLookup", e);
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, e.getMessage (), "WatchdogServiceModVerIdLookupDB", "saveRequest", null);
- if (session != null) {
- session.close ();
- }
- // throw an Exception in the event of a DB insert failure so that the calling routine can exit
- throw e;
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully", "WatchdogServiceModVerIdLookupDB", "insertWatchdogServiceModVerIdLookup", null);
- }
- }
-
- }
-
- /**
- * Retrieve from WATCHDOG_SERVICE_MOD_VER_ID_LOOKUP.
- *
- * @param distributionId
- * @return WatchdogServiceModVerIdLookup
- */
- public String getWatchdogServiceModVerId(String distributionId) {
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("Retrieve WatchdogServiceModVerIdLookup with distributionId: " + distributionId );
-
- Session session = sessionFactoryRequestDB.getSessionFactory ().openSession ();
- String serviceModelVersionId = null;
- try {
- session.beginTransaction ();
- Query query = session.createQuery ("Select serviceModelVersionId FROM WatchdogServiceModVerIdLookup WHERE distributionId = :distributionId ");
- query.setParameter ("distributionId", distributionId);
- serviceModelVersionId = (String) query.uniqueResult();
- } finally {
- if (session != null && session.isOpen ()) {
- session.close ();
- }
- msoLogger.recordMetricEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully", "WatchdogServiceModVerIdLookupDB", "getWatchdogServiceModVerId", null);
- }
- return serviceModelVersionId;
- }
-}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapter.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapter.java
deleted file mode 100644
index 37ea2924a3..0000000000
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/adapter/TimestampXMLAdapter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.requestsdb.adapter;
-
-
-import java.sql.Timestamp;
-
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-
-public class TimestampXMLAdapter extends XmlAdapter <Long, Timestamp> {
-
- @Override
- public Long marshal (Timestamp v) throws Exception {
- return v.getTime ();
- }
-
- @Override
- public Timestamp unmarshal (Long v) throws Exception {
- if (v == null) {
- return new Timestamp(0);
- }
- return new Timestamp (v);
- }
-}