From ae993816c1dbe800dffe0c9e0dada126a57860e6 Mon Sep 17 00:00:00 2001 From: Eoin Hanan Date: Wed, 16 Jan 2019 16:30:32 +0000 Subject: Added CorsConfigurer class and cleaned up typos Change-Id: If133419e4ddb7aa4b8b0a199a57e1eaf9a8386c7 Issue-ID: SO-1335 Signed-off-by: Eoin Hanan --- .../monitoring/camunda/model/ActivityInstance.java | 188 ++++++++++++++++++++ .../camunda/model/ProcessDefinition.java | 88 +++++++++ .../monitoring/camunda/model/ProcessInstance.java | 129 ++++++++++++++ .../camunda/model/ProcessInstanceVariable.java | 106 +++++++++++ .../camunda/model/SoActiveInfraRequests.java | 196 +++++++++++++++++++++ .../camunda/CamundaConfiguration.java | 38 ++++ .../camunda/CamundaRestUrlProvider.java | 106 +++++++++++ .../database/DatabaseConfiguration.java | 37 ++++ .../database/DatabaseUrlProvider.java | 48 +++++ .../BasicAuthorizationHttpRequestInterceptor.java | 49 ++++++ .../configuration/rest/CorsConfigurer.java | 52 ++++++ .../rest/HttpClientConnectionConfiguration.java | 87 +++++++++ .../rest/HttpServiceProviderConfiguration.java | 73 ++++++++ .../rest/RestTemplateConfiguration.java | 85 +++++++++ .../db/service/DatabaseServiceProvider.java | 36 ++++ .../db/service/DatabaseServiceProviderImpl.java | 89 ++++++++++ .../exception/InvalidRestRequestException.java | 36 ++++ .../exception/RestProcessingException.java | 37 ++++ .../monitoring/model/ActivityInstanceDetail.java | 192 ++++++++++++++++++++ .../monitoring/model/ProcessDefinitionDetail.java | 76 ++++++++ .../so/monitoring/model/ProcessInstanceDetail.java | 103 +++++++++++ .../monitoring/model/ProcessInstanceIdDetail.java | 66 +++++++ .../model/ProcessInstanceVariableDetail.java | 84 +++++++++ .../onap/so/monitoring/model/SoInfraRequest.java | 132 ++++++++++++++ .../so/monitoring/model/SoInfraRequestBuilder.java | 148 ++++++++++++++++ .../service/CamundaProcessDataServiceProvider.java | 47 +++++ .../CamundaProcessDataServiceProviderImpl.java | 179 +++++++++++++++++++ .../rest/service/HttpRestServiceProvider.java | 33 ++++ .../rest/service/HttpRestServiceProviderImpl.java | 119 +++++++++++++ .../so/monitoring/utils/ObjectEqualsUtils.java | 36 ++++ .../montoring/camunda/model/ActivityInstance.java | 188 -------------------- .../montoring/camunda/model/ProcessDefinition.java | 88 --------- .../montoring/camunda/model/ProcessInstance.java | 129 -------------- .../camunda/model/ProcessInstanceVariable.java | 106 ----------- .../camunda/model/SoActiveInfraRequests.java | 196 --------------------- .../camunda/CamundaConfiguration.java | 38 ---- .../camunda/CamundaRestUrlProvider.java | 106 ----------- .../database/DatabaseConfiguration.java | 37 ---- .../database/DatabaseUrlProvider.java | 48 ----- .../BasicAuthorizationHttpRequestInterceptor.java | 49 ------ .../rest/HttpClientConnectionConfiguration.java | 87 --------- .../rest/HttpServiceProviderConfiguration.java | 73 -------- .../rest/RestTemplateConfigration.java | 85 --------- .../db/service/DatabaseServiceProvider.java | 36 ---- .../db/service/DatabaseServiceProviderImpl.java | 89 ---------- .../exception/InvalidRestRequestException.java | 36 ---- .../exception/RestProcessingException.java | 37 ---- .../so/montoring/model/ActivityInstanceDetail.java | 192 -------------------- .../montoring/model/ProcessDefinitionDetail.java | 76 -------- .../so/montoring/model/ProcessInstanceDetail.java | 103 ----------- .../montoring/model/ProcessInstanceIdDetail.java | 66 ------- .../model/ProcessInstanceVariableDetail.java | 84 --------- .../onap/so/montoring/model/SoInfraRequest.java | 132 -------------- .../so/montoring/model/SoInfraRequestBuilder.java | 148 ---------------- .../service/CamundaProcessDataServiceProvider.java | 47 ----- .../CamundaProcessDataServiceProviderImpl.java | 179 ------------------- .../rest/service/HttpRestServiceProvider.java | 33 ---- .../rest/service/HttpRestServiceProviderImpl.java | 119 ------------- .../onap/so/montoring/utils/ObjectEqualsUtils.java | 36 ---- .../configuration/CamundaConfigurationTest.java | 6 +- .../configuration/CamundaRestUrlProviderTest.java | 4 +- .../HttpServiceProviderConfigurationTest.java | 6 +- .../montoring/configuration/PojoClassesTests.java | 10 +- .../database/DatabaseUrlProviderTest.java | 2 +- .../db/api/DatabaseServiceProviderTest.java | 14 +- .../CamundaProcessDataServiceProviderTest.java | 20 +-- .../so/montoring/utils/ObjectEqualsUtilsTest.java | 2 +- .../rest/api/SoMonitoringController.java | 20 +-- .../rest/api/SoMonitoringControllerTest.java | 14 +- 69 files changed, 2744 insertions(+), 2692 deletions(-) create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ActivityInstance.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessDefinition.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessInstance.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessInstanceVariable.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/SoActiveInfraRequests.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/camunda/CamundaConfiguration.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/camunda/CamundaRestUrlProvider.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/database/DatabaseConfiguration.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/database/DatabaseUrlProvider.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpClientConnectionConfiguration.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpServiceProviderConfiguration.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/RestTemplateConfiguration.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProvider.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProviderImpl.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/InvalidRestRequestException.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/RestProcessingException.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ActivityInstanceDetail.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessDefinitionDetail.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceDetail.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceIdDetail.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceVariableDetail.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/SoInfraRequest.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/SoInfraRequestBuilder.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProvider.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderImpl.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProvider.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProviderImpl.java create mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/utils/ObjectEqualsUtils.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ActivityInstance.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessDefinition.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessInstance.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessInstanceVariable.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/SoActiveInfraRequests.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/camunda/CamundaConfiguration.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/camunda/CamundaRestUrlProvider.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/database/DatabaseConfiguration.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/database/DatabaseUrlProvider.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/HttpClientConnectionConfiguration.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/HttpServiceProviderConfiguration.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/RestTemplateConfigration.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/db/service/DatabaseServiceProvider.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/db/service/DatabaseServiceProviderImpl.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/exception/InvalidRestRequestException.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/exception/RestProcessingException.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ActivityInstanceDetail.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessDefinitionDetail.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceDetail.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceIdDetail.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceVariableDetail.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/SoInfraRequest.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/SoInfraRequestBuilder.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProvider.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProviderImpl.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/HttpRestServiceProvider.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/HttpRestServiceProviderImpl.java delete mode 100644 so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/utils/ObjectEqualsUtils.java diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ActivityInstance.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ActivityInstance.java new file mode 100644 index 0000000000..f92d9fcbfe --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ActivityInstance.java @@ -0,0 +1,188 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.camunda.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * @author waqas.ikram@ericsson.com + * + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ActivityInstance { + + private String activityId; + private String activityName; + private String activityType; + private String processInstanceId; + private String calledProcessInstanceId; + private String startTime; + private String endTime; + private String durationInMillis; + + public ActivityInstance() {} + + + /** + * @return the activityId + */ + public String getActivityId() { + return activityId; + } + + /** + * @param activityId the activityId to set + */ + public void setActivityId(final String activityId) { + this.activityId = activityId; + } + + /** + * @return the activityName + */ + public String getActivityName() { + return activityName; + } + + /** + * @param activityName the activityName to set + */ + public void setActivityName(final String activityName) { + this.activityName = activityName; + } + + /** + * @return the activityType + */ + public String getActivityType() { + return activityType; + } + + /** + * @param activityType the activityType to set + */ + public void setActivityType(final String activityType) { + this.activityType = activityType; + } + + /** + * @return the processInstanceId + */ + public String getProcessInstanceId() { + return processInstanceId; + } + + /** + * @param processInstanceId the processInstanceId to set + */ + public void setProcessInstanceId(final String processInstanceId) { + this.processInstanceId = processInstanceId; + } + + /** + * @return the calledProcessInstanceId + */ + public String getCalledProcessInstanceId() { + return calledProcessInstanceId; + } + + /** + * @param calledProcessInstanceId the calledProcessInstanceId to set + */ + public void setCalledProcessInstanceId(final String calledProcessInstanceId) { + this.calledProcessInstanceId = calledProcessInstanceId; + } + + /** + * @return the startTime + */ + public String getStartTime() { + return startTime; + } + + /** + * @param startTime the startTime to set + */ + public void setStartTime(final String startTime) { + this.startTime = startTime; + } + + /** + * @return the endTime + */ + public String getEndTime() { + return endTime; + } + + /** + * @param endTime the endTime to set + */ + public void setEndTime(final String endTime) { + this.endTime = endTime; + } + + /** + * @return the durationInMillis + */ + public String getDurationInMillis() { + return durationInMillis; + } + + /** + * @param durationInMillis the durationInMillis to set + */ + public void setDurationInMillis(final String durationInMillis) { + this.durationInMillis = durationInMillis; + } + + @JsonIgnore + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((activityId == null) ? 0 : activityId.hashCode()); + result = prime * result + ((activityName == null) ? 0 : activityName.hashCode()); + result = prime * result + ((activityType == null) ? 0 : activityType.hashCode()); + result = prime * result + ((calledProcessInstanceId == null) ? 0 : calledProcessInstanceId.hashCode()); + result = prime * result + ((durationInMillis == null) ? 0 : durationInMillis.hashCode()); + result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); + result = prime * result + ((processInstanceId == null) ? 0 : processInstanceId.hashCode()); + result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); + return result; + } + + @JsonIgnore + @Override + public boolean equals(final Object obj) { + if (obj instanceof ActivityInstance) { + final ActivityInstance other = (ActivityInstance) obj; + return isEqual(activityId, other.activityId) && isEqual(activityName, other.activityName) + && isEqual(activityType, other.activityType) && isEqual(processInstanceId, other.processInstanceId) + && isEqual(calledProcessInstanceId, other.calledProcessInstanceId) + && isEqual(startTime, other.startTime) && isEqual(endTime, other.endTime) + && isEqual(durationInMillis, other.durationInMillis); + } + return false; + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessDefinition.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessDefinition.java new file mode 100644 index 0000000000..c38cbcf5c3 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessDefinition.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.camunda.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * @author waqas.ikram@ericsson.com + * + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProcessDefinition { + + private String id; + private String bpmn20Xml; + + public ProcessDefinition() {} + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(final String id) { + this.id = id; + } + + /** + * @return the bpmn20Xml + */ + public String getBpmn20Xml() { + return bpmn20Xml; + } + + /** + * @param bpmn20Xml the bpmn20Xml to set + */ + public void setBpmn20Xml(final String bpmn20Xml) { + this.bpmn20Xml = bpmn20Xml; + } + + @JsonIgnore + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((bpmn20Xml == null) ? 0 : bpmn20Xml.hashCode()); + return result; + } + + @JsonIgnore + @Override + public boolean equals(final Object obj) { + if (obj instanceof ProcessDefinition) { + final ProcessDefinition other = (ProcessDefinition) obj; + return isEqual(id, other.id) && isEqual(bpmn20Xml, other.bpmn20Xml); + } + return false; + } + + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessInstance.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessInstance.java new file mode 100644 index 0000000000..0a2db7dea7 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessInstance.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.camunda.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * @author waqas.ikram@ericsson.com + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ProcessInstance { + + private String id; + private String processDefinitionId; + private String processDefinitionName; + private String superProcessInstanceId; + + public ProcessInstance() {} + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(final String id) { + this.id = id; + } + + + /** + * @return the processDefinitionId + */ + public String getProcessDefinitionId() { + return processDefinitionId; + } + + /** + * @param processDefinitionId the processDefinitionId to set + */ + public void setProcessDefinitionId(final String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + } + + /** + * @return the processDefinitionName + */ + public String getProcessDefinitionName() { + return processDefinitionName; + } + + /** + * @param processDefinitionName the processDefinitionName to set + */ + public void setProcessDefinitionName(final String processDefinitionName) { + this.processDefinitionName = processDefinitionName; + } + + /** + * @return the superProcessInstanceId + */ + public String getSuperProcessInstanceId() { + return superProcessInstanceId; + } + + /** + * @param superProcessInstanceId the superProcessInstanceId to set + */ + public void setSuperProcessInstanceId(final String superProcessInstanceId) { + this.superProcessInstanceId = superProcessInstanceId; + } + + + @JsonIgnore + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((processDefinitionId == null) ? 0 : processDefinitionId.hashCode()); + result = prime * result + ((processDefinitionName == null) ? 0 : processDefinitionName.hashCode()); + result = prime * result + ((superProcessInstanceId == null) ? 0 : superProcessInstanceId.hashCode()); + return result; + } + + @JsonIgnore + @Override + public boolean equals(final Object obj) { + if (obj instanceof ProcessInstance) { + final ProcessInstance other = (ProcessInstance) obj; + return isEqual(id, other.id) && isEqual(processDefinitionId, other.processDefinitionId) + && isEqual(processDefinitionName, other.processDefinitionName) + && isEqual(superProcessInstanceId, other.superProcessInstanceId); + } + + return false; + } + + @JsonIgnore + @Override + public String toString() { + return "ProcessInstance [id=" + id + ", processDefinitionId=" + processDefinitionId + ", processDefinitionName=" + + processDefinitionName + "]"; + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessInstanceVariable.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessInstanceVariable.java new file mode 100644 index 0000000000..4154133cce --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/ProcessInstanceVariable.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.camunda.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * @author waqas.ikram@ericsson.com + */ +public class ProcessInstanceVariable { + + private String name; + private Object value; + private String type; + + public ProcessInstanceVariable() {} + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(final String name) { + this.name = name; + } + + /** + * @return the value + */ + public Object getValue() { + return value; + } + + /** + * @param value the value to set + */ + public void setValue(final Object value) { + this.value = value; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(final String type) { + this.type = type; + } + + @JsonIgnore + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @JsonIgnore + @Override + public boolean equals(final Object obj) { + if (obj instanceof ProcessInstanceVariable) { + final ProcessInstanceVariable other = (ProcessInstanceVariable) obj; + return isEqual(name, other.name) && isEqual(value, other.value) && isEqual(type, other.type); + } + + return false; + } + + @JsonIgnore + @Override + public String toString() { + return "ProcessInstance [name=" + name + ", value=" + value + ", type=" + type + "]"; + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/SoActiveInfraRequests.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/SoActiveInfraRequests.java new file mode 100644 index 0000000000..124101a999 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/camunda/model/SoActiveInfraRequests.java @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.camunda.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * @author waqas.ikram@ericsson.com + * + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class SoActiveInfraRequests { + + private String requestId; + private String serviceInstanceId; + private String networkId; + private String startTime; + private String endTime; + private String requestStatus; + private String serviceInstanceName; + private String serviceType; + + /** + * @return the requestId + */ + public String getRequestId() { + return requestId; + } + + /** + * @param requestId the requestId to set + */ + public void setRequestId(final String requestId) { + this.requestId = requestId; + } + + /** + * @return the serviceInstanceId + */ + public String getServiceInstanceId() { + return serviceInstanceId; + } + + /** + * @param serviceInstanceId the serviceInstanceId to set + */ + public void setServiceInstanceId(final String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + /** + * @return the networkId + */ + public String getNetworkId() { + return networkId; + } + + /** + * @param networkId the networkId to set + */ + public void setNetworkId(final String networkId) { + this.networkId = networkId; + } + + /** + * @return the startTime + */ + public String getStartTime() { + return startTime; + } + + /** + * @param startTime the startTime to set + */ + public void setStartTime(final String startTime) { + this.startTime = startTime; + } + + /** + * @return the endTime + */ + public String getEndTime() { + return endTime; + } + + /** + * @param endTime the endTime to set + */ + public void setEndTime(final String endTime) { + this.endTime = endTime; + } + + /** + * @return the requestStatus + */ + public String getRequestStatus() { + return requestStatus; + } + + /** + * @param requestStatus the requestStatus to set + */ + public void setRequestStatus(final String requestStatus) { + this.requestStatus = requestStatus; + } + + /** + * @return the serviceInstanceName + */ + public String getServiceInstanceName() { + return serviceInstanceName; + } + + /** + * @param serviceInstanceName the serviceInstanceName to set + */ + public void setServiceInstanceName(final String serviceInstanceName) { + this.serviceInstanceName = serviceInstanceName; + } + + /** + * @return the serviceType + */ + public String getServiceType() { + return serviceType; + } + + /** + * @param serviceType the serviceType to set + */ + public void setServiceType(final String serviceType) { + this.serviceType = serviceType; + } + + @JsonIgnore + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); + result = prime * result + ((networkId == null) ? 0 : networkId.hashCode()); + result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); + result = prime * result + ((requestStatus == null) ? 0 : requestStatus.hashCode()); + result = prime * result + ((serviceInstanceId == null) ? 0 : serviceInstanceId.hashCode()); + result = prime * result + ((serviceInstanceName == null) ? 0 : serviceInstanceName.hashCode()); + result = prime * result + ((serviceType == null) ? 0 : serviceType.hashCode()); + result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); + return result; + } + + @JsonIgnore + @Override + public boolean equals(final Object obj) { + if (obj instanceof SoActiveInfraRequests) { + SoActiveInfraRequests other = (SoActiveInfraRequests) obj; + return isEqual(requestId, other.requestId) && isEqual(serviceInstanceId, other.serviceInstanceId) + && isEqual(networkId, other.networkId) && isEqual(startTime, other.startTime) + && isEqual(endTime, other.endTime) && isEqual(requestStatus, other.requestStatus) + && isEqual(serviceInstanceName, other.serviceInstanceName) + && isEqual(serviceType, other.serviceType); + } + + return false; + } + + @JsonIgnore + @Override + public String toString() { + return "SoActiveInfraRequests [requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + + ", networkId=" + networkId + ", startTime=" + startTime + ", endTime=" + endTime + ", requestStatus=" + + requestStatus + ", serviceInstanceName=" + serviceInstanceName + ", serviceType=" + serviceType + "]"; + } + + + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/camunda/CamundaConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/camunda/CamundaConfiguration.java new file mode 100644 index 0000000000..e5194da8f0 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/camunda/CamundaConfiguration.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.configuration.camunda; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @author waqas.ikram@ericsson.com + */ + +@Configuration +public class CamundaConfiguration { + + @Bean + public CamundaRestUrlProvider camundaRestUrlProvider(@Value(value = "${camunda.rest.api.url}") final String httpURL, + @Value(value = "${camunda.rest.api.engine:default}") final String engineName) { + return new CamundaRestUrlProvider(httpURL, engineName); + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/camunda/CamundaRestUrlProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/camunda/CamundaRestUrlProvider.java new file mode 100644 index 0000000000..dc887bbac1 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/camunda/CamundaRestUrlProvider.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.configuration.camunda; + +import java.net.URI; + +import org.springframework.stereotype.Service; +import org.springframework.web.util.UriComponentsBuilder; + +/** + * @author waqas.ikram@ericsson.com + */ +@Service +public class CamundaRestUrlProvider { + + private static final String HISTORY_PATH = "history"; + private final URI baseUri; + + public CamundaRestUrlProvider(final String httpUrl, final String engineName) { + this.baseUri = UriComponentsBuilder.fromHttpUrl(httpUrl).path(engineName).build().toUri(); + } + + /** + * see {@link Get + * Process Instances}. + * + * @param requestId the request ID + * @return URL + */ + public String getHistoryProcessInstanceUrl(final String requestId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("process-instance") + .query("variables=requestId_eq_{requestID}").buildAndExpand(requestId).toString(); + } + + /** + * see {@link Get + * Single Process Instance}. + * + * @param processInstanceId the process instance id. + * @return URL + */ + public String getSingleProcessInstanceUrl(final String processInstanceId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("process-instance") + .pathSegment(processInstanceId).build().toString(); + } + + /** + * see {@link Get BPMN 2.0 + * XML}. + * + * @param processDefinitionId the process definition id. + * @return URL + */ + public String getProcessDefinitionUrl(final String processDefinitionId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment("process-definition").pathSegment(processDefinitionId) + .pathSegment("xml").build().toString(); + } + + /** + * see {@link Get + * Single Activity Instance (Historic)}. + * + * @param processInstanceId the process instance id. + * @return URL + */ + public String getActivityInstanceUrl(final String processInstanceId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("activity-instance") + .query("processInstanceId={processInstanceId}").queryParam("sortBy", "startTime") + .queryParam("sortOrder", "asc").buildAndExpand(processInstanceId).toString(); + } + + /** + * see {@link Get + * Single Variable Instance}. + * + * @param processInstanceId the process instance id. + * @return URL + */ + public String getProcessInstanceVariablesUrl(final String processInstanceId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("variable-instance") + .query("processInstanceId={processInstanceId}").buildAndExpand(processInstanceId).toString(); + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/database/DatabaseConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/database/DatabaseConfiguration.java new file mode 100644 index 0000000000..359c334cde --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/database/DatabaseConfiguration.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.monitoring.configuration.database; + + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class DatabaseConfiguration { + + @Bean + public DatabaseUrlProvider databaseUrlProvider( + @Value(value = "${mso.database.rest.api.url}") final String baseUrl) { + return new DatabaseUrlProvider(baseUrl); + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/database/DatabaseUrlProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/database/DatabaseUrlProvider.java new file mode 100644 index 0000000000..7531cfcf7e --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/database/DatabaseUrlProvider.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.configuration.database; + +import java.net.URI; + +import org.springframework.web.util.UriComponentsBuilder; + +/** + * @author waqas.ikram@ericsson.com + * + */ +public class DatabaseUrlProvider { + + private final URI baseUri; + + public DatabaseUrlProvider(final String baseUrl) { + this.baseUri = UriComponentsBuilder.fromHttpUrl(baseUrl).build().toUri(); + } + + public String getSearchUrl(final long from, final long to, final Integer maxResult) { + final UriComponentsBuilder builder = UriComponentsBuilder.fromUri(baseUri).pathSegment("v1") + .pathSegment("getInfraActiveRequests").queryParam("from", from).queryParam("to", to); + if (maxResult != null) { + return builder.queryParam("maxResult", maxResult).build().toString(); + } + + return builder.build().toString(); + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java new file mode 100644 index 0000000000..34afd825cb --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.configuration.rest; + +import java.io.IOException; + +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpRequest; +import org.springframework.http.client.ClientHttpRequestExecution; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.http.client.ClientHttpResponse; + +/** + * @author waqas.ikram@ericsson.com + * + */ +public class BasicAuthorizationHttpRequestInterceptor implements ClientHttpRequestInterceptor { + + private final String authorization; + + public BasicAuthorizationHttpRequestInterceptor(final String authorization) { + this.authorization = authorization; + } + + @Override + public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, + final ClientHttpRequestExecution execution) throws IOException { + final HttpHeaders headers = request.getHeaders(); + headers.add("Authorization", authorization); + return execution.execute(request, body); + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java new file mode 100644 index 0000000000..557e2a63b7 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/CorsConfigurer.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.monitoring.configuration.rest; + +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.Ordered; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; + +import java.util.concurrent.TimeUnit; + +/** + * @author waqas.ikram@ericsson, eoin.hanan@ericsson.com + */ +@Configuration +public class CorsConfigurer { + + @Bean + public CorsFilter corsFilter() { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + CorsConfiguration config = new CorsConfiguration(); + config.setAllowCredentials(true); + config.addAllowedOrigin("*"); + config.addAllowedHeader("*"); + config.addAllowedMethod("*"); + source.registerCorsConfiguration("/**", config); + return new CorsFilter(source); + } +} + + diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpClientConnectionConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpClientConnectionConfiguration.java new file mode 100644 index 0000000000..1260e535a1 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpClientConnectionConfiguration.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.configuration.rest; + +import java.util.concurrent.TimeUnit; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +@Service +public class HttpClientConnectionConfiguration { + + @Value(value = "${rest.http.client.configuration.connTimeOutInSec:10}") + private int connectionTimeOutInSeconds; + + @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:180}") + private int socketTimeOutInSeconds; + + @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:600}") + private int timeToLiveInSeconds; + + @Value(value = "${rest.http.client.configuration.maxConnections:10}") + private int maxConnections; + + @Value(value = "${rest.http.client.configuration.maxConnectionsPerRoute:2}") + private int maxConnectionsPerRoute; + + /** + * @return the socketTimeOut + */ + public int getSocketTimeOutInMiliSeconds() { + return (int) TimeUnit.SECONDS.toMillis(socketTimeOutInSeconds); + } + + /** + * @return the maxConnections + */ + public int getMaxConnections() { + return maxConnections; + } + + /** + * @return the maxConnectionsPerRoute + */ + public int getMaxConnectionsPerRoute() { + return maxConnectionsPerRoute; + } + + /** + * @return the connectionTimeOut + */ + public int getConnectionTimeOutInMilliSeconds() { + return (int) TimeUnit.SECONDS.toMillis(connectionTimeOutInSeconds); + } + + /** + * @return the timeToLive + */ + public int getTimeToLiveInMins() { + return (int) TimeUnit.SECONDS.toMinutes(timeToLiveInSeconds); + } + + @Override + public String toString() { + return "HttpClientConnectionConfiguration [connectionTimeOutInSeconds=" + connectionTimeOutInSeconds + + ", socketTimeOutInSeconds=" + socketTimeOutInSeconds + ", timeToLiveInSeconds=" + timeToLiveInSeconds + + ", maxConnections=" + maxConnections + ", maxConnectionsPerRoute=" + maxConnectionsPerRoute + "]"; + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpServiceProviderConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpServiceProviderConfiguration.java new file mode 100644 index 0000000000..a590d7908f --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpServiceProviderConfiguration.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.configuration.rest; + +import static org.onap.so.monitoring.configuration.rest.RestTemplateConfiguration.CAMUNDA_REST_TEMPLATE; +import static org.onap.so.monitoring.configuration.rest.RestTemplateConfiguration.DATABASE_REST_TEMPLATE; + +import org.onap.so.monitoring.rest.service.HttpRestServiceProvider; +import org.onap.so.monitoring.rest.service.HttpRestServiceProviderImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.ClientHttpRequestInterceptor; +import org.springframework.web.client.RestTemplate; + +/** + * @author waqas.ikram@ericsson.com + * + */ +@Configuration +public class HttpServiceProviderConfiguration { + + public static final String DATABASE_HTTP_REST_SERVICE_PROVIDER = "databaseHttpRestServiceProvider"; + public static final String CAMUNDA_HTTP_REST_SERVICE_PROVIDER = "camundaHttpRestServiceProvider"; + + @Bean + @Qualifier(CAMUNDA_HTTP_REST_SERVICE_PROVIDER) + public HttpRestServiceProvider camundaHttpRestServiceProvider( + @Qualifier(CAMUNDA_REST_TEMPLATE) @Autowired final RestTemplate restTemplate, + @Value(value = "${camunda.rest.api.auth:#{null}}") final String authorization) { + return getHttpRestServiceProvider(restTemplate, authorization); + } + + @Bean + @Qualifier(DATABASE_HTTP_REST_SERVICE_PROVIDER) + public HttpRestServiceProvider databaseHttpRestServiceProvider( + @Qualifier(DATABASE_REST_TEMPLATE) @Autowired final RestTemplate restTemplate, + @Value(value = "${mso.database.rest.api.auth:#{null}}") final String authorization) { + + return getHttpRestServiceProvider(restTemplate, authorization); + } + + private HttpRestServiceProvider getHttpRestServiceProvider(final RestTemplate restTemplate, + final String authorization) { + if (authorization != null && !authorization.isEmpty()) { + final ClientHttpRequestInterceptor authorizationInterceptor = + new BasicAuthorizationHttpRequestInterceptor(authorization); + restTemplate.getInterceptors().add(authorizationInterceptor); + } + return new HttpRestServiceProviderImpl(restTemplate); + } + + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/RestTemplateConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/RestTemplateConfiguration.java new file mode 100644 index 0000000000..f8f0f687cf --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/RestTemplateConfiguration.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.monitoring.configuration.rest; + +import java.util.concurrent.TimeUnit; + +import org.apache.http.client.config.RequestConfig; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; + +/** + * @author waqas.ikram@ericsson.com + */ +@Configuration +public class RestTemplateConfiguration { + + public static final String DATABASE_REST_TEMPLATE = "databaseRestTemplate"; + + public static final String CAMUNDA_REST_TEMPLATE = "camundaRestTemplate"; + + @Autowired + private HttpClientConnectionConfiguration clientConnectionConfiguration; + + @Bean + @Qualifier(CAMUNDA_REST_TEMPLATE) + public RestTemplate camundaRestTemplate() { + return new RestTemplate(httpComponentsClientHttpRequestFactory()); + } + + @Bean + @Qualifier(DATABASE_REST_TEMPLATE) + public RestTemplate dataBasecamundaRestTemplate() { + return new RestTemplate(httpComponentsClientHttpRequestFactory()); + } + + @Bean + public HttpComponentsClientHttpRequestFactory httpComponentsClientHttpRequestFactory() { + return new HttpComponentsClientHttpRequestFactory(httpClient()); + } + + @Bean + public CloseableHttpClient httpClient() { + return HttpClientBuilder.create().setConnectionManager(poolingHttpClientConnectionManager()) + .setMaxConnPerRoute(clientConnectionConfiguration.getMaxConnectionsPerRoute()) + .setMaxConnTotal(clientConnectionConfiguration.getMaxConnections()) + .setDefaultRequestConfig(requestConfig()).build(); + } + + @Bean + public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() { + return new PoolingHttpClientConnectionManager(clientConnectionConfiguration.getTimeToLiveInMins(), + TimeUnit.MINUTES); + } + + @Bean + public RequestConfig requestConfig() { + return RequestConfig.custom().setSocketTimeout(clientConnectionConfiguration.getSocketTimeOutInMiliSeconds()) + .setConnectTimeout(clientConnectionConfiguration.getConnectionTimeOutInMilliSeconds()).build(); + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProvider.java new file mode 100644 index 0000000000..209fac8fe1 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProvider.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.db.service; + +import java.util.List; +import java.util.Map; + +import org.onap.so.monitoring.model.SoInfraRequest; + + +/** + * @author waqas.ikram@ericsson.com + */ +public interface DatabaseServiceProvider { + + List getSoInfraRequest(final Map filters, final long startTime, + final long endTime, final Integer maxResult); + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProviderImpl.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProviderImpl.java new file mode 100644 index 0000000000..6be6367302 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProviderImpl.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.db.service; + +import static org.onap.so.monitoring.configuration.rest.HttpServiceProviderConfiguration.DATABASE_HTTP_REST_SERVICE_PROVIDER; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.onap.so.monitoring.camunda.model.SoActiveInfraRequests; +import org.onap.so.monitoring.configuration.database.DatabaseUrlProvider; +import org.onap.so.monitoring.model.SoInfraRequest; +import org.onap.so.monitoring.model.SoInfraRequestBuilder; +import org.onap.so.monitoring.rest.service.HttpRestServiceProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import com.google.common.base.Optional; + +/** + * @author waqas.ikram@ericsson.com + */ +@Service +public class DatabaseServiceProviderImpl implements DatabaseServiceProvider { + + private final DatabaseUrlProvider urlProvider; + + private final HttpRestServiceProvider httpRestServiceProvider; + + @Autowired + public DatabaseServiceProviderImpl(final DatabaseUrlProvider urlProvider, + @Qualifier(DATABASE_HTTP_REST_SERVICE_PROVIDER) @Autowired final HttpRestServiceProvider httpRestServiceProvider) { + this.urlProvider = urlProvider; + this.httpRestServiceProvider = httpRestServiceProvider; + } + + @Override + public List getSoInfraRequest(final Map filters, final long startTime, + final long endTime, final Integer maxResult) { + final String url = urlProvider.getSearchUrl(startTime, endTime, maxResult); + + final Optional optionalRequests = + httpRestServiceProvider.postHttpRequest(filters, url, SoActiveInfraRequests[].class); + if (optionalRequests.isPresent()) { + return getSoInfraRequest(optionalRequests.get()); + } + return Collections.emptyList(); + } + + + private List getSoInfraRequest(final SoActiveInfraRequests[] requests) { + final List result = new ArrayList<>(requests.length); + for (final SoActiveInfraRequests activeRequests : requests) { + final SoInfraRequest soInfraRequest = + new SoInfraRequestBuilder().setRequestId(activeRequests.getRequestId()) + .setServiceInstanceId(activeRequests.getServiceInstanceId()) + .setNetworkId(activeRequests.getNetworkId()).setEndTime(activeRequests.getEndTime()) + .setRequestStatus(activeRequests.getRequestStatus()) + .setServiceIstanceName(activeRequests.getServiceInstanceName()) + .setServiceType(activeRequests.getServiceType()).setStartTime(activeRequests.getStartTime()) + .build(); + result.add(soInfraRequest); + + } + return result; + } + + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/InvalidRestRequestException.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/InvalidRestRequestException.java new file mode 100644 index 0000000000..4d3c489fa9 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/InvalidRestRequestException.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.exception; + +/** + * @author waqas.ikram@ericsson.com + * + */ +public class InvalidRestRequestException extends RuntimeException { + private static final long serialVersionUID = -1158414939006977465L; + + public InvalidRestRequestException(final String message) { + super(message); + } + + public InvalidRestRequestException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/RestProcessingException.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/RestProcessingException.java new file mode 100644 index 0000000000..ab25854542 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/RestProcessingException.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.exception; + +/** + * @author waqas.ikram@ericsson.com + * + */ +public class RestProcessingException extends RuntimeException { + + private static final long serialVersionUID = 16862313537198441L; + + public RestProcessingException(final String message) { + super(message); + } + + public RestProcessingException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ActivityInstanceDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ActivityInstanceDetail.java new file mode 100644 index 0000000000..2b26a4a25c --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ActivityInstanceDetail.java @@ -0,0 +1,192 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +/** + * @author waqas.ikram@ericsson.com + * + */ +public class ActivityInstanceDetail { + private final String activityId; + private final String activityName; + private final String activityType; + private final String processInstanceId; + private final String calledProcessInstanceId; + private final String startTime; + private final String endTime; + private final String durationInMilliseconds; + + public ActivityInstanceDetail(final ActivityInstanceDetailBuilder builder) { + this.activityId = builder.activityId; + this.activityName = builder.activityName; + this.activityType = builder.activityType; + this.processInstanceId = builder.processInstanceId; + this.calledProcessInstanceId = builder.calledProcessInstanceId; + this.startTime = builder.startTime; + this.endTime = builder.endTime; + this.durationInMilliseconds = builder.durationInMilliseconds; + } + + /** + * @return the activityId + */ + public String getActivityId() { + return activityId; + } + + /** + * @return the activityName + */ + public String getActivityName() { + return activityName; + } + + /** + * @return the activityType + */ + public String getActivityType() { + return activityType; + } + + /** + * @return the processInstanceId + */ + public String getProcessInstanceId() { + return processInstanceId; + } + + /** + * @return the calledProcessInstanceId + */ + public String getCalledProcessInstanceId() { + return calledProcessInstanceId; + } + + /** + * @return the startTime + */ + public String getStartTime() { + return startTime; + } + + /** + * @return the endTime + */ + public String getEndTime() { + return endTime; + } + + /** + * @return the durationInMillis + */ + public String getDurationInMillis() { + return durationInMilliseconds; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((activityId == null) ? 0 : activityId.hashCode()); + result = prime * result + ((activityName == null) ? 0 : activityName.hashCode()); + result = prime * result + ((activityType == null) ? 0 : activityType.hashCode()); + result = prime * result + ((calledProcessInstanceId == null) ? 0 : calledProcessInstanceId.hashCode()); + result = prime * result + ((durationInMilliseconds == null) ? 0 : durationInMilliseconds.hashCode()); + result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); + result = prime * result + ((processInstanceId == null) ? 0 : processInstanceId.hashCode()); + result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + + if (obj instanceof ActivityInstanceDetail) { + final ActivityInstanceDetail other = (ActivityInstanceDetail) obj; + return isEqual(activityId, other.activityId) && isEqual(activityName, other.activityName) + && isEqual(activityType, other.activityType) && isEqual(processInstanceId, other.processInstanceId) + && isEqual(calledProcessInstanceId, other.calledProcessInstanceId) + && isEqual(startTime, other.startTime) && isEqual(endTime, other.endTime) + && isEqual(durationInMilliseconds, other.durationInMilliseconds); + } + + return false; + } + + + public static final class ActivityInstanceDetailBuilder { + + private String activityId; + private String activityName; + private String activityType; + private String processInstanceId; + private String calledProcessInstanceId; + private String startTime; + private String endTime; + private String durationInMilliseconds; + + public ActivityInstanceDetailBuilder activityId(final String activityId) { + this.activityId = activityId; + return this; + } + + public ActivityInstanceDetailBuilder activityName(final String activityName) { + this.activityName = activityName; + return this; + } + + public ActivityInstanceDetailBuilder activityType(final String activityType) { + this.activityType = activityType; + return this; + } + + public ActivityInstanceDetailBuilder processInstanceId(final String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + public ActivityInstanceDetailBuilder calledProcessInstanceId(final String calledProcessInstanceId) { + this.calledProcessInstanceId = calledProcessInstanceId; + return this; + } + + public ActivityInstanceDetailBuilder startTime(final String startTime) { + this.startTime = startTime; + return this; + } + + public ActivityInstanceDetailBuilder endTime(final String endTime) { + this.endTime = endTime; + return this; + } + + public ActivityInstanceDetailBuilder durationInMilliseconds(final String durationInMilliseconds) { + this.durationInMilliseconds = durationInMilliseconds; + return this; + } + + public ActivityInstanceDetail build() { + return new ActivityInstanceDetail(this); + } + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessDefinitionDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessDefinitionDetail.java new file mode 100644 index 0000000000..5e988f6aa6 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessDefinitionDetail.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +/** + * @author waqas.ikram@ericsson.com + * + */ +public class ProcessDefinitionDetail { + + private final String processDefinitionId; + private final String processDefinitionXml; + + public ProcessDefinitionDetail(final String processDefinitionId, final String processDefinitionXml) { + this.processDefinitionId = processDefinitionId; + this.processDefinitionXml = processDefinitionXml; + } + + /** + * @return the processDefinitionId + */ + public String getProcessDefinitionId() { + return processDefinitionId; + } + + /** + * @return the processDefinitionXml + */ + public String getProcessDefinitionXml() { + return processDefinitionXml; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((processDefinitionId == null) ? 0 : processDefinitionId.hashCode()); + result = prime * result + ((processDefinitionXml == null) ? 0 : processDefinitionXml.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof ProcessDefinitionDetail) { + final ProcessDefinitionDetail other = (ProcessDefinitionDetail) obj; + return isEqual(processDefinitionId, other.processDefinitionId) + && isEqual(processDefinitionXml, other.processDefinitionXml); + } + return false; + } + + @Override + public String toString() { + return "ProcessDefinitionDetail [processDefinitionId=" + processDefinitionId + ", processDefinitionXml=" + + processDefinitionXml + "]"; + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceDetail.java new file mode 100644 index 0000000000..2f8e756b8c --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceDetail.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +/** + * @author waqas.ikram@ericsson.com + */ +public class ProcessInstanceDetail { + + private final String processInstanceId; + private final String processDefinitionId; + private final String processDefinitionName; + private final String superProcessInstanceId; + + + public ProcessInstanceDetail(final String processInstanceId, final String processDefinitionId, + final String processDefinitionName, final String superProcessInstanceId) { + this.processInstanceId = processInstanceId; + this.processDefinitionId = processDefinitionId; + this.processDefinitionName = processDefinitionName; + this.superProcessInstanceId = superProcessInstanceId; + } + + /** + * @return the processInstanceId + */ + public String getProcessInstanceId() { + return processInstanceId; + } + + /** + * @return the processDefinitionId + */ + public String getProcessDefinitionId() { + return processDefinitionId; + } + + /** + * @return the processDefinitionName + */ + public String getProcessDefinitionName() { + return processDefinitionName; + } + + /** + * @return the superProcessInstanceId + */ + public String getSuperProcessInstanceId() { + return superProcessInstanceId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((processInstanceId == null) ? 0 : processInstanceId.hashCode()); + result = prime * result + ((processDefinitionId == null) ? 0 : processDefinitionId.hashCode()); + result = prime * result + ((processDefinitionName == null) ? 0 : processDefinitionName.hashCode()); + result = prime * result + ((superProcessInstanceId == null) ? 0 : superProcessInstanceId.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof ProcessInstanceDetail) { + final ProcessInstanceDetail other = (ProcessInstanceDetail) obj; + + return isEqual(processInstanceId, other.processInstanceId) + && isEqual(processDefinitionId, other.processDefinitionId) + && isEqual(processDefinitionName, other.processDefinitionName) + && isEqual(superProcessInstanceId, other.superProcessInstanceId); + } + return false; + } + + @Override + public String toString() { + return "ProcessInstanceDetail [processInstanceId=" + processInstanceId + ", processDefinitionId=" + + processDefinitionId + ", processDefinitionName=" + processDefinitionName + ", superProcessInstanceId=" + + superProcessInstanceId + "]"; + } + + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceIdDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceIdDetail.java new file mode 100644 index 0000000000..06a08f2027 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceIdDetail.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +/** + * @author waqas.ikram@ericsson.com + */ +public class ProcessInstanceIdDetail { + + private final String processInstanceId; + + + public ProcessInstanceIdDetail(final String processInstanceId) { + this.processInstanceId = processInstanceId; + } + + /** + * @return the processInstancId + */ + public String getProcessInstanceId() { + return processInstanceId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((processInstanceId == null) ? 0 : processInstanceId.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof ProcessInstanceIdDetail) { + final ProcessInstanceIdDetail other = (ProcessInstanceIdDetail) obj; + + return isEqual(processInstanceId, other.processInstanceId); + } + return false; + } + + @Override + public String toString() { + return "ProcessInstanceIdDetail [processInstanceId=" + processInstanceId + "]"; + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceVariableDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceVariableDetail.java new file mode 100644 index 0000000000..a52121d7c5 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/ProcessInstanceVariableDetail.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.model; + +/** + * @author waqas.ikram@ericsson.com + */ +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +public class ProcessInstanceVariableDetail { + + private final String name; + private final Object value; + private final String type; + + public ProcessInstanceVariableDetail(final String name, final Object value, final String type) { + this.name = name; + this.value = value; + this.type = type; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the value + */ + public Object getValue() { + return value; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof ProcessInstanceVariableDetail) { + final ProcessInstanceVariableDetail other = (ProcessInstanceVariableDetail) obj; + + return isEqual(name, other.name) && isEqual(value, other.value) && isEqual(type, other.type); + } + return false; + } + + @Override + public String toString() { + return "ProcessInstanceVariableDetail [name=" + name + ", value=" + value + ", type=" + type + "]"; + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/SoInfraRequest.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/SoInfraRequest.java new file mode 100644 index 0000000000..e16cd14598 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/SoInfraRequest.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.model; + +import static org.onap.so.monitoring.utils.ObjectEqualsUtils.isEqual; + +/** + * @author waqas.ikram@ericsson.com + */ +public class SoInfraRequest { + + private final String requestId; + private final String serviceInstanceId; + private final String serviceIstanceName; + private final String networkId; + private final String requestStatus; + private final String serviceType; + private final String startTime; + private final String endTime; + + public SoInfraRequest(final SoInfraRequestBuilder requestBuilder) { + this.requestId = requestBuilder.getRequestId(); + this.serviceInstanceId = requestBuilder.getServiceInstanceId(); + this.serviceIstanceName = requestBuilder.getServiceIstanceName(); + this.networkId = requestBuilder.getNetworkId(); + this.requestStatus = requestBuilder.getRequestStatus(); + this.serviceType = requestBuilder.getServiceType(); + this.startTime = requestBuilder.getStartTime(); + this.endTime = requestBuilder.getEndTime(); + } + + /** + * @return the requestId + */ + public String getRequestId() { + return requestId; + } + + /** + * @return the serviceInstanceId + */ + public String getServiceInstanceId() { + return serviceInstanceId; + } + + /** + * @return the serviceIstanceName + */ + public String getServiceIstanceName() { + return serviceIstanceName; + } + + /** + * @return the networkId + */ + public String getNetworkId() { + return networkId; + } + + /** + * @return the requestStatus + */ + public String getRequestStatus() { + return requestStatus; + } + + /** + * @return the serviceType + */ + public String getServiceType() { + return serviceType; + } + + /** + * @return the startTime + */ + public String getStartTime() { + return startTime; + } + + /** + * @return the endTime + */ + public String getEndTime() { + return endTime; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); + result = prime * result + ((networkId == null) ? 0 : networkId.hashCode()); + result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); + result = prime * result + ((requestStatus == null) ? 0 : requestStatus.hashCode()); + result = prime * result + ((serviceInstanceId == null) ? 0 : serviceInstanceId.hashCode()); + result = prime * result + ((serviceIstanceName == null) ? 0 : serviceIstanceName.hashCode()); + result = prime * result + ((serviceType == null) ? 0 : serviceType.hashCode()); + result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (obj instanceof SoInfraRequest) { + final SoInfraRequest other = (SoInfraRequest) obj; + return isEqual(requestId, other.requestId) && isEqual(serviceInstanceId, other.serviceInstanceId) + && isEqual(serviceIstanceName, other.serviceIstanceName) && isEqual(networkId, other.networkId) + && isEqual(requestStatus, other.requestStatus) && isEqual(serviceType, other.serviceType) + && isEqual(startTime, other.startTime) && isEqual(endTime, other.endTime); + } + return false; + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/SoInfraRequestBuilder.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/SoInfraRequestBuilder.java new file mode 100644 index 0000000000..cdaf7641c8 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/model/SoInfraRequestBuilder.java @@ -0,0 +1,148 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.model; + +import java.sql.Timestamp; + +/** + * @author waqas.ikram@ericsson.com + */ +public class SoInfraRequestBuilder { + + private String requestId; + private String serviceInstanceId; + private String serviceIstanceName; + private String networkId; + private String requestStatus; + private String serviceType; + private String startTime; + private String endTime; + + public SoInfraRequestBuilder setRequestId(final String requestId) { + this.requestId = requestId; + return this; + } + + public SoInfraRequestBuilder setServiceInstanceId(final String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + return this; + } + + public SoInfraRequestBuilder setServiceIstanceName(final String serviceIstanceName) { + this.serviceIstanceName = serviceIstanceName; + return this; + } + + public SoInfraRequestBuilder setNetworkId(final String networkId) { + this.networkId = networkId; + return this; + } + + public SoInfraRequestBuilder setRequestStatus(final String requestStatus) { + this.requestStatus = requestStatus; + return this; + } + + public SoInfraRequestBuilder setServiceType(final String serviceType) { + this.serviceType = serviceType; + return this; + } + + public SoInfraRequestBuilder setEndTime(final String endTime) { + this.endTime = endTime; + return this; + } + + public SoInfraRequestBuilder setEndTime(final Timestamp endTime) { + this.endTime = endTime != null ? endTime.toString() : null; + return this; + } + + + public SoInfraRequestBuilder setStartTime(final String startTime) { + this.startTime = startTime; + return this; + } + + public SoInfraRequestBuilder setStartTime(final Timestamp startTime) { + this.startTime = startTime != null ? startTime.toString() : null; + return this; + } + + public SoInfraRequest build() { + return new SoInfraRequest(this); + } + + /** + * @return the requestId + */ + public String getRequestId() { + return requestId; + } + + /** + * @return the serviceInstanceId + */ + public String getServiceInstanceId() { + return serviceInstanceId; + } + + /** + * @return the serviceIstanceName + */ + public String getServiceIstanceName() { + return serviceIstanceName; + } + + /** + * @return the networkId + */ + public String getNetworkId() { + return networkId; + } + + /** + * @return the requestStatus + */ + public String getRequestStatus() { + return requestStatus; + } + + /** + * @return the serviceType + */ + public String getServiceType() { + return serviceType; + } + + /** + * @return the startTime + */ + public String getStartTime() { + return startTime; + } + + /** + * @return the endTime + */ + public String getEndTime() { + return endTime; + } +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProvider.java new file mode 100644 index 0000000000..e0e0432452 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProvider.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.rest.service; + +import java.util.List; + +import org.onap.so.monitoring.model.ActivityInstanceDetail; +import org.onap.so.monitoring.model.ProcessDefinitionDetail; +import org.onap.so.monitoring.model.ProcessInstanceDetail; +import org.onap.so.monitoring.model.ProcessInstanceIdDetail; +import org.onap.so.monitoring.model.ProcessInstanceVariableDetail; + +import com.google.common.base.Optional; + +/** + * @author waqas.ikram@ericsson.com + */ +public interface CamundaProcessDataServiceProvider { + + Optional getProcessInstanceIdDetail(final String requestId); + + Optional getSingleProcessInstanceDetail(final String processInstanceId); + + Optional getProcessDefinition(final String processDefinitionId); + + List getActivityInstance(final String processInstanceId); + + List getProcessInstanceVariable(final String processInstanceId); + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderImpl.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderImpl.java new file mode 100644 index 0000000000..e6fbb68456 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderImpl.java @@ -0,0 +1,179 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.rest.service; + +import static org.onap.so.monitoring.configuration.rest.HttpServiceProviderConfiguration.CAMUNDA_HTTP_REST_SERVICE_PROVIDER; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.onap.so.monitoring.camunda.model.ActivityInstance; +import org.onap.so.monitoring.camunda.model.ProcessDefinition; +import org.onap.so.monitoring.camunda.model.ProcessInstance; +import org.onap.so.monitoring.camunda.model.ProcessInstanceVariable; +import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider; +import org.onap.so.monitoring.model.ActivityInstanceDetail; +import org.onap.so.monitoring.model.ProcessDefinitionDetail; +import org.onap.so.monitoring.model.ProcessInstanceDetail; +import org.onap.so.monitoring.model.ProcessInstanceIdDetail; +import org.onap.so.monitoring.model.ProcessInstanceVariableDetail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import com.google.common.base.Optional; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author waqas.ikram@ericsson.com + */ +@Service +public class CamundaProcessDataServiceProviderImpl implements CamundaProcessDataServiceProvider { + private static final Logger LOGGER = LoggerFactory.getLogger(CamundaProcessDataServiceProviderImpl.class); + private final CamundaRestUrlProvider urlProvider; + + private final HttpRestServiceProvider httpRestServiceProvider; + + @Autowired + public CamundaProcessDataServiceProviderImpl(final CamundaRestUrlProvider urlProvider, + @Qualifier(CAMUNDA_HTTP_REST_SERVICE_PROVIDER) @Autowired final HttpRestServiceProvider httpRestServiceProvider) { + this.urlProvider = urlProvider; + this.httpRestServiceProvider = httpRestServiceProvider; + } + + @Override + public Optional getProcessInstanceIdDetail(final String requestId) { + final String url = urlProvider.getHistoryProcessInstanceUrl(requestId); + final Optional processInstances = + httpRestServiceProvider.getHttpResponse(url, ProcessInstance[].class); + + if (processInstances.isPresent()) { + final ProcessInstance[] instances = processInstances.get(); + final String message = "found process instance for request id: " + requestId + + ", result size: " + instances.length; + LOGGER.debug(message); + + if (instances.length > 0) { + for (int index = 0; index < instances.length; index++) { + final ProcessInstance processInstance = instances[index]; + if (processInstance.getSuperProcessInstanceId() == null) { + return Optional.of(new ProcessInstanceIdDetail(processInstance.getId())); + } + LOGGER.debug("found sub process instance id with super process instanceId: " + + processInstance.getSuperProcessInstanceId()); + } + } + } + LOGGER.error("Unable to find process intance for request id: " + requestId); + return Optional.absent(); + } + + @Override + public Optional getSingleProcessInstanceDetail(final String processInstanceId) { + final String url = urlProvider.getSingleProcessInstanceUrl(processInstanceId); + final Optional processInstances = + httpRestServiceProvider.getHttpResponse(url, ProcessInstance.class); + + if (processInstances.isPresent()) { + final ProcessInstance processInstance = processInstances.get(); + + final ProcessInstanceDetail instanceDetail = + new ProcessInstanceDetail(processInstance.getId(), processInstance.getProcessDefinitionId(), + processInstance.getProcessDefinitionName(), processInstance.getSuperProcessInstanceId()); + return Optional.of(instanceDetail); + + } + LOGGER.error("Unable to find process intance for id: " + processInstanceId); + return Optional.absent(); + } + + + @Override + public Optional getProcessDefinition(final String processDefinitionId) { + final String url = urlProvider.getProcessDefinitionUrl(processDefinitionId); + final Optional response = + httpRestServiceProvider.getHttpResponse(url, ProcessDefinition.class); + if (response.isPresent()) { + final ProcessDefinition processDefinition = response.get(); + final String xmlDefinition = processDefinition.getBpmn20Xml(); + if (xmlDefinition != null) { + return Optional.of(new ProcessDefinitionDetail(processDefinitionId, xmlDefinition)); + } + } + LOGGER.error("Unable to find process definition for processDefinitionId: " + + processDefinitionId); + return Optional.absent(); + } + + @Override + public List getActivityInstance(final String processInstanceId) { + final String url = urlProvider.getActivityInstanceUrl(processInstanceId); + final Optional response = + httpRestServiceProvider.getHttpResponse(url, ActivityInstance[].class); + if (response.isPresent()) { + final ActivityInstance[] activityInstances = response.get(); + final List activityInstanceDetails = new ArrayList<>(activityInstances.length); + for (int index = 0; index < activityInstances.length; index++) { + + final ActivityInstance activityInstance = activityInstances[index]; + + activityInstanceDetails.add(new ActivityInstanceDetail.ActivityInstanceDetailBuilder() + .activityId(activityInstance.getActivityId()).activityName(activityInstance.getActivityName()) + .activityType(activityInstance.getActivityType()) + .calledProcessInstanceId(activityInstance.getCalledProcessInstanceId()) + .startTime(activityInstance.getStartTime()).endTime(activityInstance.getEndTime()) + .durationInMilliseconds(activityInstance.getDurationInMillis()) + .processInstanceId(activityInstance.getProcessInstanceId()).build()); + + } + return activityInstanceDetails; + } + LOGGER.error("Unable to find activity intance detail for process instance id: " + + processInstanceId); + return Collections.emptyList(); + } + + @Override + public List getProcessInstanceVariable(final String processInstanceId) { + final String url = urlProvider.getProcessInstanceVariablesUrl(processInstanceId); + final Optional response = + httpRestServiceProvider.getHttpResponse(url, ProcessInstanceVariable[].class); + if (response.isPresent()) { + final ProcessInstanceVariable[] instanceVariables = response.get(); + final List instanceVariableDetails = + new ArrayList<>(instanceVariables.length); + for (int index = 0; index < instanceVariables.length; index++) { + final ProcessInstanceVariable processInstanceVariable = instanceVariables[index]; + final ProcessInstanceVariableDetail instanceVariableDetail = + new ProcessInstanceVariableDetail(processInstanceVariable.getName(), + processInstanceVariable.getValue(), processInstanceVariable.getType()); + instanceVariableDetails.add(instanceVariableDetail); + } + return instanceVariableDetails; + } + LOGGER.error("Unable to find process intance variable details for process instance id: " + + processInstanceId); + return Collections.emptyList(); + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProvider.java new file mode 100644 index 0000000000..4606c04e05 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProvider.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.rest.service; + +import com.google.common.base.Optional; + +/** + * @author waqas.ikram@ericsson.com + */ +public interface HttpRestServiceProvider { + + public Optional getHttpResponse(final String url, final Class clazz); + + public Optional postHttpRequest(final Object object, final String url, final Class clazz); + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProviderImpl.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProviderImpl.java new file mode 100644 index 0000000000..82a54c10a2 --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProviderImpl.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.rest.service; + +import org.onap.so.monitoring.exception.InvalidRestRequestException; +import org.onap.so.monitoring.exception.RestProcessingException; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; + +import com.google.common.base.Optional; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author waqas.ikram@ericsson.com + */ +public class HttpRestServiceProviderImpl implements HttpRestServiceProvider { + + private static final Logger LOGGER = LoggerFactory.getLogger(HttpRestServiceProviderImpl.class); + private final RestTemplate restTemplate; + + public HttpRestServiceProviderImpl(final RestTemplate restTemplate) { + this.restTemplate = restTemplate; + } + + @Override + public Optional getHttpResponse(final String url, final Class clazz) { + LOGGER.trace("Will invoke HTTP GET using URL: " + url); + try { + final ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, null, clazz); + if (!response.getStatusCode().equals(HttpStatus.OK)) { + final String message = "Unable to invoke HTTP GET using URL: " + url + + ", Response Code: " + response.getStatusCode(); + LOGGER.error(message); + return Optional.absent(); + } + + if (response.hasBody()) { + return Optional.of(response.getBody()); + } + } catch (final HttpClientErrorException httpClientErrorException) { + final String message = "Unable to invoke HTTP GET using url: " + url + ", Response: " + + httpClientErrorException.getRawStatusCode(); + LOGGER.error(message, httpClientErrorException); + final int rawStatusCode = httpClientErrorException.getRawStatusCode(); + if (rawStatusCode == HttpStatus.BAD_REQUEST.value() || rawStatusCode == HttpStatus.NOT_FOUND.value()) { + throw new InvalidRestRequestException("No result found for given url: " + url); + } + throw new RestProcessingException("Unable to invoke HTTP GET using URL: " + url); + + } catch (final RestClientException restClientException) { + LOGGER.error("Unable to invoke HTTP GET using url: " + url, restClientException); + throw new RestProcessingException("Unable to invoke HTTP GET using URL: " + + url, restClientException); + } + + return Optional.absent(); + } + + @Override + public Optional postHttpRequest(final Object object, final String url, final Class clazz) { + try { + final HttpEntity request = new HttpEntity<>(object); + final ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, request, clazz); + if (!response.getStatusCode().equals(HttpStatus.OK)) { + final String message = "Unable to invoke HTTP GET using URL: " + url + + ", Response Code: " + response.getStatusCode(); + LOGGER.error(message); + return Optional.absent(); + } + + if (response.hasBody()) { + return Optional.of(response.getBody()); + } + + } catch (final HttpClientErrorException httpClientErrorException) { + final String message = "Unable to invoke HTTP POST using url: " + url + + ", Response: " + httpClientErrorException.getRawStatusCode(); + LOGGER.error(message, httpClientErrorException); + final int rawStatusCode = httpClientErrorException.getRawStatusCode(); + if (rawStatusCode == HttpStatus.BAD_REQUEST.value() || rawStatusCode == HttpStatus.NOT_FOUND.value()) { + throw new InvalidRestRequestException("No result found for given url: " + url); + } + throw new RestProcessingException("Unable to invoke HTTP POST using URL: " + url); + + } catch (final RestClientException restClientException) { + LOGGER.error("Unable to invoke HTTP POST using url: " + url, restClientException); + throw new RestProcessingException("Unable to invoke HTTP POST using URL: " + + url, restClientException); + } + + return Optional.absent(); + } + + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/utils/ObjectEqualsUtils.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/utils/ObjectEqualsUtils.java new file mode 100644 index 0000000000..d8e331baae --- /dev/null +++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/utils/ObjectEqualsUtils.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.monitoring.utils; + +/** + * @author waqas.ikram@ericsson.com + */ +public class ObjectEqualsUtils { + + private ObjectEqualsUtils() {} + + public static boolean isEqual(final Object objectA, final Object objectB) { + if (objectA == null) { + return objectB == null; + } + return objectA.equals(objectB); + } + +} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ActivityInstance.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ActivityInstance.java deleted file mode 100644 index 10ca6c9ac3..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ActivityInstance.java +++ /dev/null @@ -1,188 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.camunda.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * @author waqas.ikram@ericsson.com - * - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class ActivityInstance { - - private String activityId; - private String activityName; - private String activityType; - private String processInstanceId; - private String calledProcessInstanceId; - private String startTime; - private String endTime; - private String durationInMillis; - - public ActivityInstance() {} - - - /** - * @return the activityId - */ - public String getActivityId() { - return activityId; - } - - /** - * @param activityId the activityId to set - */ - public void setActivityId(final String activityId) { - this.activityId = activityId; - } - - /** - * @return the activityName - */ - public String getActivityName() { - return activityName; - } - - /** - * @param activityName the activityName to set - */ - public void setActivityName(final String activityName) { - this.activityName = activityName; - } - - /** - * @return the activityType - */ - public String getActivityType() { - return activityType; - } - - /** - * @param activityType the activityType to set - */ - public void setActivityType(final String activityType) { - this.activityType = activityType; - } - - /** - * @return the processInstanceId - */ - public String getProcessInstanceId() { - return processInstanceId; - } - - /** - * @param processInstanceId the processInstanceId to set - */ - public void setProcessInstanceId(final String processInstanceId) { - this.processInstanceId = processInstanceId; - } - - /** - * @return the calledProcessInstanceId - */ - public String getCalledProcessInstanceId() { - return calledProcessInstanceId; - } - - /** - * @param calledProcessInstanceId the calledProcessInstanceId to set - */ - public void setCalledProcessInstanceId(final String calledProcessInstanceId) { - this.calledProcessInstanceId = calledProcessInstanceId; - } - - /** - * @return the startTime - */ - public String getStartTime() { - return startTime; - } - - /** - * @param startTime the startTime to set - */ - public void setStartTime(final String startTime) { - this.startTime = startTime; - } - - /** - * @return the endTime - */ - public String getEndTime() { - return endTime; - } - - /** - * @param endTime the endTime to set - */ - public void setEndTime(final String endTime) { - this.endTime = endTime; - } - - /** - * @return the durationInMillis - */ - public String getDurationInMillis() { - return durationInMillis; - } - - /** - * @param durationInMillis the durationInMillis to set - */ - public void setDurationInMillis(final String durationInMillis) { - this.durationInMillis = durationInMillis; - } - - @JsonIgnore - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((activityId == null) ? 0 : activityId.hashCode()); - result = prime * result + ((activityName == null) ? 0 : activityName.hashCode()); - result = prime * result + ((activityType == null) ? 0 : activityType.hashCode()); - result = prime * result + ((calledProcessInstanceId == null) ? 0 : calledProcessInstanceId.hashCode()); - result = prime * result + ((durationInMillis == null) ? 0 : durationInMillis.hashCode()); - result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); - result = prime * result + ((processInstanceId == null) ? 0 : processInstanceId.hashCode()); - result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); - return result; - } - - @JsonIgnore - @Override - public boolean equals(final Object obj) { - if (obj instanceof ActivityInstance) { - final ActivityInstance other = (ActivityInstance) obj; - return isEqual(activityId, other.activityId) && isEqual(activityName, other.activityName) - && isEqual(activityType, other.activityType) && isEqual(processInstanceId, other.processInstanceId) - && isEqual(calledProcessInstanceId, other.calledProcessInstanceId) - && isEqual(startTime, other.startTime) && isEqual(endTime, other.endTime) - && isEqual(durationInMillis, other.durationInMillis); - } - return false; - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessDefinition.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessDefinition.java deleted file mode 100644 index ccddf0cd95..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessDefinition.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.camunda.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * @author waqas.ikram@ericsson.com - * - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class ProcessDefinition { - - private String id; - private String bpmn20Xml; - - public ProcessDefinition() {} - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(final String id) { - this.id = id; - } - - /** - * @return the bpmn20Xml - */ - public String getBpmn20Xml() { - return bpmn20Xml; - } - - /** - * @param bpmn20Xml the bpmn20Xml to set - */ - public void setBpmn20Xml(final String bpmn20Xml) { - this.bpmn20Xml = bpmn20Xml; - } - - @JsonIgnore - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((bpmn20Xml == null) ? 0 : bpmn20Xml.hashCode()); - return result; - } - - @JsonIgnore - @Override - public boolean equals(final Object obj) { - if (obj instanceof ProcessDefinition) { - final ProcessDefinition other = (ProcessDefinition) obj; - return isEqual(id, other.id) && isEqual(bpmn20Xml, other.bpmn20Xml); - } - return false; - } - - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessInstance.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessInstance.java deleted file mode 100644 index faea7b3bf9..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessInstance.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.camunda.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * @author waqas.ikram@ericsson.com - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class ProcessInstance { - - private String id; - private String processDefinitionId; - private String processDefinitionName; - private String superProcessInstanceId; - - public ProcessInstance() {} - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(final String id) { - this.id = id; - } - - - /** - * @return the processDefinitionId - */ - public String getProcessDefinitionId() { - return processDefinitionId; - } - - /** - * @param processDefinitionId the processDefinitionId to set - */ - public void setProcessDefinitionId(final String processDefinitionId) { - this.processDefinitionId = processDefinitionId; - } - - /** - * @return the processDefinitionName - */ - public String getProcessDefinitionName() { - return processDefinitionName; - } - - /** - * @param processDefinitionName the processDefinitionName to set - */ - public void setProcessDefinitionName(final String processDefinitionName) { - this.processDefinitionName = processDefinitionName; - } - - /** - * @return the superProcessInstanceId - */ - public String getSuperProcessInstanceId() { - return superProcessInstanceId; - } - - /** - * @param superProcessInstanceId the superProcessInstanceId to set - */ - public void setSuperProcessInstanceId(final String superProcessInstanceId) { - this.superProcessInstanceId = superProcessInstanceId; - } - - - @JsonIgnore - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((processDefinitionId == null) ? 0 : processDefinitionId.hashCode()); - result = prime * result + ((processDefinitionName == null) ? 0 : processDefinitionName.hashCode()); - result = prime * result + ((superProcessInstanceId == null) ? 0 : superProcessInstanceId.hashCode()); - return result; - } - - @JsonIgnore - @Override - public boolean equals(final Object obj) { - if (obj instanceof ProcessInstance) { - final ProcessInstance other = (ProcessInstance) obj; - return isEqual(id, other.id) && isEqual(processDefinitionId, other.processDefinitionId) - && isEqual(processDefinitionName, other.processDefinitionName) - && isEqual(superProcessInstanceId, other.superProcessInstanceId); - } - - return false; - } - - @JsonIgnore - @Override - public String toString() { - return "ProcessInstance [id=" + id + ", processDefinitionId=" + processDefinitionId + ", processDefinitionName=" - + processDefinitionName + "]"; - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessInstanceVariable.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessInstanceVariable.java deleted file mode 100644 index 14a01b96bb..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/ProcessInstanceVariable.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.camunda.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * @author waqas.ikram@ericsson.com - */ -public class ProcessInstanceVariable { - - private String name; - private Object value; - private String type; - - public ProcessInstanceVariable() {} - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(final String name) { - this.name = name; - } - - /** - * @return the value - */ - public Object getValue() { - return value; - } - - /** - * @param value the value to set - */ - public void setValue(final Object value) { - this.value = value; - } - - /** - * @return the type - */ - public String getType() { - return type; - } - - /** - * @param type the type to set - */ - public void setType(final String type) { - this.type = type; - } - - @JsonIgnore - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - @JsonIgnore - @Override - public boolean equals(final Object obj) { - if (obj instanceof ProcessInstanceVariable) { - final ProcessInstanceVariable other = (ProcessInstanceVariable) obj; - return isEqual(name, other.name) && isEqual(value, other.value) && isEqual(type, other.type); - } - - return false; - } - - @JsonIgnore - @Override - public String toString() { - return "ProcessInstance [name=" + name + ", value=" + value + ", type=" + type + "]"; - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/SoActiveInfraRequests.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/SoActiveInfraRequests.java deleted file mode 100644 index b17cad23b5..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/camunda/model/SoActiveInfraRequests.java +++ /dev/null @@ -1,196 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.camunda.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - * @author waqas.ikram@ericsson.com - * - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class SoActiveInfraRequests { - - private String requestId; - private String serviceInstanceId; - private String networkId; - private String startTime; - private String endTime; - private String requestStatus; - private String serviceInstanceName; - private String serviceType; - - /** - * @return the requestId - */ - public String getRequestId() { - return requestId; - } - - /** - * @param requestId the requestId to set - */ - public void setRequestId(final String requestId) { - this.requestId = requestId; - } - - /** - * @return the serviceInstanceId - */ - public String getServiceInstanceId() { - return serviceInstanceId; - } - - /** - * @param serviceInstanceId the serviceInstanceId to set - */ - public void setServiceInstanceId(final String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } - - /** - * @return the networkId - */ - public String getNetworkId() { - return networkId; - } - - /** - * @param networkId the networkId to set - */ - public void setNetworkId(final String networkId) { - this.networkId = networkId; - } - - /** - * @return the startTime - */ - public String getStartTime() { - return startTime; - } - - /** - * @param startTime the startTime to set - */ - public void setStartTime(final String startTime) { - this.startTime = startTime; - } - - /** - * @return the endTime - */ - public String getEndTime() { - return endTime; - } - - /** - * @param endTime the endTime to set - */ - public void setEndTime(final String endTime) { - this.endTime = endTime; - } - - /** - * @return the requestStatus - */ - public String getRequestStatus() { - return requestStatus; - } - - /** - * @param requestStatus the requestStatus to set - */ - public void setRequestStatus(final String requestStatus) { - this.requestStatus = requestStatus; - } - - /** - * @return the serviceInstanceName - */ - public String getServiceInstanceName() { - return serviceInstanceName; - } - - /** - * @param serviceInstanceName the serviceInstanceName to set - */ - public void setServiceInstanceName(final String serviceInstanceName) { - this.serviceInstanceName = serviceInstanceName; - } - - /** - * @return the serviceType - */ - public String getServiceType() { - return serviceType; - } - - /** - * @param serviceType the serviceType to set - */ - public void setServiceType(final String serviceType) { - this.serviceType = serviceType; - } - - @JsonIgnore - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); - result = prime * result + ((networkId == null) ? 0 : networkId.hashCode()); - result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); - result = prime * result + ((requestStatus == null) ? 0 : requestStatus.hashCode()); - result = prime * result + ((serviceInstanceId == null) ? 0 : serviceInstanceId.hashCode()); - result = prime * result + ((serviceInstanceName == null) ? 0 : serviceInstanceName.hashCode()); - result = prime * result + ((serviceType == null) ? 0 : serviceType.hashCode()); - result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); - return result; - } - - @JsonIgnore - @Override - public boolean equals(final Object obj) { - if (obj instanceof SoActiveInfraRequests) { - SoActiveInfraRequests other = (SoActiveInfraRequests) obj; - return isEqual(requestId, other.requestId) && isEqual(serviceInstanceId, other.serviceInstanceId) - && isEqual(networkId, other.networkId) && isEqual(startTime, other.startTime) - && isEqual(endTime, other.endTime) && isEqual(requestStatus, other.requestStatus) - && isEqual(serviceInstanceName, other.serviceInstanceName) - && isEqual(serviceType, other.serviceType); - } - - return false; - } - - @JsonIgnore - @Override - public String toString() { - return "SoActiveInfraRequests [requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId - + ", networkId=" + networkId + ", startTime=" + startTime + ", endTime=" + endTime + ", requestStatus=" - + requestStatus + ", serviceInstanceName=" + serviceInstanceName + ", serviceType=" + serviceType + "]"; - } - - - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/camunda/CamundaConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/camunda/CamundaConfiguration.java deleted file mode 100644 index 2540eda04b..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/camunda/CamundaConfiguration.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.configuration.camunda; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author waqas.ikram@ericsson.com - */ - -@Configuration -public class CamundaConfiguration { - - @Bean - public CamundaRestUrlProvider camundaRestUrlProvider(@Value(value = "${camunda.rest.api.url}") final String httpURL, - @Value(value = "${camunda.rest.api.engine:default}") final String engineName) { - return new CamundaRestUrlProvider(httpURL, engineName); - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/camunda/CamundaRestUrlProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/camunda/CamundaRestUrlProvider.java deleted file mode 100644 index 9a509f037b..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/camunda/CamundaRestUrlProvider.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.configuration.camunda; - -import java.net.URI; - -import org.springframework.stereotype.Service; -import org.springframework.web.util.UriComponentsBuilder; - -/** - * @author waqas.ikram@ericsson.com - */ -@Service -public class CamundaRestUrlProvider { - - private static final String HISTORY_PATH = "history"; - private final URI baseUri; - - public CamundaRestUrlProvider(final String httpUrl, final String engineName) { - this.baseUri = UriComponentsBuilder.fromHttpUrl(httpUrl).path(engineName).build().toUri(); - } - - /** - * see {@link Get - * Process Instances}. - * - * @param requestId the request ID - * @return URL - */ - public String getHistoryProcessInstanceUrl(final String requestId) { - return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("process-instance") - .query("variables=requestId_eq_{requestID}").buildAndExpand(requestId).toString(); - } - - /** - * see {@link Get - * Single Process Instance}. - * - * @param processInstanceId the process instance id. - * @return URL - */ - public String getSingleProcessInstanceUrl(final String processInstanceId) { - return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("process-instance") - .pathSegment(processInstanceId).build().toString(); - } - - /** - * see {@link Get BPMN 2.0 - * XML}. - * - * @param processDefinitionId the process definition id. - * @return URL - */ - public String getProcessDefinitionUrl(final String processDefinitionId) { - return UriComponentsBuilder.fromUri(baseUri).pathSegment("process-definition").pathSegment(processDefinitionId) - .pathSegment("xml").build().toString(); - } - - /** - * see {@link Get - * Single Activity Instance (Historic)}. - * - * @param processInstanceId the process instance id. - * @return URL - */ - public String getActivityInstanceUrl(final String processInstanceId) { - return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("activity-instance") - .query("processInstanceId={processInstanceId}").queryParam("sortBy", "startTime") - .queryParam("sortOrder", "asc").buildAndExpand(processInstanceId).toString(); - } - - /** - * see {@link Get - * Single Variable Instance}. - * - * @param processInstanceId the process instance id. - * @return URL - */ - public String getProcessInstanceVariablesUrl(final String processInstanceId) { - return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("variable-instance") - .query("processInstanceId={processInstanceId}").buildAndExpand(processInstanceId).toString(); - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/database/DatabaseConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/database/DatabaseConfiguration.java deleted file mode 100644 index 3d2b529d9a..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/database/DatabaseConfiguration.java +++ /dev/null @@ -1,37 +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.onap.so.montoring.configuration.database; - - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class DatabaseConfiguration { - - @Bean - public DatabaseUrlProvider databaseUrlProvider( - @Value(value = "${mso.database.rest.api.url}") final String baseUrl) { - return new DatabaseUrlProvider(baseUrl); - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/database/DatabaseUrlProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/database/DatabaseUrlProvider.java deleted file mode 100644 index 8235b9272b..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/database/DatabaseUrlProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.configuration.database; - -import java.net.URI; - -import org.springframework.web.util.UriComponentsBuilder; - -/** - * @author waqas.ikram@ericsson.com - * - */ -public class DatabaseUrlProvider { - - private final URI baseUri; - - public DatabaseUrlProvider(final String baseUrl) { - this.baseUri = UriComponentsBuilder.fromHttpUrl(baseUrl).build().toUri(); - } - - public String getSearchUrl(final long from, final long to, final Integer maxResult) { - final UriComponentsBuilder builder = UriComponentsBuilder.fromUri(baseUri).pathSegment("v1") - .pathSegment("getInfraActiveRequests").queryParam("from", from).queryParam("to", to); - if (maxResult != null) { - return builder.queryParam("maxResult", maxResult).build().toString(); - } - - return builder.build().toString(); - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java deleted file mode 100644 index 0db1e51ce2..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.configuration.rest; - -import java.io.IOException; - -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpRequestExecution; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; - -/** - * @author waqas.ikram@ericsson.com - * - */ -public class BasicAuthorizationHttpRequestInterceptor implements ClientHttpRequestInterceptor { - - private final String authorization; - - public BasicAuthorizationHttpRequestInterceptor(final String authorization) { - this.authorization = authorization; - } - - @Override - public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, - final ClientHttpRequestExecution execution) throws IOException { - final HttpHeaders headers = request.getHeaders(); - headers.add("Authorization", authorization); - return execution.execute(request, body); - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/HttpClientConnectionConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/HttpClientConnectionConfiguration.java deleted file mode 100644 index a465b53c71..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/HttpClientConnectionConfiguration.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.configuration.rest; - -import java.util.concurrent.TimeUnit; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -@Service -public class HttpClientConnectionConfiguration { - - @Value(value = "${rest.http.client.configuration.connTimeOutInSec:10}") - private int connectionTimeOutInSeconds; - - @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:180}") - private int socketTimeOutInSeconds; - - @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:600}") - private int timeToLiveInSeconds; - - @Value(value = "${rest.http.client.configuration.maxConnections:10}") - private int maxConnections; - - @Value(value = "${rest.http.client.configuration.maxConnectionsPerRoute:2}") - private int maxConnectionsPerRoute; - - /** - * @return the socketTimeOut - */ - public int getSocketTimeOutInMiliSeconds() { - return (int) TimeUnit.SECONDS.toMillis(socketTimeOutInSeconds); - } - - /** - * @return the maxConnections - */ - public int getMaxConnections() { - return maxConnections; - } - - /** - * @return the maxConnectionsPerRoute - */ - public int getMaxConnectionsPerRoute() { - return maxConnectionsPerRoute; - } - - /** - * @return the connectionTimeOut - */ - public int getConnectionTimeOutInMilliSeconds() { - return (int) TimeUnit.SECONDS.toMillis(connectionTimeOutInSeconds); - } - - /** - * @return the timeToLive - */ - public int getTimeToLiveInMins() { - return (int) TimeUnit.SECONDS.toMinutes(timeToLiveInSeconds); - } - - @Override - public String toString() { - return "HttpClientConnectionConfiguration [connectionTimeOutInSeconds=" + connectionTimeOutInSeconds - + ", socketTimeOutInSeconds=" + socketTimeOutInSeconds + ", timeToLiveInSeconds=" + timeToLiveInSeconds - + ", maxConnections=" + maxConnections + ", maxConnectionsPerRoute=" + maxConnectionsPerRoute + "]"; - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/HttpServiceProviderConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/HttpServiceProviderConfiguration.java deleted file mode 100644 index 31cd12bebc..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/HttpServiceProviderConfiguration.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.configuration.rest; - -import static org.onap.so.montoring.configuration.rest.RestTemplateConfigration.CAMUNDA_REST_TEMPLATE; -import static org.onap.so.montoring.configuration.rest.RestTemplateConfigration.DATABASE_REST_TEMPLATE; - -import org.onap.so.montoring.rest.service.HttpRestServiceProvider; -import org.onap.so.montoring.rest.service.HttpRestServiceProviderImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.web.client.RestTemplate; - -/** - * @author waqas.ikram@ericsson.com - * - */ -@Configuration -public class HttpServiceProviderConfiguration { - - public static final String DATABASE_HTTP_REST_SERVICE_PROVIDER = "databaseHttpRestServiceProvider"; - public static final String CAMUNDA_HTTP_REST_SERVICE_PROVIDER = "camundaHttpRestServiceProvider"; - - @Bean - @Qualifier(CAMUNDA_HTTP_REST_SERVICE_PROVIDER) - public HttpRestServiceProvider camundaHttpRestServiceProvider( - @Qualifier(CAMUNDA_REST_TEMPLATE) @Autowired final RestTemplate restTemplate, - @Value(value = "${camunda.rest.api.auth:#{null}}") final String authorization) { - return getHttpRestServiceProvider(restTemplate, authorization); - } - - @Bean - @Qualifier(DATABASE_HTTP_REST_SERVICE_PROVIDER) - public HttpRestServiceProvider databaseHttpRestServiceProvider( - @Qualifier(DATABASE_REST_TEMPLATE) @Autowired final RestTemplate restTemplate, - @Value(value = "${mso.database.rest.api.auth:#{null}}") final String authorization) { - - return getHttpRestServiceProvider(restTemplate, authorization); - } - - private HttpRestServiceProvider getHttpRestServiceProvider(final RestTemplate restTemplate, - final String authorization) { - if (authorization != null && !authorization.isEmpty()) { - final ClientHttpRequestInterceptor authorizationInterceptor = - new BasicAuthorizationHttpRequestInterceptor(authorization); - restTemplate.getInterceptors().add(authorizationInterceptor); - } - return new HttpRestServiceProviderImpl(restTemplate); - } - - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/RestTemplateConfigration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/RestTemplateConfigration.java deleted file mode 100644 index a30628b1d5..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/configuration/rest/RestTemplateConfigration.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.so.montoring.configuration.rest; - -import java.util.concurrent.TimeUnit; - -import org.apache.http.client.config.RequestConfig; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.web.client.RestTemplate; - -/** - * @author waqas.ikram@ericsson.com - */ -@Configuration -public class RestTemplateConfigration { - - public static final String DATABASE_REST_TEMPLATE = "databaseRestTemplate"; - - public static final String CAMUNDA_REST_TEMPLATE = "camundaRestTemplate"; - - @Autowired - private HttpClientConnectionConfiguration clientConnectionConfiguration; - - @Bean - @Qualifier(CAMUNDA_REST_TEMPLATE) - public RestTemplate camundaRestTemplate() { - return new RestTemplate(httpComponentsClientHttpRequestFactory()); - } - - @Bean - @Qualifier(DATABASE_REST_TEMPLATE) - public RestTemplate dataBasecamundaRestTemplate() { - return new RestTemplate(httpComponentsClientHttpRequestFactory()); - } - - @Bean - public HttpComponentsClientHttpRequestFactory httpComponentsClientHttpRequestFactory() { - return new HttpComponentsClientHttpRequestFactory(httpClient()); - } - - @Bean - public CloseableHttpClient httpClient() { - return HttpClientBuilder.create().setConnectionManager(poolingHttpClientConnectionManager()) - .setMaxConnPerRoute(clientConnectionConfiguration.getMaxConnectionsPerRoute()) - .setMaxConnTotal(clientConnectionConfiguration.getMaxConnections()) - .setDefaultRequestConfig(requestConfig()).build(); - } - - @Bean - public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() { - return new PoolingHttpClientConnectionManager(clientConnectionConfiguration.getTimeToLiveInMins(), - TimeUnit.MINUTES); - } - - @Bean - public RequestConfig requestConfig() { - return RequestConfig.custom().setSocketTimeout(clientConnectionConfiguration.getSocketTimeOutInMiliSeconds()) - .setConnectTimeout(clientConnectionConfiguration.getConnectionTimeOutInMilliSeconds()).build(); - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/db/service/DatabaseServiceProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/db/service/DatabaseServiceProvider.java deleted file mode 100644 index b8481803e2..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/db/service/DatabaseServiceProvider.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.db.service; - -import java.util.List; -import java.util.Map; - -import org.onap.so.montoring.model.SoInfraRequest; - - -/** - * @author waqas.ikram@ericsson.com - */ -public interface DatabaseServiceProvider { - - List getSoInfraRequest(final Map filters, final long startTime, - final long endTime, final Integer maxResult); - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/db/service/DatabaseServiceProviderImpl.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/db/service/DatabaseServiceProviderImpl.java deleted file mode 100644 index f6cbc3c297..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/db/service/DatabaseServiceProviderImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.db.service; - -import static org.onap.so.montoring.configuration.rest.HttpServiceProviderConfiguration.DATABASE_HTTP_REST_SERVICE_PROVIDER; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.onap.so.montoring.camunda.model.SoActiveInfraRequests; -import org.onap.so.montoring.configuration.database.DatabaseUrlProvider; -import org.onap.so.montoring.model.SoInfraRequest; -import org.onap.so.montoring.model.SoInfraRequestBuilder; -import org.onap.so.montoring.rest.service.HttpRestServiceProvider; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import com.google.common.base.Optional; - -/** - * @author waqas.ikram@ericsson.com - */ -@Service -public class DatabaseServiceProviderImpl implements DatabaseServiceProvider { - - private final DatabaseUrlProvider urlProvider; - - private final HttpRestServiceProvider httpRestServiceProvider; - - @Autowired - public DatabaseServiceProviderImpl(final DatabaseUrlProvider urlProvider, - @Qualifier(DATABASE_HTTP_REST_SERVICE_PROVIDER) @Autowired final HttpRestServiceProvider httpRestServiceProvider) { - this.urlProvider = urlProvider; - this.httpRestServiceProvider = httpRestServiceProvider; - } - - @Override - public List getSoInfraRequest(final Map filters, final long startTime, - final long endTime, final Integer maxResult) { - final String url = urlProvider.getSearchUrl(startTime, endTime, maxResult); - - final Optional optionalRequests = - httpRestServiceProvider.postHttpRequest(filters, url, SoActiveInfraRequests[].class); - if (optionalRequests.isPresent()) { - return getSoInfraRequest(optionalRequests.get()); - } - return Collections.emptyList(); - } - - - private List getSoInfraRequest(final SoActiveInfraRequests[] requests) { - final List result = new ArrayList<>(requests.length); - for (final SoActiveInfraRequests activeRequests : requests) { - final SoInfraRequest soInfraRequest = - new SoInfraRequestBuilder().setRequestId(activeRequests.getRequestId()) - .setServiceInstanceId(activeRequests.getServiceInstanceId()) - .setNetworkId(activeRequests.getNetworkId()).setEndTime(activeRequests.getEndTime()) - .setRequestStatus(activeRequests.getRequestStatus()) - .setServiceIstanceName(activeRequests.getServiceInstanceName()) - .setServiceType(activeRequests.getServiceType()).setStartTime(activeRequests.getStartTime()) - .build(); - result.add(soInfraRequest); - - } - return result; - } - - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/exception/InvalidRestRequestException.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/exception/InvalidRestRequestException.java deleted file mode 100644 index 8e4c751c8e..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/exception/InvalidRestRequestException.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.exception; - -/** - * @author waqas.ikram@ericsson.com - * - */ -public class InvalidRestRequestException extends RuntimeException { - private static final long serialVersionUID = -1158414939006977465L; - - public InvalidRestRequestException(final String message) { - super(message); - } - - public InvalidRestRequestException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/exception/RestProcessingException.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/exception/RestProcessingException.java deleted file mode 100644 index 2d3544ed66..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/exception/RestProcessingException.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.exception; - -/** - * @author waqas.ikram@ericsson.com - * - */ -public class RestProcessingException extends RuntimeException { - - private static final long serialVersionUID = 16862313537198441L; - - public RestProcessingException(final String message) { - super(message); - } - - public RestProcessingException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ActivityInstanceDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ActivityInstanceDetail.java deleted file mode 100644 index 5691f23622..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ActivityInstanceDetail.java +++ /dev/null @@ -1,192 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -/** - * @author waqas.ikram@ericsson.com - * - */ -public class ActivityInstanceDetail { - private final String activityId; - private final String activityName; - private final String activityType; - private final String processInstanceId; - private final String calledProcessInstanceId; - private final String startTime; - private final String endTime; - private final String durationInMilliseconds; - - public ActivityInstanceDetail(final ActivityInstanceDetailBuilder builder) { - this.activityId = builder.activityId; - this.activityName = builder.activityName; - this.activityType = builder.activityType; - this.processInstanceId = builder.processInstanceId; - this.calledProcessInstanceId = builder.calledProcessInstanceId; - this.startTime = builder.startTime; - this.endTime = builder.endTime; - this.durationInMilliseconds = builder.durationInMilliseconds; - } - - /** - * @return the activityId - */ - public String getActivityId() { - return activityId; - } - - /** - * @return the activityName - */ - public String getActivityName() { - return activityName; - } - - /** - * @return the activityType - */ - public String getActivityType() { - return activityType; - } - - /** - * @return the processInstanceId - */ - public String getProcessInstanceId() { - return processInstanceId; - } - - /** - * @return the calledProcessInstanceId - */ - public String getCalledProcessInstanceId() { - return calledProcessInstanceId; - } - - /** - * @return the startTime - */ - public String getStartTime() { - return startTime; - } - - /** - * @return the endTime - */ - public String getEndTime() { - return endTime; - } - - /** - * @return the durationInMillis - */ - public String getDurationInMillis() { - return durationInMilliseconds; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((activityId == null) ? 0 : activityId.hashCode()); - result = prime * result + ((activityName == null) ? 0 : activityName.hashCode()); - result = prime * result + ((activityType == null) ? 0 : activityType.hashCode()); - result = prime * result + ((calledProcessInstanceId == null) ? 0 : calledProcessInstanceId.hashCode()); - result = prime * result + ((durationInMilliseconds == null) ? 0 : durationInMilliseconds.hashCode()); - result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); - result = prime * result + ((processInstanceId == null) ? 0 : processInstanceId.hashCode()); - result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - - if (obj instanceof ActivityInstanceDetail) { - final ActivityInstanceDetail other = (ActivityInstanceDetail) obj; - return isEqual(activityId, other.activityId) && isEqual(activityName, other.activityName) - && isEqual(activityType, other.activityType) && isEqual(processInstanceId, other.processInstanceId) - && isEqual(calledProcessInstanceId, other.calledProcessInstanceId) - && isEqual(startTime, other.startTime) && isEqual(endTime, other.endTime) - && isEqual(durationInMilliseconds, other.durationInMilliseconds); - } - - return false; - } - - - public static final class ActivityInstanceDetailBuilder { - - private String activityId; - private String activityName; - private String activityType; - private String processInstanceId; - private String calledProcessInstanceId; - private String startTime; - private String endTime; - private String durationInMilliseconds; - - public ActivityInstanceDetailBuilder activityId(final String activityId) { - this.activityId = activityId; - return this; - } - - public ActivityInstanceDetailBuilder activityName(final String activityName) { - this.activityName = activityName; - return this; - } - - public ActivityInstanceDetailBuilder activityType(final String activityType) { - this.activityType = activityType; - return this; - } - - public ActivityInstanceDetailBuilder processInstanceId(final String processInstanceId) { - this.processInstanceId = processInstanceId; - return this; - } - - public ActivityInstanceDetailBuilder calledProcessInstanceId(final String calledProcessInstanceId) { - this.calledProcessInstanceId = calledProcessInstanceId; - return this; - } - - public ActivityInstanceDetailBuilder startTime(final String startTime) { - this.startTime = startTime; - return this; - } - - public ActivityInstanceDetailBuilder endTime(final String endTime) { - this.endTime = endTime; - return this; - } - - public ActivityInstanceDetailBuilder durationInMilliseconds(final String durationInMilliseconds) { - this.durationInMilliseconds = durationInMilliseconds; - return this; - } - - public ActivityInstanceDetail build() { - return new ActivityInstanceDetail(this); - } - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessDefinitionDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessDefinitionDetail.java deleted file mode 100644 index 164a3921c0..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessDefinitionDetail.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -/** - * @author waqas.ikram@ericsson.com - * - */ -public class ProcessDefinitionDetail { - - private final String processDefinitionId; - private final String processDefinitionXml; - - public ProcessDefinitionDetail(final String processDefinitionId, final String processDefinitionXml) { - this.processDefinitionId = processDefinitionId; - this.processDefinitionXml = processDefinitionXml; - } - - /** - * @return the processDefinitionId - */ - public String getProcessDefinitionId() { - return processDefinitionId; - } - - /** - * @return the processDefinitionXml - */ - public String getProcessDefinitionXml() { - return processDefinitionXml; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((processDefinitionId == null) ? 0 : processDefinitionId.hashCode()); - result = prime * result + ((processDefinitionXml == null) ? 0 : processDefinitionXml.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (obj instanceof ProcessDefinitionDetail) { - final ProcessDefinitionDetail other = (ProcessDefinitionDetail) obj; - return isEqual(processDefinitionId, other.processDefinitionId) - && isEqual(processDefinitionXml, other.processDefinitionXml); - } - return false; - } - - @Override - public String toString() { - return "ProcessDefinitionDetail [processDefinitionId=" + processDefinitionId + ", processDefinitionXml=" - + processDefinitionXml + "]"; - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceDetail.java deleted file mode 100644 index a96b6c3a0f..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceDetail.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -/** - * @author waqas.ikram@ericsson.com - */ -public class ProcessInstanceDetail { - - private final String processInstanceId; - private final String processDefinitionId; - private final String processDefinitionName; - private final String superProcessInstanceId; - - - public ProcessInstanceDetail(final String processInstanceId, final String processDefinitionId, - final String processDefinitionName, final String superProcessInstanceId) { - this.processInstanceId = processInstanceId; - this.processDefinitionId = processDefinitionId; - this.processDefinitionName = processDefinitionName; - this.superProcessInstanceId = superProcessInstanceId; - } - - /** - * @return the processInstanceId - */ - public String getProcessInstanceId() { - return processInstanceId; - } - - /** - * @return the processDefinitionId - */ - public String getProcessDefinitionId() { - return processDefinitionId; - } - - /** - * @return the processDefinitionName - */ - public String getProcessDefinitionName() { - return processDefinitionName; - } - - /** - * @return the superProcessInstanceId - */ - public String getSuperProcessInstanceId() { - return superProcessInstanceId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((processInstanceId == null) ? 0 : processInstanceId.hashCode()); - result = prime * result + ((processDefinitionId == null) ? 0 : processDefinitionId.hashCode()); - result = prime * result + ((processDefinitionName == null) ? 0 : processDefinitionName.hashCode()); - result = prime * result + ((superProcessInstanceId == null) ? 0 : superProcessInstanceId.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (obj instanceof ProcessInstanceDetail) { - final ProcessInstanceDetail other = (ProcessInstanceDetail) obj; - - return isEqual(processInstanceId, other.processInstanceId) - && isEqual(processDefinitionId, other.processDefinitionId) - && isEqual(processDefinitionName, other.processDefinitionName) - && isEqual(superProcessInstanceId, other.superProcessInstanceId); - } - return false; - } - - @Override - public String toString() { - return "ProcessInstanceDetail [processInstanceId=" + processInstanceId + ", processDefinitionId=" - + processDefinitionId + ", processDefinitionName=" + processDefinitionName + ", superProcessInstanceId=" - + superProcessInstanceId + "]"; - } - - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceIdDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceIdDetail.java deleted file mode 100644 index b0bb7acc75..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceIdDetail.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -/** - * @author waqas.ikram@ericsson.com - */ -public class ProcessInstanceIdDetail { - - private final String processInstanceId; - - - public ProcessInstanceIdDetail(final String processInstanceId) { - this.processInstanceId = processInstanceId; - } - - /** - * @return the processInstancId - */ - public String getProcessInstanceId() { - return processInstanceId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((processInstanceId == null) ? 0 : processInstanceId.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (obj instanceof ProcessInstanceIdDetail) { - final ProcessInstanceIdDetail other = (ProcessInstanceIdDetail) obj; - - return isEqual(processInstanceId, other.processInstanceId); - } - return false; - } - - @Override - public String toString() { - return "ProcessInstanceIdDetail [processInstanceId=" + processInstanceId + "]"; - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceVariableDetail.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceVariableDetail.java deleted file mode 100644 index 9674dfea4d..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/ProcessInstanceVariableDetail.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.model; - -/** - * @author waqas.ikram@ericsson.com - */ -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -public class ProcessInstanceVariableDetail { - - private final String name; - private final Object value; - private final String type; - - public ProcessInstanceVariableDetail(final String name, final Object value, final String type) { - this.name = name; - this.value = value; - this.type = type; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @return the value - */ - public Object getValue() { - return value; - } - - /** - * @return the type - */ - public String getType() { - return type; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (obj instanceof ProcessInstanceVariableDetail) { - final ProcessInstanceVariableDetail other = (ProcessInstanceVariableDetail) obj; - - return isEqual(name, other.name) && isEqual(value, other.value) && isEqual(type, other.type); - } - return false; - } - - @Override - public String toString() { - return "ProcessInstanceVariableDetail [name=" + name + ", value=" + value + ", type=" + type + "]"; - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/SoInfraRequest.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/SoInfraRequest.java deleted file mode 100644 index ca392496eb..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/SoInfraRequest.java +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.model; - -import static org.onap.so.montoring.utils.ObjectEqualsUtils.isEqual; - -/** - * @author waqas.ikram@ericsson.com - */ -public class SoInfraRequest { - - private final String requestId; - private final String serviceInstanceId; - private final String serviceIstanceName; - private final String networkId; - private final String requestStatus; - private final String serviceType; - private final String startTime; - private final String endTime; - - public SoInfraRequest(final SoInfraRequestBuilder requestBuilder) { - this.requestId = requestBuilder.getRequestId(); - this.serviceInstanceId = requestBuilder.getServiceInstanceId(); - this.serviceIstanceName = requestBuilder.getServiceIstanceName(); - this.networkId = requestBuilder.getNetworkId(); - this.requestStatus = requestBuilder.getRequestStatus(); - this.serviceType = requestBuilder.getServiceType(); - this.startTime = requestBuilder.getStartTime(); - this.endTime = requestBuilder.getEndTime(); - } - - /** - * @return the requestId - */ - public String getRequestId() { - return requestId; - } - - /** - * @return the serviceInstanceId - */ - public String getServiceInstanceId() { - return serviceInstanceId; - } - - /** - * @return the serviceIstanceName - */ - public String getServiceIstanceName() { - return serviceIstanceName; - } - - /** - * @return the networkId - */ - public String getNetworkId() { - return networkId; - } - - /** - * @return the requestStatus - */ - public String getRequestStatus() { - return requestStatus; - } - - /** - * @return the serviceType - */ - public String getServiceType() { - return serviceType; - } - - /** - * @return the startTime - */ - public String getStartTime() { - return startTime; - } - - /** - * @return the endTime - */ - public String getEndTime() { - return endTime; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); - result = prime * result + ((networkId == null) ? 0 : networkId.hashCode()); - result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); - result = prime * result + ((requestStatus == null) ? 0 : requestStatus.hashCode()); - result = prime * result + ((serviceInstanceId == null) ? 0 : serviceInstanceId.hashCode()); - result = prime * result + ((serviceIstanceName == null) ? 0 : serviceIstanceName.hashCode()); - result = prime * result + ((serviceType == null) ? 0 : serviceType.hashCode()); - result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (obj instanceof SoInfraRequest) { - final SoInfraRequest other = (SoInfraRequest) obj; - return isEqual(requestId, other.requestId) && isEqual(serviceInstanceId, other.serviceInstanceId) - && isEqual(serviceIstanceName, other.serviceIstanceName) && isEqual(networkId, other.networkId) - && isEqual(requestStatus, other.requestStatus) && isEqual(serviceType, other.serviceType) - && isEqual(startTime, other.startTime) && isEqual(endTime, other.endTime); - } - return false; - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/SoInfraRequestBuilder.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/SoInfraRequestBuilder.java deleted file mode 100644 index 3b996f758e..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/model/SoInfraRequestBuilder.java +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.model; - -import java.sql.Timestamp; - -/** - * @author waqas.ikram@ericsson.com - */ -public class SoInfraRequestBuilder { - - private String requestId; - private String serviceInstanceId; - private String serviceIstanceName; - private String networkId; - private String requestStatus; - private String serviceType; - private String startTime; - private String endTime; - - public SoInfraRequestBuilder setRequestId(final String requestId) { - this.requestId = requestId; - return this; - } - - public SoInfraRequestBuilder setServiceInstanceId(final String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - return this; - } - - public SoInfraRequestBuilder setServiceIstanceName(final String serviceIstanceName) { - this.serviceIstanceName = serviceIstanceName; - return this; - } - - public SoInfraRequestBuilder setNetworkId(final String networkId) { - this.networkId = networkId; - return this; - } - - public SoInfraRequestBuilder setRequestStatus(final String requestStatus) { - this.requestStatus = requestStatus; - return this; - } - - public SoInfraRequestBuilder setServiceType(final String serviceType) { - this.serviceType = serviceType; - return this; - } - - public SoInfraRequestBuilder setEndTime(final String endTime) { - this.endTime = endTime; - return this; - } - - public SoInfraRequestBuilder setEndTime(final Timestamp endTime) { - this.endTime = endTime != null ? endTime.toString() : null; - return this; - } - - - public SoInfraRequestBuilder setStartTime(final String startTime) { - this.startTime = startTime; - return this; - } - - public SoInfraRequestBuilder setStartTime(final Timestamp startTime) { - this.startTime = startTime != null ? startTime.toString() : null; - return this; - } - - public SoInfraRequest build() { - return new SoInfraRequest(this); - } - - /** - * @return the requestId - */ - public String getRequestId() { - return requestId; - } - - /** - * @return the serviceInstanceId - */ - public String getServiceInstanceId() { - return serviceInstanceId; - } - - /** - * @return the serviceIstanceName - */ - public String getServiceIstanceName() { - return serviceIstanceName; - } - - /** - * @return the networkId - */ - public String getNetworkId() { - return networkId; - } - - /** - * @return the requestStatus - */ - public String getRequestStatus() { - return requestStatus; - } - - /** - * @return the serviceType - */ - public String getServiceType() { - return serviceType; - } - - /** - * @return the startTime - */ - public String getStartTime() { - return startTime; - } - - /** - * @return the endTime - */ - public String getEndTime() { - return endTime; - } -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProvider.java deleted file mode 100644 index 81e30f1176..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.rest.service; - -import java.util.List; - -import org.onap.so.montoring.model.ActivityInstanceDetail; -import org.onap.so.montoring.model.ProcessDefinitionDetail; -import org.onap.so.montoring.model.ProcessInstanceDetail; -import org.onap.so.montoring.model.ProcessInstanceIdDetail; -import org.onap.so.montoring.model.ProcessInstanceVariableDetail; - -import com.google.common.base.Optional; - -/** - * @author waqas.ikram@ericsson.com - */ -public interface CamundaProcessDataServiceProvider { - - Optional getProcessInstanceIdDetail(final String requestId); - - Optional getSingleProcessInstanceDetail(final String processInstanceId); - - Optional getProcessDefinition(final String processDefinitionId); - - List getActivityInstance(final String processInstanceId); - - List getProcessInstanceVariable(final String processInstanceId); - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProviderImpl.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProviderImpl.java deleted file mode 100644 index 2515c8f79b..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProviderImpl.java +++ /dev/null @@ -1,179 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.rest.service; - -import static org.onap.so.montoring.configuration.rest.HttpServiceProviderConfiguration.CAMUNDA_HTTP_REST_SERVICE_PROVIDER; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.onap.so.montoring.camunda.model.ActivityInstance; -import org.onap.so.montoring.camunda.model.ProcessDefinition; -import org.onap.so.montoring.camunda.model.ProcessInstance; -import org.onap.so.montoring.camunda.model.ProcessInstanceVariable; -import org.onap.so.montoring.configuration.camunda.CamundaRestUrlProvider; -import org.onap.so.montoring.model.ActivityInstanceDetail; -import org.onap.so.montoring.model.ProcessDefinitionDetail; -import org.onap.so.montoring.model.ProcessInstanceDetail; -import org.onap.so.montoring.model.ProcessInstanceIdDetail; -import org.onap.so.montoring.model.ProcessInstanceVariableDetail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Service; - -import com.google.common.base.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author waqas.ikram@ericsson.com - */ -@Service -public class CamundaProcessDataServiceProviderImpl implements CamundaProcessDataServiceProvider { - private static final Logger LOGGER = LoggerFactory.getLogger(CamundaProcessDataServiceProviderImpl.class); - private final CamundaRestUrlProvider urlProvider; - - private final HttpRestServiceProvider httpRestServiceProvider; - - @Autowired - public CamundaProcessDataServiceProviderImpl(final CamundaRestUrlProvider urlProvider, - @Qualifier(CAMUNDA_HTTP_REST_SERVICE_PROVIDER) @Autowired final HttpRestServiceProvider httpRestServiceProvider) { - this.urlProvider = urlProvider; - this.httpRestServiceProvider = httpRestServiceProvider; - } - - @Override - public Optional getProcessInstanceIdDetail(final String requestId) { - final String url = urlProvider.getHistoryProcessInstanceUrl(requestId); - final Optional processInstances = - httpRestServiceProvider.getHttpResponse(url, ProcessInstance[].class); - - if (processInstances.isPresent()) { - final ProcessInstance[] instances = processInstances.get(); - final String message = "found process instance for request id: " + requestId + - ", result size: " + instances.length; - LOGGER.debug(message); - - if (instances.length > 0) { - for (int index = 0; index < instances.length; index++) { - final ProcessInstance processInstance = instances[index]; - if (processInstance.getSuperProcessInstanceId() == null) { - return Optional.of(new ProcessInstanceIdDetail(processInstance.getId())); - } - LOGGER.debug("found sub process instance id with super process instanceId: " + - processInstance.getSuperProcessInstanceId()); - } - } - } - LOGGER.error("Unable to find process intance for request id: " + requestId); - return Optional.absent(); - } - - @Override - public Optional getSingleProcessInstanceDetail(final String processInstanceId) { - final String url = urlProvider.getSingleProcessInstanceUrl(processInstanceId); - final Optional processInstances = - httpRestServiceProvider.getHttpResponse(url, ProcessInstance.class); - - if (processInstances.isPresent()) { - final ProcessInstance processInstance = processInstances.get(); - - final ProcessInstanceDetail instanceDetail = - new ProcessInstanceDetail(processInstance.getId(), processInstance.getProcessDefinitionId(), - processInstance.getProcessDefinitionName(), processInstance.getSuperProcessInstanceId()); - return Optional.of(instanceDetail); - - } - LOGGER.error("Unable to find process intance for id: " + processInstanceId); - return Optional.absent(); - } - - - @Override - public Optional getProcessDefinition(final String processDefinitionId) { - final String url = urlProvider.getProcessDefinitionUrl(processDefinitionId); - final Optional response = - httpRestServiceProvider.getHttpResponse(url, ProcessDefinition.class); - if (response.isPresent()) { - final ProcessDefinition processDefinition = response.get(); - final String xmlDefinition = processDefinition.getBpmn20Xml(); - if (xmlDefinition != null) { - return Optional.of(new ProcessDefinitionDetail(processDefinitionId, xmlDefinition)); - } - } - LOGGER.error("Unable to find process definition for processDefinitionId: " + - processDefinitionId); - return Optional.absent(); - } - - @Override - public List getActivityInstance(final String processInstanceId) { - final String url = urlProvider.getActivityInstanceUrl(processInstanceId); - final Optional response = - httpRestServiceProvider.getHttpResponse(url, ActivityInstance[].class); - if (response.isPresent()) { - final ActivityInstance[] activityInstances = response.get(); - final List activityInstanceDetails = new ArrayList<>(activityInstances.length); - for (int index = 0; index < activityInstances.length; index++) { - - final ActivityInstance activityInstance = activityInstances[index]; - - activityInstanceDetails.add(new ActivityInstanceDetail.ActivityInstanceDetailBuilder() - .activityId(activityInstance.getActivityId()).activityName(activityInstance.getActivityName()) - .activityType(activityInstance.getActivityType()) - .calledProcessInstanceId(activityInstance.getCalledProcessInstanceId()) - .startTime(activityInstance.getStartTime()).endTime(activityInstance.getEndTime()) - .durationInMilliseconds(activityInstance.getDurationInMillis()) - .processInstanceId(activityInstance.getProcessInstanceId()).build()); - - } - return activityInstanceDetails; - } - LOGGER.error("Unable to find activity intance detail for process instance id: " + - processInstanceId); - return Collections.emptyList(); - } - - @Override - public List getProcessInstanceVariable(final String processInstanceId) { - final String url = urlProvider.getProcessInstanceVariablesUrl(processInstanceId); - final Optional response = - httpRestServiceProvider.getHttpResponse(url, ProcessInstanceVariable[].class); - if (response.isPresent()) { - final ProcessInstanceVariable[] instanceVariables = response.get(); - final List instanceVariableDetails = - new ArrayList<>(instanceVariables.length); - for (int index = 0; index < instanceVariables.length; index++) { - final ProcessInstanceVariable processInstanceVariable = instanceVariables[index]; - final ProcessInstanceVariableDetail instanceVariableDetail = - new ProcessInstanceVariableDetail(processInstanceVariable.getName(), - processInstanceVariable.getValue(), processInstanceVariable.getType()); - instanceVariableDetails.add(instanceVariableDetail); - } - return instanceVariableDetails; - } - LOGGER.error("Unable to find process intance variable details for process instance id: " - + processInstanceId); - return Collections.emptyList(); - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/HttpRestServiceProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/HttpRestServiceProvider.java deleted file mode 100644 index eb80ddcd78..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/HttpRestServiceProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.rest.service; - -import com.google.common.base.Optional; - -/** - * @author waqas.ikram@ericsson.com - */ -public interface HttpRestServiceProvider { - - public Optional getHttpResponse(final String url, final Class clazz); - - public Optional postHttpRequest(final Object object, final String url, final Class clazz); - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/HttpRestServiceProviderImpl.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/HttpRestServiceProviderImpl.java deleted file mode 100644 index b5cafcf1ed..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/rest/service/HttpRestServiceProviderImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.rest.service; - -import org.onap.so.montoring.exception.InvalidRestRequestException; -import org.onap.so.montoring.exception.RestProcessingException; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.RestClientException; -import org.springframework.web.client.RestTemplate; - -import com.google.common.base.Optional; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author waqas.ikram@ericsson.com - */ -public class HttpRestServiceProviderImpl implements HttpRestServiceProvider { - - private static final Logger LOGGER = LoggerFactory.getLogger(HttpRestServiceProviderImpl.class); - private final RestTemplate restTemplate; - - public HttpRestServiceProviderImpl(final RestTemplate restTemplate) { - this.restTemplate = restTemplate; - } - - @Override - public Optional getHttpResponse(final String url, final Class clazz) { - LOGGER.trace("Will invoke HTTP GET using URL: " + url); - try { - final ResponseEntity response = restTemplate.exchange(url, HttpMethod.GET, null, clazz); - if (!response.getStatusCode().equals(HttpStatus.OK)) { - final String message = "Unable to invoke HTTP GET using URL: " + url + - ", Response Code: " + response.getStatusCode(); - LOGGER.error(message); - return Optional.absent(); - } - - if (response.hasBody()) { - return Optional.of(response.getBody()); - } - } catch (final HttpClientErrorException httpClientErrorException) { - final String message = "Unable to invoke HTTP GET using url: " + url + ", Response: " + - httpClientErrorException.getRawStatusCode(); - LOGGER.error(message, httpClientErrorException); - final int rawStatusCode = httpClientErrorException.getRawStatusCode(); - if (rawStatusCode == HttpStatus.BAD_REQUEST.value() || rawStatusCode == HttpStatus.NOT_FOUND.value()) { - throw new InvalidRestRequestException("No result found for given url: " + url); - } - throw new RestProcessingException("Unable to invoke HTTP GET using URL: " + url); - - } catch (final RestClientException restClientException) { - LOGGER.error("Unable to invoke HTTP GET using url: " + url, restClientException); - throw new RestProcessingException("Unable to invoke HTTP GET using URL: " + - url, restClientException); - } - - return Optional.absent(); - } - - @Override - public Optional postHttpRequest(final Object object, final String url, final Class clazz) { - try { - final HttpEntity request = new HttpEntity<>(object); - final ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, request, clazz); - if (!response.getStatusCode().equals(HttpStatus.OK)) { - final String message = "Unable to invoke HTTP GET using URL: " + url + - ", Response Code: " + response.getStatusCode(); - LOGGER.error(message); - return Optional.absent(); - } - - if (response.hasBody()) { - return Optional.of(response.getBody()); - } - - } catch (final HttpClientErrorException httpClientErrorException) { - final String message = "Unable to invoke HTTP POST using url: " + url + - ", Response: " + httpClientErrorException.getRawStatusCode(); - LOGGER.error(message, httpClientErrorException); - final int rawStatusCode = httpClientErrorException.getRawStatusCode(); - if (rawStatusCode == HttpStatus.BAD_REQUEST.value() || rawStatusCode == HttpStatus.NOT_FOUND.value()) { - throw new InvalidRestRequestException("No result found for given url: " + url); - } - throw new RestProcessingException("Unable to invoke HTTP POST using URL: " + url); - - } catch (final RestClientException restClientException) { - LOGGER.error("Unable to invoke HTTP POST using url: " + url, restClientException); - throw new RestProcessingException("Unable to invoke HTTP POST using URL: " - + url, restClientException); - } - - return Optional.absent(); - } - - -} diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/utils/ObjectEqualsUtils.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/utils/ObjectEqualsUtils.java deleted file mode 100644 index 496ad26bea..0000000000 --- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/montoring/utils/ObjectEqualsUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.montoring.utils; - -/** - * @author waqas.ikram@ericsson.com - */ -public class ObjectEqualsUtils { - - private ObjectEqualsUtils() {} - - public static boolean isEqual(final Object objectA, final Object objectB) { - if (objectA == null) { - return objectB == null; - } - return objectA.equals(objectB); - } - -} diff --git a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/CamundaConfigurationTest.java b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/CamundaConfigurationTest.java index de891dd01b..fb56d841e4 100644 --- a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/CamundaConfigurationTest.java +++ b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/CamundaConfigurationTest.java @@ -17,13 +17,13 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.montoring.configuration; +package org.onap.so.monitoring.configuration; import static org.junit.Assert.assertEquals; import org.junit.Test; -import org.onap.so.montoring.configuration.camunda.CamundaConfiguration; -import org.onap.so.montoring.configuration.camunda.CamundaRestUrlProvider; +import org.onap.so.monitoring.configuration.camunda.CamundaConfiguration; +import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider; /** diff --git a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/CamundaRestUrlProviderTest.java b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/CamundaRestUrlProviderTest.java index 5fa9b447e6..3cd8a33d77 100644 --- a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/CamundaRestUrlProviderTest.java +++ b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/CamundaRestUrlProviderTest.java @@ -17,14 +17,14 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.montoring.configuration; +package org.onap.so.monitoring.configuration; import static org.junit.Assert.assertEquals; import java.util.UUID; import org.junit.Test; -import org.onap.so.montoring.configuration.camunda.CamundaRestUrlProvider; +import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider; /** * @author waqas.ikram@ericsson.com diff --git a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/HttpServiceProviderConfigurationTest.java b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/HttpServiceProviderConfigurationTest.java index 13a2f98d57..1b3e168c12 100644 --- a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/HttpServiceProviderConfigurationTest.java +++ b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/HttpServiceProviderConfigurationTest.java @@ -17,13 +17,13 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.montoring.configuration; +package org.onap.so.monitoring.configuration; import static org.junit.Assert.assertNotNull; import org.junit.Test; -import org.onap.so.montoring.configuration.rest.HttpServiceProviderConfiguration; -import org.onap.so.montoring.rest.service.HttpRestServiceProvider; +import org.onap.so.monitoring.configuration.rest.HttpServiceProviderConfiguration; +import org.onap.so.monitoring.rest.service.HttpRestServiceProvider; import org.springframework.web.client.RestTemplate; /** diff --git a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/PojoClassesTests.java b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/PojoClassesTests.java index 93dfa79990..f51d4c64b1 100644 --- a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/PojoClassesTests.java +++ b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/PojoClassesTests.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.montoring.configuration; +package org.onap.so.monitoring.configuration; import static org.junit.Assert.assertFalse; @@ -46,14 +46,14 @@ public class PojoClassesTests { @Test public void test_camunda_module_pojo_classes() throws ClassNotFoundException { - test("org.onap.so.montoring.camunda.model"); - assertEqualMethod("org.onap.so.montoring.camunda.model"); + test("org.onap.so.monitoring.camunda.model"); + assertEqualMethod("org.onap.so.monitoring.camunda.model"); } @Test public void test_so_monitoring_pojo_classes() throws ClassNotFoundException { - test("org.onap.so.montoring.model"); - assertEqualMethod("org.onap.so.montoring.model"); + test("org.onap.so.monitoring.model"); + assertEqualMethod("org.onap.so.monitoring.model"); } public void assertEqualMethod(final String pojoPackage) throws ClassNotFoundException { diff --git a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/database/DatabaseUrlProviderTest.java b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/database/DatabaseUrlProviderTest.java index d9d260992d..d820e9435d 100644 --- a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/database/DatabaseUrlProviderTest.java +++ b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/configuration/database/DatabaseUrlProviderTest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.montoring.configuration.database; +package org.onap.so.monitoring.configuration.database; import static org.junit.Assert.assertEquals; diff --git a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java index 3bb7b289e4..8c06426217 100644 --- a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java +++ b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/db/api/DatabaseServiceProviderTest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.montoring.db.api; +package org.onap.so.monitoring.db.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -33,12 +33,12 @@ import java.util.Map; import java.util.UUID; import org.junit.Test; -import org.onap.so.montoring.camunda.model.SoActiveInfraRequests; -import org.onap.so.montoring.configuration.database.DatabaseUrlProvider; -import org.onap.so.montoring.db.service.DatabaseServiceProvider; -import org.onap.so.montoring.db.service.DatabaseServiceProviderImpl; -import org.onap.so.montoring.model.SoInfraRequest; -import org.onap.so.montoring.rest.service.HttpRestServiceProvider; +import org.onap.so.monitoring.camunda.model.SoActiveInfraRequests; +import org.onap.so.monitoring.configuration.database.DatabaseUrlProvider; +import org.onap.so.monitoring.db.service.DatabaseServiceProvider; +import org.onap.so.monitoring.db.service.DatabaseServiceProviderImpl; +import org.onap.so.monitoring.model.SoInfraRequest; +import org.onap.so.monitoring.rest.service.HttpRestServiceProvider; import com.google.common.base.Optional; diff --git a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProviderTest.java b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProviderTest.java index 351c476ca1..c3930df196 100644 --- a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProviderTest.java +++ b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/rest/service/CamundaProcessDataServiceProviderTest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.montoring.rest.service; +package org.onap.so.monitoring.rest.service; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -29,15 +29,15 @@ import java.util.List; import java.util.UUID; import org.junit.Test; -import org.onap.so.montoring.camunda.model.ActivityInstance; -import org.onap.so.montoring.camunda.model.ProcessDefinition; -import org.onap.so.montoring.camunda.model.ProcessInstance; -import org.onap.so.montoring.camunda.model.ProcessInstanceVariable; -import org.onap.so.montoring.configuration.camunda.CamundaRestUrlProvider; -import org.onap.so.montoring.model.ActivityInstanceDetail; -import org.onap.so.montoring.model.ProcessDefinitionDetail; -import org.onap.so.montoring.model.ProcessInstanceIdDetail; -import org.onap.so.montoring.model.ProcessInstanceVariableDetail; +import org.onap.so.monitoring.camunda.model.ActivityInstance; +import org.onap.so.monitoring.camunda.model.ProcessDefinition; +import org.onap.so.monitoring.camunda.model.ProcessInstance; +import org.onap.so.monitoring.camunda.model.ProcessInstanceVariable; +import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider; +import org.onap.so.monitoring.model.ActivityInstanceDetail; +import org.onap.so.monitoring.model.ProcessDefinitionDetail; +import org.onap.so.monitoring.model.ProcessInstanceIdDetail; +import org.onap.so.monitoring.model.ProcessInstanceVariableDetail; import com.google.common.base.Optional; diff --git a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/utils/ObjectEqualsUtilsTest.java b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/utils/ObjectEqualsUtilsTest.java index b1ad4eae12..dd363abe3a 100644 --- a/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/utils/ObjectEqualsUtilsTest.java +++ b/so-monitoring/so-monitoring-handler/src/test/java/org/onap/so/montoring/utils/ObjectEqualsUtilsTest.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.montoring.utils; +package org.onap.so.monitoring.utils; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java index de2263be3f..155b4e65a4 100644 --- a/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java +++ b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringController.java @@ -32,16 +32,16 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; -import org.onap.so.montoring.db.service.DatabaseServiceProvider; -import org.onap.so.montoring.exception.InvalidRestRequestException; -import org.onap.so.montoring.exception.RestProcessingException; -import org.onap.so.montoring.model.ActivityInstanceDetail; -import org.onap.so.montoring.model.ProcessDefinitionDetail; -import org.onap.so.montoring.model.ProcessInstanceDetail; -import org.onap.so.montoring.model.ProcessInstanceIdDetail; -import org.onap.so.montoring.model.ProcessInstanceVariableDetail; -import org.onap.so.montoring.model.SoInfraRequest; -import org.onap.so.montoring.rest.service.CamundaProcessDataServiceProvider; +import org.onap.so.monitoring.db.service.DatabaseServiceProvider; +import org.onap.so.monitoring.exception.InvalidRestRequestException; +import org.onap.so.monitoring.exception.RestProcessingException; +import org.onap.so.monitoring.model.ActivityInstanceDetail; +import org.onap.so.monitoring.model.ProcessDefinitionDetail; +import org.onap.so.monitoring.model.ProcessInstanceDetail; +import org.onap.so.monitoring.model.ProcessInstanceIdDetail; +import org.onap.so.monitoring.model.ProcessInstanceVariableDetail; +import org.onap.so.monitoring.model.SoInfraRequest; +import org.onap.so.monitoring.rest.service.CamundaProcessDataServiceProvider; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java b/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java index 13953b0331..ca2a88d4a8 100644 --- a/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java +++ b/so-monitoring/so-monitoring-service/src/test/java/org/onap/so/monitoring/rest/api/SoMonitoringControllerTest.java @@ -22,7 +22,7 @@ package org.onap.so.monitoring.rest.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.onap.so.montoring.configuration.rest.RestTemplateConfigration.CAMUNDA_REST_TEMPLATE; +import static org.onap.so.monitoring.configuration.rest.RestTemplateConfiguration.CAMUNDA_REST_TEMPLATE; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; @@ -41,12 +41,12 @@ import javax.ws.rs.core.Response.Status; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.montoring.configuration.camunda.CamundaRestUrlProvider; -import org.onap.so.montoring.model.ActivityInstanceDetail; -import org.onap.so.montoring.model.ProcessDefinitionDetail; -import org.onap.so.montoring.model.ProcessInstanceDetail; -import org.onap.so.montoring.model.ProcessInstanceIdDetail; -import org.onap.so.montoring.model.ProcessInstanceVariableDetail; +import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider; +import org.onap.so.monitoring.model.ActivityInstanceDetail; +import org.onap.so.monitoring.model.ProcessDefinitionDetail; +import org.onap.so.monitoring.model.ProcessInstanceDetail; +import org.onap.so.monitoring.model.ProcessInstanceIdDetail; +import org.onap.so.monitoring.model.ProcessInstanceVariableDetail; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; -- cgit 1.2.3-korg