summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--holmes-actions/pom.xml79
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiJsonParserUtil.java9
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java6
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn2.java7
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java2
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java2
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/aai/CorrelationUtil.java11
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmsCorrelation.java67
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/config/GsonConfig.java39
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/config/MQConfig.java35
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/constant/AlarmConst.java13
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/database/DatabaseConfiguration.java78
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java40
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java10
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java2
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java8
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java6
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/BaseService.java34
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/Lazy.java34
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PostBaseService.java34
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreBaseService.java34
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreLoad.java34
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreServiceLoad.java35
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundle.java367
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleBuider.java42
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/IOCApplication.java42
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/ServiceLocatorManaged.java51
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceBinder.java52
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceLocatorHolder.java36
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java14
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java16
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java4
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java8
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java11
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/CommonUtils.java5
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java13
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/DbDaoUtil.java91
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java1
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java2
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/RestExceptionHandler.java34
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/SpringContextUtil.java45
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilter.java8
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmsCorrelationTest.java121
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/config/MQConfigTest.java28
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleTest.java36
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/engine/dao/EngineEntityMapperTest.java2
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java12
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java12
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java2
-rw-r--r--holmes-actions/src/test/java/org/onap/holmes/common/utils/DbDaoUtilTest.java151
-rw-r--r--pom.xml63
51 files changed, 419 insertions, 1469 deletions
diff --git a/holmes-actions/pom.xml b/holmes-actions/pom.xml
index f5c884d..13555ba 100644
--- a/holmes-actions/pom.xml
+++ b/holmes-actions/pom.xml
@@ -43,29 +43,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-core</artifactId>
- <scope>provided</scope>
- <exclusions>
- <exclusion>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.fasterxml.jackson.dataformat</groupId>
- <artifactId>jackson-dataformat-yaml</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<exclusions>
@@ -90,7 +67,6 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.13.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
@@ -111,11 +87,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-jdbi</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
@@ -164,6 +135,49 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-autoconfigure</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jdbi</groupId>
+ <artifactId>jdbi3-postgres</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jdbi</groupId>
+ <artifactId>jdbi3-sqlobject</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jdbi</groupId>
+ <artifactId>jdbi3-spring4</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>42.2.13</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>5.3.13</version>
+ </dependency>
</dependencies>
<build>
<resources>
@@ -182,10 +196,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.3</version>
+ <version>3.8.0</version>
<configuration>
- <source>1.8</source>
- <target>1.8</target>
+ <source>8</source>
+ <target>8</target>
+ <release>11</release>
</configuration>
</plugin>
</plugins>
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiJsonParserUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiJsonParserUtil.java
index ba66628..0a9e4f7 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiJsonParserUtil.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiJsonParserUtil.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.holmes.common.aai
* ================================================================================
- * Copyright (C) 2018-2020 Huawei. All rights reserved.
+ * Copyright (C) 2018-2021 Huawei, ZTE. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,18 +24,15 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.aai.config.AaiConfig;
import org.onap.holmes.common.config.MicroServiceConfig;
+import org.springframework.stereotype.Component;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-@Service
@Slf4j
+@Component
public class AaiJsonParserUtil {
public static String getPath(String urlTemplate, String paramName, String paramValue) {
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java
index a73eb22..1bf79f2 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery.java
@@ -14,14 +14,14 @@
package org.onap.holmes.common.aai;
import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.aai.config.AaiConfig;
import org.onap.holmes.common.aai.entity.VmEntity;
import org.onap.holmes.common.aai.entity.VnfEntity;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.JerseyClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
-import javax.inject.Inject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -30,7 +30,7 @@ import java.util.Map;
@Slf4j
public class AaiQuery {
- @Inject
+ @Autowired
private AaiResponseUtil aaiResponseUtil;
public VnfEntity getAaiVnfData(String vnfId, String vnfName) throws CorrelationException {
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn2.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn2.java
index 41eb2c0..a9d9e53 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn2.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQuery4Ccvpn2.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* org.onap.holmes.common.aai
* ================================================================================
- * Copyright (C) 2018-2020 Huawei. All rights reserved.
+ * Copyright (C) 2018-2021 Huawei, ZTE. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,10 +24,9 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.aai.config.AaiConfig;
-import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.JerseyClient;
+import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@@ -36,8 +35,8 @@ import java.util.regex.Pattern;
import static org.onap.holmes.common.aai.AaiJsonParserUtil.*;
-@Service
@Slf4j
+@Service
public class AaiQuery4Ccvpn2 {
private Map<String, Object> headers;
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java
index c557003..f9e2e5d 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiQueryMdons.java
@@ -17,13 +17,13 @@ package org.onap.holmes.common.aai;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.aai.config.AaiConfig;
import org.onap.holmes.common.config.MicroServiceConfig;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.JerseyClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MultivaluedHashMap;
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java
index 5ad4984..896e694 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/AaiResponseUtil.java
@@ -18,7 +18,6 @@ package org.onap.holmes.common.aai;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.aai.entity.RelationshipList;
import org.onap.holmes.common.aai.entity.RelationshipList.RelatedToProperty;
import org.onap.holmes.common.aai.entity.RelationshipList.Relationship;
@@ -26,6 +25,7 @@ import org.onap.holmes.common.aai.entity.RelationshipList.RelationshipData;
import org.onap.holmes.common.aai.entity.VmEntity;
import org.onap.holmes.common.aai.entity.VmResourceLink;
import org.onap.holmes.common.aai.entity.VnfEntity;
+import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/aai/CorrelationUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/aai/CorrelationUtil.java
index 6520552..51b4cf0 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/aai/CorrelationUtil.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/aai/CorrelationUtil.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2021 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
@@ -13,13 +13,14 @@
*/
package org.onap.holmes.common.aai;
-import java.util.List;
-import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.onap.holmes.common.aai.entity.RelationshipList.Relationship;
import org.onap.holmes.common.aai.entity.VmEntity;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
+import org.onap.holmes.common.utils.SpringContextUtil;
+
+import java.util.List;
+import java.util.Optional;
@Slf4j
public class CorrelationUtil {
@@ -33,7 +34,7 @@ public class CorrelationUtil {
public static final CorrelationUtil getInstance() {
if (aaiQuery == null) {
- aaiQuery = ServiceLocatorHolder.getLocator().getService(AaiQuery.class);
+ aaiQuery = SpringContextUtil.getBean(AaiQuery.class);
}
return LazyHolder.INSTANCE;
}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmsCorrelation.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmsCorrelation.java
deleted file mode 100644
index e21f97d..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmsCorrelation.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.api.entity;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.Date;
-import lombok.Data;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-@Getter
-@Setter
-@NoArgsConstructor
-public class AlarmsCorrelation {
-
- @SerializedName(value = "ruleid")
- private String ruleId;
-
- @SerializedName(value = "ruleinfo")
- private String ruleInfo;
-
- @SerializedName(value = "resulttype")
- private byte resultType;
-
- @SerializedName(value = "createtime")
- private Date createTime;
-
- @SerializedName(value = "parentalarmid")
- private long parentAlarmId;
-
- @SerializedName(value = "childalarmid")
- private long childAlarmId;
-
- private long reserve1 = -1;
-
- private long reserve2 = -1;
-
- private long reserve3 = -1;
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("[");
- sb.append("ruleId=").append(ruleId).append(",");
- sb.append("ruleInfo=").append(ruleInfo).append(",");
- sb.append("createTime=").append(createTime == null ? null : createTime.toString()).append(",");
- sb.append("parentAlarmId=").append(parentAlarmId).append(",");
- sb.append("childAlarmId=").append(childAlarmId).append(",");
- sb.append("reserve1=").append(reserve1).append(",");
- sb.append("reserve2=").append(reserve2).append(",");
- sb.append("reserve3=").append(reserve3).append("]");
- return sb.toString();
- }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/config/GsonConfig.java b/holmes-actions/src/main/java/org/onap/holmes/common/config/GsonConfig.java
new file mode 100644
index 0000000..58a8f35
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/config/GsonConfig.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2021 ZTE Corporation.
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.common.config;
+
+import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.GsonHttpMessageConverter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@Configuration
+public class GsonConfig {
+ @Bean
+ public HttpMessageConverters customConverters() {
+ Collection<HttpMessageConverter<?>> messageConverters = new ArrayList();
+
+ GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
+ messageConverters.add(gsonHttpMessageConverter);
+
+ return new HttpMessageConverters(true, messageConverters);
+ }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/config/MQConfig.java b/holmes-actions/src/main/java/org/onap/holmes/common/config/MQConfig.java
deleted file mode 100644
index 70ef0cb..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/config/MQConfig.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.holmes.common.config;
-
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-@Getter
-@Setter
-@NoArgsConstructor
-public class MQConfig {
-
- private String brokerIp;
-
- private int brokerPort;
-
- private String brokerUsername;
-
- private String brokerPassword;
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/constant/AlarmConst.java b/holmes-actions/src/main/java/org/onap/holmes/common/constant/AlarmConst.java
index ba3d80e..0cdb66d 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/constant/AlarmConst.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/constant/AlarmConst.java
@@ -16,15 +16,6 @@
package org.onap.holmes.common.constant;
public interface AlarmConst {
-
- String MQ_TOPIC_NAME_ALARMS_CORRELATION = "topic://voss/fm/alarms_correlation";
-
- String MQ_TOPIC_NAME_ALARM = "topic://voss/fm/alarm";
-
- String NFVO_PATH = "/api/umc/v1/fm/curalarms/findAll";
-
- int NFVO_STATUS_OK = 200;
-
String I18N_EN = "en";
String I18N_ZH = "zh";
@@ -33,10 +24,6 @@ public interface AlarmConst {
String ADMIN = "admin";
- int MICRO_SERVICE_STATUS_SUCCESS = 201;
-
- int MICRO_SERVICE_PORT = 8086;
-
String HTTP = "http://";
String HTTPS = "https://";
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/database/DatabaseConfiguration.java b/holmes-actions/src/main/java/org/onap/holmes/common/database/DatabaseConfiguration.java
new file mode 100644
index 0000000..101c350
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/database/DatabaseConfiguration.java
@@ -0,0 +1,78 @@
+/**
+ * Copyright 2021 ZTE Corporation.
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.database;
+
+import org.jdbi.v3.core.Jdbi;
+import org.jdbi.v3.core.mapper.RowMapper;
+import org.jdbi.v3.core.spi.JdbiPlugin;
+import org.jdbi.v3.postgres.PostgresPlugin;
+import org.jdbi.v3.sqlobject.SqlObjectPlugin;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
+
+import javax.sql.DataSource;
+import java.util.List;
+
+@Configuration
+public class DatabaseConfiguration {
+//
+// @Value("${spring.datasource.url}")
+// private String url;
+//
+// @Value("${spring.datasource.username}")
+// private String username;
+//
+// @Value("${spring.datasource.password}")
+// private String pwd;
+//
+// @Value("${spring.datasource.dirver-class-name}")
+// private String driverClass;
+//
+// @Bean
+// public DataSource driverManagerDataSource() {
+// System.out.println("======================================: " + driverClass);
+// DriverManagerDataSource ds = new DriverManagerDataSource();
+// ds.setDriverClassName(driverClass);
+// ds.setUrl(url);
+// ds.setUsername(username);
+// ds.setPassword(pwd);
+// return ds;
+// }
+
+// @Bean
+// public DataSourceTransactionManager dataSourceTransactionManager(DataSource dataSource) {
+// DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager();
+// dataSourceTransactionManager.setDataSource(dataSource);
+// return dataSourceTransactionManager;
+// }
+
+ @Bean
+ public Jdbi jdbi(DataSource dataSource) {
+ return Jdbi.create(dataSource)
+ .installPlugin(new SqlObjectPlugin())
+ .installPlugin(new PostgresPlugin());
+ }
+
+// @Bean
+// public Jdbi jdbi(DataSource ds, List<JdbiPlugin> jdbiPlugins, List<RowMapper<?>> rowMappers) {
+// TransactionAwareDataSourceProxy proxy = new TransactionAwareDataSourceProxy(ds);
+// Jdbi jdbi = Jdbi.create(proxy);
+// jdbiPlugins.forEach(plugin -> jdbi.installPlugin(plugin));
+// rowMappers.forEach(mapper -> jdbi.registerRowMapper(mapper));
+// return jdbi;
+// }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java
new file mode 100644
index 0000000..2cbb538
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/database/DbDaoUtil.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2017-2021 ZTE Corporation.
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.database;
+
+import org.jdbi.v3.core.Handle;
+import org.jdbi.v3.core.Jdbi;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DbDaoUtil {
+ private Jdbi jdbi;
+
+ @Autowired
+ public DbDaoUtil(Jdbi jdbi) {
+ this.jdbi = jdbi;
+ }
+
+ public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {
+ return jdbi.onDemand(daoClazz);
+ }
+
+ @Deprecated
+ public Handle getHandle() {
+ return jdbi.open();
+ }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java
index e9eb003..de7d74f 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/DmaapService.java
@@ -15,7 +15,6 @@
*/
package org.onap.holmes.common.dmaap;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.aai.AaiQuery;
import org.onap.holmes.common.aai.entity.RelationshipList.Relationship;
import org.onap.holmes.common.aai.entity.VmEntity;
@@ -30,8 +29,9 @@ import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.GsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
-import javax.inject.Inject;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.UUID;
@@ -45,17 +45,17 @@ public class DmaapService {
private ClosedLoopControlNameCache closedLoopControlNameCache;
private UniqueRequestIdCache uniqueRequestIdCache;
- @Inject
+ @Autowired
public void setAaiQuery(AaiQuery aaiQuery) {
this.aaiQuery = aaiQuery;
}
- @Inject
+ @Autowired
public void setClosedLoopControlNameCache(ClosedLoopControlNameCache closedLoopControlNameCache) {
this.closedLoopControlNameCache = closedLoopControlNameCache;
}
- @Inject
+ @Autowired
public void setUniqueRequestIdCache(UniqueRequestIdCache uniqueRequestIdCache) {
this.uniqueRequestIdCache = uniqueRequestIdCache;
}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java
index 23a04d6..b1c5595 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/Publisher.java
@@ -17,9 +17,9 @@ package org.onap.holmes.common.dmaap;
import lombok.Getter;
import lombok.Setter;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.dmaap.entity.PolicyMsg;
import org.onap.holmes.common.utils.JerseyClient;
+import org.springframework.stereotype.Service;
import javax.ws.rs.client.Entity;
import java.util.concurrent.TimeUnit;
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java
index 8a692b2..2d9cf99 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/ClosedLoopControlNameCache.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,15 +15,13 @@
*/
package org.onap.holmes.common.dmaap.store;
-import org.jvnet.hk2.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
-import javax.inject.Singleton;
import java.util.concurrent.ConcurrentHashMap;
-@Service
-@Singleton
+@Component
public class ClosedLoopControlNameCache extends ConcurrentHashMap<String, String> {
private static final Logger log = LoggerFactory.getLogger(ClosedLoopControlNameCache.class);
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java
index 070159e..f4e2459 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/dmaap/store/UniqueRequestIdCache.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,14 @@
*/
package org.onap.holmes.common.dmaap.store;
-import org.jvnet.hk2.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
import javax.inject.Singleton;
import java.util.concurrent.ConcurrentHashMap;
-@Service
+@Component
@Singleton
public class UniqueRequestIdCache extends ConcurrentHashMap<String, String> {
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/BaseService.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/BaseService.java
deleted file mode 100644
index 9f0ae67..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/BaseService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * basic services for identification
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface BaseService {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/Lazy.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/Lazy.java
deleted file mode 100644
index 4f7d046..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/Lazy.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * lazy loading of related services
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface Lazy {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PostBaseService.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PostBaseService.java
deleted file mode 100644
index 4787bec..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PostBaseService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * load on after basic services
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface PostBaseService {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreBaseService.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreBaseService.java
deleted file mode 100644
index 669bceb..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreBaseService.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * prior to basic service loading
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface PreBaseService {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreLoad.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreLoad.java
deleted file mode 100644
index dce3e58..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreLoad.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * load before general service
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface PreLoad {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreServiceLoad.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreServiceLoad.java
deleted file mode 100644
index 815c1d7..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/annotation/PreServiceLoad.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- *
- * load before general service,after PreLoad
- * @author hu.rui
- *
- */
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface PreServiceLoad {
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundle.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundle.java
deleted file mode 100644
index fe9ee5a..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundle.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/**
- * Copyright 2017 - 2021 ZTE Corporation.
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import com.codahale.metrics.health.HealthCheck;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Lists;
-import io.dropwizard.Configuration;
-import io.dropwizard.ConfiguredBundle;
-import io.dropwizard.lifecycle.ServerLifecycleListener;
-import io.dropwizard.servlets.tasks.Task;
-import io.dropwizard.setup.Bootstrap;
-import io.dropwizard.setup.Environment;
-import org.eclipse.jetty.util.component.LifeCycle;
-import org.glassfish.hk2.api.ServiceLocator;
-import org.glassfish.hk2.api.ServiceLocatorFactory;
-import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
-import org.glassfish.hk2.utilities.binding.AbstractBinder;
-import org.glassfish.jersey.servlet.ServletProperties;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.dropwizard.ioc.annotation.*;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceBinder;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
-import org.reflections.Reflections;
-import org.reflections.scanners.SubTypesScanner;
-import org.reflections.scanners.TypeAnnotationsScanner;
-import org.reflections.util.ClasspathHelper;
-import org.reflections.util.ConfigurationBuilder;
-import org.reflections.util.FilterBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.Path;
-import javax.ws.rs.ext.Provider;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * complete the integration of hK2 container and dropwizard
- *
- * @author hu.rui
- */
-
-public class AutoConfigBundle<T extends Configuration> implements ConfiguredBundle<T> {
-
- private static final Logger LOG = LoggerFactory.getLogger(AutoConfigBundle.class);
-
- private ServiceLocator locator;
- private Reflections reflections;
- private Set<Class<?>> services;
-
- private Bootstrap<?> bootstrap;
-
-
- AutoConfigBundle(final String packageName) {
- this(Lists.newArrayList(packageName));
- }
-
- AutoConfigBundle(List<String> packageNames) {
- FilterBuilder filterBuilder = new FilterBuilder();
-
- packageNames.stream().forEach(packageName -> filterBuilder.include(FilterBuilder.prefix(packageName)));
- ConfigurationBuilder reflectionCfg = new ConfigurationBuilder();
-
- packageNames.stream().forEach(packageName -> reflectionCfg.addUrls(ClasspathHelper.forPackage(packageName)));
-
- reflectionCfg.filterInputsBy(filterBuilder).setScanners(new SubTypesScanner(),
- new TypeAnnotationsScanner());
- reflections = new Reflections(reflectionCfg);
-
- locator = ServiceLocatorFactory.getInstance().create("dw-hk2");
-
- ServiceLocatorHolder.setLocator(locator);
-
- }
-
- public static <T extends Configuration> AutoConfigBundleBuider<T> newBuilder() {
- return new AutoConfigBundleBuider<T>();
- }
-
- @Override
- public void initialize(final Bootstrap<?> bootstrap) {
-
- this.bootstrap = bootstrap;
- registerPreLoadService();
-
- LOG.debug("Intialzing auto config bundle.");
- }
-
- private void registerPreLoadService() {
- registerService(PreLoad.class);
- }
-
-
- @Override
- public void run(final T configuration, final Environment environment) {
-
- registerConfigurationProvider(configuration, environment);
-
- registerEnvironment(environment);
- registerObjectMapper(environment);
-
- environment.getApplicationContext().getServletContext()
- .setAttribute(ServletProperties.SERVICE_LOCATOR, locator);
-
- registerService(PreBaseService.class);
- registerService(BaseService.class);
- registerService(PostBaseService.class);
- this.registerService(PreServiceLoad.class);
-
-
- registerServices();
-
- registerLifecycle(environment);
- registerServerLifecycleListeners(environment);
- registerJettyLifeCycleListener(environment);
- registerTasks(environment);
- registerHealthChecks(environment);
- registerProviders(environment);
- registerResources(environment);
-
- environment.lifecycle().manage(new ServiceLocatorManaged(locator));
-
- }
-
-
- private void registerProviders(Environment environment) {
- reflections.getSubTypesOf(Provider.class).stream().filter(services::contains)
- .forEach(providerKlass -> {
- try {
- environment.jersey().register(locator.getService(providerKlass));
- } catch (Exception e) {
- LOG.warn("", e);
- }
-
- LOG.info("Registering Dropwizard Provider, class name : {}", providerKlass.getName());
-
- });
-
- }
-
- private void registerTasks(Environment environment) {
- reflections.getSubTypesOf(Task.class).stream().filter(services::contains).forEach(taskKlass -> {
- try {
- environment.admin().addTask(locator.getService(taskKlass));
- } catch (Exception e) {
- LOG.warn("", e);
- }
- LOG.info("Registering Dropwizard Task, class name : {}", taskKlass.getName());
- });
-
- }
-
- private void registerJettyLifeCycleListener(Environment environment) {
- reflections.getSubTypesOf(LifeCycle.Listener.class).stream().filter(services::contains)
- .forEach(lifecycleListenerKlass -> {
- try {
- environment.lifecycle()
- .addLifeCycleListener(locator.getService(lifecycleListenerKlass));
- } catch (Exception e) {
- LOG.warn("", e);
- }
- LOG.info("Registering Dropwizard lifecycleListener, class name : {}",
- lifecycleListenerKlass.getName());
- });
-
- }
-
- private void registerServerLifecycleListeners(Environment environment) {
-
- reflections.getSubTypesOf(ServerLifecycleListener.class).stream().filter(services::contains)
- .forEach(serverLifecycleListenerKlass -> {
- try {
- environment.lifecycle()
- .addServerLifecycleListener(locator.getService(serverLifecycleListenerKlass));
- } catch (Exception e) {
- LOG.warn("", e);
- }
- LOG.info("Registering Dropwizard serverLifecycleListener, class name : {}",
- serverLifecycleListenerKlass.getName());
- });
-
- }
-
- private void registerLifecycle(Environment environment) {
- reflections.getSubTypesOf(LifeCycle.class).stream().filter(services::contains)
- .forEach(lifeCycleKlass -> {
- try {
- environment.lifecycle().manage(locator.getService(lifeCycleKlass));
- } catch (Exception e) {
- LOG.warn("", e);
- }
- LOG.info("Registering Dropwizard LifeCycle, class name : {}", lifeCycleKlass.getName());
- });
- }
-
- private void registerObjectMapper(Environment environment) {
-
- final ObjectMapper objectMapper = environment.getObjectMapper();
-
- ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
- @Override
- protected void configure() {
- bind(objectMapper).to(ObjectMapper.class);
-
- LOG.info("Registering Dropwizard objectMapper, class name : {}",
- objectMapper.getClass().getName());
- }
- });
-
- }
-
- private void registerEnvironment(final Environment environment) {
-
- ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
- @Override
- protected void configure() {
- bind(environment).to(Environment.class);
-
- LOG.info("Registering Dropwizard environment, class name : {}",
- environment.getClass().getName());
- }
- });
-
- }
-
- private void registerConfigurationProvider(final T configuration, final Environment environment) {
-
- ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
- @Override
- protected void configure() {
- bind(configuration);
- LOG.info("Registering Dropwizard Configuration class name:{}",
- configuration.getClass().getName());
- bind((Configuration) configuration).to(Configuration.class);
- LOG.info("Registering Dropwizard Configuration class name:{}",
- Configuration.class.getName());
- }
- });
-
- registerSubConfigure(configuration, environment);
-
- }
-
- private void registerSubConfigure(final T configuration, final Environment environment) {
- final List<Field> subDeclaredFields =
- Arrays.asList(configuration.getClass().getDeclaredFields());
- List<Field> parentDeclaredFields = Arrays.asList(Configuration.class.getDeclaredFields());
-
- List<Field> filtersubDeclaredFields = subDeclaredFields.stream()
- .filter(subDeclaredField -> !subDeclaredField.getType().isPrimitive())
- .filter(subDeclaredField -> !subDeclaredField.getType().equals(String.class))
- .filter(subDeclaredField -> !parentDeclaredFields.contains(subDeclaredField))
- .collect(Collectors.toList());
-
- ServiceLocatorUtilities.bind(locator, new AbstractBinder() {
- @Override
- protected void configure() {
- filtersubDeclaredFields.forEach(subField -> {
- subField.setAccessible(true);
- try {
- Object subConfig = subField.get(configuration);
- if (subConfig != null) {
- bind(subConfig);
- LOG.info("Registering Dropwizard Sub Configuration class name {}",
- subConfig.getClass().getName());
- }
-
- } catch (Exception e) {
- LOG.error("bind sub config:{} fail", subField);
- }
- });
- }
- });
-
- }
-
- private void registerServices() {
- services = this.reflections.getTypesAnnotatedWith(Service.class, true);
- if (!services.isEmpty()) {
- ServiceLocatorUtilities.bind(locator, new ServiceBinder(services));
- services.forEach(s -> LOG.info("Registering Dropwizard service, class name : {}", s.getName()));
- recordTimeCost(services);
- } else {
- LOG.warn("Registering Dropwizard service is empty");
- }
-
- }
-
-
- private void registerResources(final Environment environment) {
- reflections.getTypesAnnotatedWith(Path.class).stream().forEach(resourceClass -> {
-
- LOG.info("begin Registering Dropwizard resource, class name : {}", resourceClass.getName());
- try {
- Object resourceObject = locator.getService(resourceClass);
- if (resourceObject != null) {
- environment.jersey().register(resourceObject);
- LOG.info("Registering Dropwizard resource, class name : {}", resourceClass.getName());
- } else {
- LOG.warn(resourceClass.getName() + " not use Service annotation");
- }
- } catch (Exception e) {
- LOG.error("", e);
- }
- });
- }
-
- private void registerHealthChecks(final Environment env) {
- reflections.getSubTypesOf(HealthCheck.class).stream().filter(services::contains)
- .forEach(healthCheckKlass -> {
- try {
- env.healthChecks().register(healthCheckKlass.getName(),
- locator.getService(healthCheckKlass));
- } catch (Exception e) {
- LOG.warn("", e);
- }
- LOG.info("Registering Dropwizard healthCheck, class name : {}",
- healthCheckKlass.getName());
- });
- }
-
- private void registerService(Class<? extends Annotation> annotationClazz) {
-
- Set<Class<?>> services = this.reflections.getTypesAnnotatedWith(annotationClazz, true);
- if (!services.isEmpty()) {
- ServiceLocatorUtilities.bind(locator, new ServiceBinder(services));
- services.forEach(s -> LOG.info("{} Registering service, class name : {}", annotationClazz.getName(),
- s.getName()));
- recordTimeCost(services);
- } else {
- LOG.warn("Registering {} service is empty", annotationClazz.getName());
- }
- }
-
- private void recordTimeCost(Set<Class<?>> services) {
- services.stream().filter(serviceClazz -> (serviceClazz.getAnnotation(Lazy.class) == null))
- .peek(serviceClazz -> LOG.info("active service, class name : {}", serviceClazz.getName()))
- .forEach(serviceClazz -> {
- try {
- long startTime = System.currentTimeMillis();
- locator.getService(serviceClazz);
- LOG.info("active service, class name : {},cost time:{}", serviceClazz.getName(),
- (System.currentTimeMillis() - startTime));
- } catch (Exception e) {
- LOG.warn("", e);
- }
- });
- }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleBuider.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleBuider.java
deleted file mode 100644
index a439ff0..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleBuider.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import io.dropwizard.Configuration;
-
-public class AutoConfigBundleBuider<T extends Configuration> {
-
- private static final String DEFAULT_PACKAGE_NAME="org.onap";
-
- private List<String> packageNames=new ArrayList<>();
-
- public AutoConfigBundleBuider(){
- packageNames.add( DEFAULT_PACKAGE_NAME);
- }
-
- public AutoConfigBundleBuider<T> addPackageName(String packageName) {
- this.packageNames.add(packageName);
- return this;
- }
-
-
- public AutoConfigBundle<T> build() {
- return new AutoConfigBundle<T>(packageNames);
- }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/IOCApplication.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/IOCApplication.java
deleted file mode 100644
index 6025028..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/IOCApplication.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import io.dropwizard.Application;
-import io.dropwizard.Configuration;
-import io.dropwizard.setup.Bootstrap;
-import io.dropwizard.setup.Environment;
-
-/**
- * complete IOC container startup
- *
- * @author hu.rui2
- *
- */
-public abstract class IOCApplication<T extends Configuration> extends Application<T> {
-
-
- @Override
- public void initialize(Bootstrap<T> bootstrap) {
- super.initialize(bootstrap);
- bootstrap.addBundle(new AutoConfigBundleBuider().build());
- }
-
- @Override
- public void run(T configuration, Environment environment) throws Exception {
-
- }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/ServiceLocatorManaged.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/ServiceLocatorManaged.java
deleted file mode 100644
index d6c0563..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/bundle/ServiceLocatorManaged.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import org.glassfish.hk2.api.ServiceLocator;
-
-import io.dropwizard.lifecycle.Managed;
-
-/**
- * Life cycle management for IOC containers
- * @author hu.rui
- *
- */
-public class ServiceLocatorManaged implements Managed{
-
-
-
- private ServiceLocator locator;
-
-
-
- public ServiceLocatorManaged(ServiceLocator locator) {
- super();
- this.locator = locator;
- }
-
- @Override
- public void start() throws Exception {
-
-
- }
-
- @Override
- public void stop() throws Exception {
- locator.shutdown();
- }
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceBinder.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceBinder.java
deleted file mode 100644
index f5801c8..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceBinder.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.utils;
-
-import java.util.Set;
-
-import org.glassfish.hk2.utilities.binding.AbstractBinder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author hu.rui
- *
- */
-public class ServiceBinder extends AbstractBinder {
-
- private static final Logger LOG = LoggerFactory.getLogger(ServiceBinder.class);
-
- final Set<Class<?>> klasses;
-
- public ServiceBinder(Set<Class<?>> services) {
- this.klasses = services;
- }
-
- @Override
- protected void configure() {
- for (Class<?> klass : this.klasses) {
-
- try{
- LOG.info("start active class:"+klass.getName());
- addActiveDescriptor(klass);
- }catch(Exception e){
- LOG.info("active class error:"+klass.getName(),e);
- }
-
-
- }
- }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceLocatorHolder.java b/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceLocatorHolder.java
deleted file mode 100644
index 394ab6c..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/dropwizard/ioc/utils/ServiceLocatorHolder.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.utils;
-
-import org.glassfish.hk2.api.ServiceLocator;
-
-/**
- * @author hu.rui
- *
- */
-public class ServiceLocatorHolder {
-
- private static ServiceLocator locator;
-
- public static ServiceLocator getLocator() {
- return locator;
- }
-
- public static void setLocator(ServiceLocator locator) {
- ServiceLocatorHolder.locator = locator;
- }
-
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java b/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java
index 5ca38e0..71c9827 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityDao.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,16 +16,16 @@
package org.onap.holmes.common.engine.dao;
+import org.jdbi.v3.sqlobject.config.RegisterRowMapper;
+import org.jdbi.v3.sqlobject.customizer.Bind;
+import org.jdbi.v3.sqlobject.customizer.BindBean;
+import org.jdbi.v3.sqlobject.statement.SqlQuery;
+import org.jdbi.v3.sqlobject.statement.SqlUpdate;
import org.onap.holmes.common.engine.entity.EngineEntity;
-import org.skife.jdbi.v2.sqlobject.Bind;
-import org.skife.jdbi.v2.sqlobject.BindBean;
-import org.skife.jdbi.v2.sqlobject.SqlQuery;
-import org.skife.jdbi.v2.sqlobject.SqlUpdate;
-import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
import java.util.List;
-@RegisterMapper(EngineEntityMapper.class)
+@RegisterRowMapper(EngineEntityMapper.class)
public interface EngineEntityDao {
@SqlQuery("SELECT * FROM ENGINE_ENTITY WHERE ID = :id")
EngineEntity getEntity(@Bind("id") String id);
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java b/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java
index cda38a5..5432027 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/engine/dao/EngineEntityMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,20 +16,20 @@
package org.onap.holmes.common.engine.dao;
+import org.jdbi.v3.core.mapper.RowMapper;
+import org.jdbi.v3.core.statement.StatementContext;
import org.onap.holmes.common.engine.entity.EngineEntity;
-import org.skife.jdbi.v2.StatementContext;
-import org.skife.jdbi.v2.tweak.ResultSetMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class EngineEntityMapper implements ResultSetMapper<EngineEntity> {
+public class EngineEntityMapper implements RowMapper<EngineEntity> {
@Override
- public EngineEntity map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
+ public EngineEntity map(ResultSet rs, StatementContext ctx) throws SQLException {
EngineEntity entity = new EngineEntity();
- entity.setIp(resultSet.getString("ip"));
- entity.setPort(resultSet.getInt("port"));
- entity.setLastModified(resultSet.getLong("lastmodified"));
+ entity.setIp(rs.getString("ip"));
+ entity.setPort(rs.getInt("port"));
+ entity.setLastModified(rs.getLong("lastmodified"));
return entity;
}
} \ No newline at end of file
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java b/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java
index b913f38..630d55c 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/EngineEntityService.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2021 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +16,10 @@
package org.onap.holmes.common.engine.service;
-import org.jvnet.hk2.annotations.Contract;
import org.onap.holmes.common.engine.entity.EngineEntity;
import java.util.List;
-@Contract
public interface EngineEntityService {
EngineEntity getEntity(String id);
List<EngineEntity> getAllEntities();
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java b/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java
index 62d2388..7692cf9 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImpl.java
@@ -16,13 +16,13 @@
package org.onap.holmes.common.engine.service.impl;
-import org.jvnet.hk2.annotations.Service;
+import org.onap.holmes.common.database.DbDaoUtil;
import org.onap.holmes.common.engine.dao.EngineEntityDao;
import org.onap.holmes.common.engine.entity.EngineEntity;
import org.onap.holmes.common.engine.service.EngineEntityService;
-import org.onap.holmes.common.utils.DbDaoUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
-import javax.inject.Inject;
import java.util.List;
@Service
@@ -30,7 +30,7 @@ public class EngineEntityServiceImpl implements EngineEntityService {
private EngineEntityDao engineEntityDao;
- @Inject
+ @Autowired
public EngineEntityServiceImpl(DbDaoUtil dbDaoUtil){
engineEntityDao = dbDaoUtil.getJdbiDaoByOnDemand(EngineEntityDao.class);
}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java
index e5b0830..996df25 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2021 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,17 @@
*/
package org.onap.holmes.common.utils;
+import org.jdbi.v3.core.mapper.RowMapper;
+import org.jdbi.v3.core.statement.StatementContext;
import org.onap.holmes.common.api.entity.AlarmInfo;
-import org.skife.jdbi.v2.StatementContext;
-import org.skife.jdbi.v2.tweak.ResultSetMapper;
+
import java.sql.ResultSet;
import java.sql.SQLException;
-public class AlarmInfoMapper implements ResultSetMapper<AlarmInfo> {
+public class AlarmInfoMapper implements RowMapper<AlarmInfo> {
@Override
- public AlarmInfo map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
+ public AlarmInfo map(ResultSet resultSet, StatementContext statementContext) throws SQLException {
AlarmInfo alarmInfo = new AlarmInfo();
alarmInfo.setAlarmIsCleared(resultSet.getInt("alarmiscleared"));
alarmInfo.setRootFlag(resultSet.getInt("rootflag"));
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/CommonUtils.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/CommonUtils.java
index 9aa2e0b..837baed 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/CommonUtils.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/CommonUtils.java
@@ -14,11 +14,12 @@
package org.onap.holmes.common.utils;
-import org.jvnet.hk2.annotations.Service;
+
+import org.springframework.stereotype.Component;
import java.util.regex.Pattern;
-@Service
+@Component
public class CommonUtils {
final static public String IP_REG = "(http(s)?://)?(\\d+\\.\\d+\\.\\d+\\.\\d+)(:(\\d+))?";
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java
index a0fbd93..ed1c581 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2021 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,17 +16,18 @@
package org.onap.holmes.common.utils;
+import org.jdbi.v3.core.mapper.RowMapper;
+import org.jdbi.v3.core.statement.StatementContext;
+import org.onap.holmes.common.api.entity.CorrelationRule;
+
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
-import org.onap.holmes.common.api.entity.CorrelationRule;
-import org.skife.jdbi.v2.StatementContext;
-import org.skife.jdbi.v2.tweak.ResultSetMapper;
-public class CorrelationRuleMapper implements ResultSetMapper<CorrelationRule> {
+public class CorrelationRuleMapper implements RowMapper<CorrelationRule> {
@Override
- public CorrelationRule map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
+ public CorrelationRule map(ResultSet resultSet, StatementContext statementContext) throws SQLException {
CorrelationRule correlationRule = new CorrelationRule();
correlationRule.setName(resultSet.getString("name"));
correlationRule.setRid(resultSet.getString("rid"));
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/DbDaoUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/DbDaoUtil.java
deleted file mode 100644
index 05792c5..0000000
--- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/DbDaoUtil.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Copyright 2017-2020 ZTE Corporation.
- * <p>
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.utils;
-
-import io.dropwizard.db.DataSourceFactory;
-import io.dropwizard.jdbi.DBIFactory;
-import io.dropwizard.setup.Environment;
-import org.jvnet.hk2.annotations.Service;
-import org.skife.jdbi.v2.DBI;
-import org.skife.jdbi.v2.Handle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-@Singleton
-@Service
-public class DbDaoUtil {
-
- private Logger log = LoggerFactory.getLogger(DbDaoUtil.class);
-
- private DBI jdbi;
- @Inject
- private Environment environmentProvider;
- @Inject
- private DataSourceFactory dataSourceFactoryProvider;
-
- private DBIFactory factory = new DBIFactory();
-
- @PostConstruct
- public synchronized void init() {
- if (jdbi == null) {
- jdbi = factory.build(environmentProvider, dataSourceFactoryProvider, "postgres");
- }
- }
-
- public <K> K getDao(Class<K> clazz) {
- try {
- return jdbi.open(clazz);
- } catch (Exception e) {
- log.warn("get object instance of Dao error.", e);
- }
- return null;
- }
-
- public Handle getHandle() {
- try {
- return jdbi.open();
- } catch (Exception e) {
- log.warn("get object instance of Dao error.", e);
- }
- return null;
- }
-
- public void close(Object obj) {
- if (obj != null) {
- try {
- jdbi.close(obj);
- } catch (Exception e) {
- log.warn("close jdbi connection error.", e);
- }
- }
- }
-
- public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {
-
- return jdbi.onDemand(daoClazz);
-
- }
-
- public <T> T getJdbiDaoByOpen(Class<T> daoClazz) {
-
- return jdbi.open(daoClazz);
-
- }
-}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java
index cfb601a..d8b5215 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/JerseyClient.java
@@ -16,7 +16,6 @@
package org.onap.holmes.common.utils;
-import org.onap.holmes.common.exception.HttpException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java
index 33b53c7..957b818 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/MsbRegister.java
@@ -18,13 +18,13 @@ package org.onap.holmes.common.utils;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.config.MicroServiceConfig;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;
import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/RestExceptionHandler.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/RestExceptionHandler.java
new file mode 100644
index 0000000..f70cf68
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/RestExceptionHandler.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2021 ZTE Corporation.
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.common.utils;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import javax.ws.rs.WebApplicationException;
+
+@RestControllerAdvice
+public class RestExceptionHandler {
+
+ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
+ @ExceptionHandler(WebApplicationException.class)
+ public String handleWebApplicationException(WebApplicationException ex){
+ return ex.getResponse().getEntity().toString();
+ }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/SpringContextUtil.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/SpringContextUtil.java
new file mode 100644
index 0000000..b959c0a
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/SpringContextUtil.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2021 ZTE Corporation.
+ * <p>
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.holmes.common.utils;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SpringContextUtil implements ApplicationContextAware {
+
+ private static ApplicationContext applicationContext;
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ SpringContextUtil.applicationContext = applicationContext;
+ }
+
+ public static Object getBean(String name) {
+ return applicationContext.getBean(name);
+ }
+
+ public static <T> T getBean(Class<T> clazz) {
+ return applicationContext.getBean(clazz);
+ }
+
+ public static <T> T getBean(String name, Class<T> clazz) {
+ return applicationContext.getBean(name, clazz);
+ }
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilter.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilter.java
index 9d42b91..725084a 100644
--- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilter.java
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/transactionid/TransactionIdFilter.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2018 - 2021 ZTE Corporation.
+ * Copyright 2018-2021 ZTE Corporation.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,20 +17,22 @@ package org.onap.holmes.common.utils.transactionid;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
-import org.jvnet.hk2.annotations.Service;
import org.slf4j.MDC;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
+import org.springframework.stereotype.Component;
import javax.servlet.*;
+import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;
-@Service
@Slf4j
+@Component
+@WebFilter(urlPatterns = {"/*"})
public class TransactionIdFilter implements Filter {
public static final Marker INVOKE_SYNCHRONOUS;
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmsCorrelationTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmsCorrelationTest.java
deleted file mode 100644
index 822d74c..0000000
--- a/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/AlarmsCorrelationTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.holmes.common.api.entity;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-import java.util.Date;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-
-public class AlarmsCorrelationTest {
-
- private AlarmsCorrelation alarmsCorrelation;
-
- @Before
- public void before() throws Exception {
- alarmsCorrelation = new AlarmsCorrelation();
- }
-
- @After
- public void after() throws Exception {
-
- }
-
-
- @Test
- public void getterAndSetter4RuleId() throws Exception {
- final String ruleId = "ruleId";
- alarmsCorrelation.setRuleId(ruleId);
- assertThat(alarmsCorrelation.getRuleId(), equalTo(ruleId));
- }
-
-
- @Test
- public void getterAndSetter4RuleInfo() throws Exception {
- final String ruleInfo = "ruleInfo";
- alarmsCorrelation.setRuleInfo(ruleInfo);
- assertThat(alarmsCorrelation.getRuleInfo(), equalTo(ruleInfo));
- }
-
-
- @Test
- public void getterAndSetter4ResultType() throws Exception {
- final byte resultType = 1;
- alarmsCorrelation.setResultType(resultType);
- assertThat(alarmsCorrelation.getResultType(), equalTo(resultType));
- }
-
-
- @Test
- public void getterAndSetter4CreateTime() throws Exception {
- final Date createTime = new Date();
- alarmsCorrelation.setCreateTime(createTime);
- assertThat(alarmsCorrelation.getCreateTime(), equalTo(createTime));
- }
-
-
- @Test
- public void getterAndSetter4ParentAlarmId() throws Exception {
- final long pad = 11L;
- alarmsCorrelation.setParentAlarmId(pad);
- assertThat(alarmsCorrelation.getParentAlarmId(), equalTo(pad));
- }
-
-
- @Test
- public void getterAndSetter4ChildAlarmId() throws Exception {
- final long childAlarmId = 11L;
- alarmsCorrelation.setChildAlarmId(childAlarmId);
- assertThat(alarmsCorrelation.getChildAlarmId(), equalTo(childAlarmId));
- }
-
-
- @Test
- public void getterAndSetter4Reserve1() throws Exception {
- final long reserve1 = 11L;
- alarmsCorrelation.setReserve1(reserve1);
- assertThat(alarmsCorrelation.getReserve1(), equalTo(reserve1));
- }
-
-
- @Test
- public void getterAndSetter4Reserve2() throws Exception {
- final long reserve2 = 11L;
- alarmsCorrelation.setReserve2(reserve2);
- assertThat(alarmsCorrelation.getReserve2(), equalTo(reserve2));
- }
-
-
- @Test
- public void getterAndSetter4Reserve3() throws Exception {
- final long reserve3 = 11L;
- alarmsCorrelation.setReserve3(reserve3);
- assertThat(alarmsCorrelation.getReserve3(), equalTo(reserve3));
- }
-
- @Test
- public void testToString() throws Exception {
- final AlarmsCorrelation alarmsCorrelationTemp = new AlarmsCorrelation();
- String ruleId = "ruleId";
- alarmsCorrelationTemp.setRuleId(ruleId);
- alarmsCorrelation.setRuleId(ruleId);
- assertThat(alarmsCorrelation.toString(), equalTo(alarmsCorrelationTemp.toString()));
- }
-}
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/config/MQConfigTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/config/MQConfigTest.java
deleted file mode 100644
index cc9dced..0000000
--- a/holmes-actions/src/test/java/org/onap/holmes/common/config/MQConfigTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.holmes.common.config;
-
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-
-public class MQConfigTest {
- @Test
- public void testNewClass() {
- MQConfig mqConfig= new MQConfig();
- }
-}
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleTest.java
deleted file mode 100644
index 8cf044f..0000000
--- a/holmes-actions/src/test/java/org/onap/holmes/common/dropwizard/ioc/bundle/AutoConfigBundleTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017-2020 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.holmes.common.dropwizard.ioc.bundle;
-
-import io.dropwizard.Configuration;
-import io.dropwizard.setup.Environment;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertThat;
-
-public class AutoConfigBundleTest {
- @Test
- public void newBuilder() {
- assertThat(AutoConfigBundle.newBuilder(), instanceOf(AutoConfigBundleBuider.class));
- }
-
- @Test
- public void run() throws Exception {
- AutoConfigBundle.newBuilder().build().run(new Configuration(), new Environment("Test"));
- }
-
-} \ No newline at end of file
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/engine/dao/EngineEntityMapperTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/engine/dao/EngineEntityMapperTest.java
index 99b14ab..b201495 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/engine/dao/EngineEntityMapperTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/engine/dao/EngineEntityMapperTest.java
@@ -44,7 +44,7 @@ public class EngineEntityMapperTest {
PowerMock.replay(rsMock);
- EngineEntity entity = mapper.map(0, rsMock, null);
+ EngineEntity entity = mapper.map( rsMock, null);
PowerMock.verify(rsMock);
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java
index 21a4025..cb16650 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/engine/service/impl/EngineEntityServiceImplTest.java
@@ -16,23 +16,21 @@
package org.onap.holmes.common.engine.service.impl;
-import com.google.common.base.CharMatcher;
-import org.junit.Before;
+import org.jdbi.v3.core.Jdbi;
import org.junit.Test;
import org.onap.holmes.common.engine.dao.EngineEntityDao;
import org.onap.holmes.common.engine.entity.EngineEntity;
import org.onap.holmes.common.engine.service.EngineEntityService;
-import org.onap.holmes.common.utils.DbDaoUtil;
+import org.onap.holmes.common.database.DbDaoUtil;
import java.util.*;
-import static com.google.common.base.Predicates.notNull;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.*;
public class EngineEntityServiceImplTest {
- private EngineEntityService service = new EngineEntityServiceImpl(new DbDaoUtilStub());
+ private EngineEntityService service = new EngineEntityServiceImpl(new DbDaoUtilStub(null));
@Test
public void getLegacyEngines() {
@@ -78,6 +76,10 @@ public class EngineEntityServiceImplTest {
class DbDaoUtilStub extends DbDaoUtil {
private EngineEntityDao dao = new EngineEntityDaoStub();
+ public DbDaoUtilStub(Jdbi jdbi) {
+ super(jdbi);
+ }
+
@Override
public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java
index 3d36def..9ea0057 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/utils/AlarmInfoMapperTest.java
@@ -1,12 +1,12 @@
/**
* Copyright 2017 ZTE Corporation.
- *
+ * <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,13 +33,13 @@ public class AlarmInfoMapperTest {
expect(resultSet.getString("eventname")).andReturn("");
expect(resultSet.getString("sourceid")).andReturn("");
expect(resultSet.getString("sourcename")).andReturn("");
- expect(resultSet.getInt("sequence")).andReturn(0);
+ expect(resultSet.getInt("sequence")).andReturn(0);
expect(resultSet.getLong("startepochmicrosec")).andReturn(0L);
expect(resultSet.getLong("lastepochmicrosec")).andReturn(0L);
expect(resultSet.getInt("alarmiscleared")).andReturn(0);
expect(resultSet.getInt("rootflag")).andReturn(0);
PowerMock.replay(resultSet);
- mapper.map(0, resultSet, null);
+ mapper.map(resultSet, null);
PowerMock.verify(resultSet);
}
}
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java
index c18c828..9ea92ca 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java
@@ -49,7 +49,7 @@ public class CorrelationRuleMapperTest {
expect(resultSet.getString("ctrlloop")).andReturn("");
expect(resultSet.getString("engineinstance")).andReturn("");
PowerMock.replay(resultSet);
- mapper.map(0, resultSet, null);
+ mapper.map(resultSet, null);
PowerMock.verify(resultSet);
}
} \ No newline at end of file
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/utils/DbDaoUtilTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/utils/DbDaoUtilTest.java
index dd42044..696de45 100644
--- a/holmes-actions/src/test/java/org/onap/holmes/common/utils/DbDaoUtilTest.java
+++ b/holmes-actions/src/test/java/org/onap/holmes/common/utils/DbDaoUtilTest.java
@@ -16,161 +16,29 @@
package org.onap.holmes.common.utils;
-import io.dropwizard.db.DataSourceFactory;
-import io.dropwizard.jdbi.DBIFactory;
-import io.dropwizard.setup.Environment;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Ignore;
+import org.jdbi.v3.core.Jdbi;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
+import org.onap.holmes.common.database.DbDaoUtil;
import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.reflect.Whitebox;
-import org.skife.jdbi.v2.DBI;
-import org.skife.jdbi.v2.Handle;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.expect;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
@RunWith(PowerMockRunner.class)
-@PrepareForTest({DbDaoUtil.class, DBIFactory.class, DBI.class})
public class DbDaoUtilTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- private DBI jdbi;
-
- private Environment environmentProvider;
-
- private DataSourceFactory dataSourceFactoryProvider;
-
- private DbDaoUtil dbDaoUtil;
-
- private DBIFactory factory;
-
- @Before
- public void before() throws Exception {
- dbDaoUtil = new DbDaoUtil();
-
- jdbi = PowerMock.createMock(DBI.class);
- environmentProvider = PowerMock.createMock(Environment.class);
- dataSourceFactoryProvider = PowerMock.createMock(DataSourceFactory.class);
- factory = PowerMock.createMock(DBIFactory.class);
- PowerMock.expectNew(DBIFactory.class).andReturn(factory);
-
- Whitebox.setInternalState(dbDaoUtil, "environmentProvider", environmentProvider);
- Whitebox.setInternalState(dbDaoUtil, "dataSourceFactoryProvider",
- dataSourceFactoryProvider);
-
- PowerMock.resetAll();
- }
-
- @Test
- @Ignore
- public void init() {
- PowerMock.createMock(DBI.class);
-
- expect(factory.build(anyObject(Environment.class), anyObject(DataSourceFactory.class),
- anyObject(String.class))).andReturn(jdbi);
-
- PowerMock.replayAll();
-
- dbDaoUtil.init();
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void getDao_normal() {
- Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
- expect(jdbi.open(anyObject(Class.class))).andReturn(Class.class);
-
- PowerMock.replayAll();
-
- dbDaoUtil.getDao(String.class);
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void getDao_exception() {
- Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
-
- expect(jdbi.open(anyObject(Class.class))).andThrow(new RuntimeException(""));
-
- PowerMock.replayAll();
-
- Object o = dbDaoUtil.getDao(String.class);
-
- PowerMock.verifyAll();
-
- assertThat(o, equalTo(null));
- }
-
- @Test
- public void getHandle_normal() {
- Handle handle = PowerMock.createMock(Handle.class);
-
- Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
- expect(jdbi.open()).andReturn(handle);
-
- PowerMock.replayAll();
-
- dbDaoUtil.getHandle();
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void getHandle_exception() {
- Handle handle = PowerMock.createMock(Handle.class);
-
- Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
- expect(jdbi.open()).andThrow(new RuntimeException(""));
-
- PowerMock.replayAll();
-
- Handle handle1 = dbDaoUtil.getHandle();
-
- PowerMock.verifyAll();
-
- assertThat(handle1, equalTo(null));
- }
-
- @Test
- public void close_normal() {
- Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
- jdbi.close(anyObject());
-
- PowerMock.replayAll();
-
- dbDaoUtil.close(new Object());
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void close_exception() {
- Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
- jdbi.close(anyObject());
- EasyMock.expectLastCall().andThrow(new RuntimeException(""));
- PowerMock.replayAll();
-
- dbDaoUtil.close(new Object());
-
- PowerMock.verifyAll();
- }
@Test
public void testGetJdbiDaoByOnDemand() {
- Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
+ Jdbi jdbi = PowerMock.createMock(Jdbi.class);
+ DbDaoUtil dbDaoUtil = new DbDaoUtil(jdbi);
expect(jdbi.onDemand(anyObject(Class.class))).andReturn(Class.class);
PowerMock.replayAll();
@@ -180,15 +48,4 @@ public class DbDaoUtilTest {
PowerMock.verifyAll();
}
- @Test
- public void testGetJdbiDaoByOpen() {
- Whitebox.setInternalState(dbDaoUtil, "jdbi", jdbi);
- expect(jdbi.open(anyObject(Class.class))).andReturn(Class.class);
-
- PowerMock.replayAll();
-
- dbDaoUtil.getJdbiDaoByOpen(String.class);
-
- PowerMock.verifyAll();
- }
}
diff --git a/pom.xml b/pom.xml
index 0c7021b..d933a5e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,9 @@
<bundle.name>${project.artifactId}-${project.version}</bundle.name>
<powermock.version>2.0.7</powermock.version>
+ <springboot.version>2.7.2</springboot.version>
+ <spring-framework.version>5.3.13</spring-framework.version>
+ <jdbi.version>3.19.0</jdbi.version>
<dropwizard.version>2.0.9</dropwizard.version>
<swagger.version>1.6.4</swagger.version>
@@ -53,6 +56,49 @@
<dependencyManagement>
<dependencies>
<dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${springboot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${spring-framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jdbi</groupId>
+ <artifactId>jdbi3-postgres</artifactId>
+ <version>${jdbi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jdbi</groupId>
+ <artifactId>jdbi3-sqlobject</artifactId>
+ <version>${jdbi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jdbi</groupId>
+ <artifactId>jdbi3-spring4</artifactId>
+ <version>${jdbi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>4.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>42.2.13</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.10</version>
@@ -84,23 +130,6 @@
<version>${jersey.version}</version>
</dependency>
<dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-core</artifactId>
- <version>${dropwizard.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-db</artifactId>
- <version>${dropwizard.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-jdbi</artifactId>
- <version>2.0.0-rc9</version>
- </dependency>
- <dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>${swagger.version}</version>